Java Web Application Security



Similar documents
3. Broken Account and Session Management. 4. Cross-Site Scripting (XSS) Flaws. Web browsers execute code sent from websites. Account Management

Secure Web Application Coding Team Introductory Meeting December 1, :00 2:00PM Bits & Pieces Room, Sansom West Room 306 Agenda

Where every interaction matters.

What is Web Security? Motivation

WHITE PAPER. FortiWeb and the OWASP Top 10 Mitigating the most dangerous application security threats

Last update: February 23, 2004

OWASP and OWASP Top 10 (2007 Update) OWASP. The OWASP Foundation. Dave Wichers. The OWASP Foundation. OWASP Conferences Chair

Check list for web developers

Out of the Fire - Adding Layers of Protection When Deploying Oracle EBS to the Internet

Web Engineering Web Application Security Issues

Attack Vector Detail Report Atlassian

The Top Web Application Attacks: Are you vulnerable?

Web applications. Web security: web basics. HTTP requests. URLs. GET request. Myrto Arapinis School of Informatics University of Edinburgh

Creating Stronger, Safer, Web Facing Code. JPL IT Security Mary Rivera June 17, 2011

ArcGIS Server Security Threats & Best Practices David Cordes Michael Young

Acunetix Website Audit. 5 November, Developer Report. Generated by Acunetix WVS Reporter (v8.0 Build )

Detecting Web Application Vulnerabilities Using Open Source Means. OWASP 3rd Free / Libre / Open Source Software (FLOSS) Conference 27/5/2008

SAST, DAST and Vulnerability Assessments, = 4

Thick Client Application Security

Passing PCI Compliance How to Address the Application Security Mandates

State of Web Application Security. Ralph Durkee Durkee Consulting, Inc. Rochester ISSA & OWASP Chapters rd@rd1.net

Web application security

Web Application Penetration Testing

Magento Security and Vulnerabilities. Roman Stepanov

Web Application Security

Web Application Threats and Vulnerabilities Web Server Hacking and Web Application Vulnerability

Strategic Information Security. Attacking and Defending Web Services

FINAL DoIT v.4 PAYMENT CARD INDUSTRY DATA SECURITY STANDARDS APPLICATION DEVELOPMENT AND MAINTENANCE PROCEDURES

FINAL DoIT v.8 APPLICATION SECURITY PROCEDURE

Introduction to Web Application Security. Microsoft CSO Roundtable Houston, TX. September 13 th, 2006

Top Ten Web Attacks. Saumil Shah Net-Square. BlackHat Asia 2002, Singapore

Essential IT Security Testing

Cracking the Perimeter via Web Application Hacking. Zach Grace, CISSP, CEH January 17, Mega Conference

Threat Modeling/ Security Testing. Tarun Banga, Adobe 1. Agenda

Adobe Systems Incorporated

CSE598i - Web 2.0 Security OWASP Top 10: The Ten Most Critical Web Application Security Vulnerabilities

Implementation of Web Application Firewall

Don t Get Burned! Are you Leaving your Critical Applications Defenseless?

Web Application Security Assessment and Vulnerability Mitigation Tests

An Introduction to Application Security In ASP.NET Environments. Houston.NET User Group. February 23 rd, 2006

Criteria for web application security check. Version

Web Application Report

Web Application Vulnerability Testing with Nessus

Web App Security Audit Services

CIS 551 / TCOM 401 Computer and Network Security. Spring 2007 Lecture 20

Top Ten Web Application Vulnerabilities in J2EE. Vincent Partington and Eelco Klaver Xebia

How to Build a Trusted Application. John Dickson, CISSP

External Vulnerability Assessment. -Technical Summary- ABC ORGANIZATION

Sichere Software- Entwicklung für Java Entwickler

Web Application Security Considerations

Threat Modeling. Categorizing the nature and severity of system vulnerabilities. John B. Dickson, CISSP

OWASP Top Ten Tools and Tactics

Chapter 1 Web Application (In)security 1

Introduction to Computer Security

Hack Yourself First. Troy troyhunt.com

Web Application Security

elearning for Secure Application Development

Web-Application Security

Web Application Security. Vulnerabilities, Weakness and Countermeasures. Massimo Cotelli CISSP. Secure

THE PROXY SERVER 1 1 PURPOSE 3 2 USAGE EXAMPLES 4 3 STARTING THE PROXY SERVER 5 4 READING THE LOG 6

Playing with Web Application Firewalls

Web Application Hacking (Penetration Testing) 5-day Hands-On Course

Application Code Development Standards

Using Free Tools To Test Web Application Security

Web Application Security

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Application Security: What Does it Take to Build and Test a Trusted App? John Dickson, CISSP Denim Group

Cyber Security Workshop Ethical Web Hacking

Intrusion detection for web applications

Securing Your Web Application against security vulnerabilities. Ong Khai Wei, IT Specialist, Development Tools (Rational) IBM Software Group

Data Platform Security. Vinod Kumar Technology Evangelist

ASP.NET MVC Secure Coding 4-Day hands on Course. Course Syllabus

Still Aren't Doing. Frank Kim

Crowbar: New generation web application brute force attack tool

Web Security Threat Report: January April Ryan C. Barnett WASC Member Project Lead: Distributed Open Proxy Honeypots

SQuAD: Application Security Testing

Application Security Testing. Erez Metula (CISSP), Founder Application Security Expert

National Information Security Group The Top Web Application Hack Attacks. Danny Allan Director, Security Research

The purpose of this report is to educate our prospective clients about capabilities of Hackers Locked.

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

Mingyu Web Application Firewall (DAS- WAF) All transparent deployment for Web application gateway

reference: HTTP: The Definitive Guide by David Gourley and Brian Totty (O Reilly, 2002)

Simon Fraser University. Web Security. Dr. Abhijit Sen CMPT 470

Web Application Attacks and Countermeasures: Case Studies from Financial Systems

The Weakest Link: Mitigating Web Application Vulnerabilities. webscurity White Paper. webscurity Inc. Minneapolis, Minnesota USA

IJMIE Volume 2, Issue 9 ISSN:

Columbia University Web Security Standards and Practices. Objective and Scope

Top 10 Web Application Security Vulnerabilities - with focus on PHP

Ethical Hacking as a Professional Penetration Testing Technique

Application Security Best Practices. Wally LEE Principal Consultant

Web Application Security

We protect you applications! No, you don t. Digicomp Hacking Day 2013 May 16 th 2013

Data Breaches and Web Servers: The Giant Sucking Sound

WHITE PAPER FORTIWEB WEB APPLICATION FIREWALL. Ensuring Compliance for PCI DSS 6.5 and 6.6

Integrated Network Vulnerability Scanning & Penetration Testing SAINTcorporation.com

Sitefinity Security and Best Practices

An Introduction to Application Security in J2EE Environments

Testing Web Applications for SQL Injection Sam Shober

Network Security Audit. Vulnerability Assessment (VA)

Application Layer Encryption: Protecting against Application Logic and Session Theft Attacks. Whitepaper

Transcription:

Java Web Application Security RJUG Nov 11, 2003 Durkee Consulting www.rd1.net 1

Ralph Durkee SANS Certified Mentor/Instructor SANS GIAC Network Security and Software Development Consulting Durkee Consulting www.rd1.net 2

Agenda Intro and Definition Web Application Risk Overview Threat Categories Overview Top 10 Vulnerabilities Examine some vulnerabilities in detail Sun Security Code Guidelines for Java Durkee Consulting www.rd1.net 3

Definition of Web Application Vulnerabilities Web Applications: Software applications that interact with users or other applications using HTTP/s Could include Web services which communicate between Applications via XML Web Application Vulnerabilities: Weakness in custom Web Application, architecture, design, configuration, or code. Durkee Consulting www.rd1.net 4

Web Applications What s the Risk? Risk = Threat * Vulnerability * Asset Threat Level for Internet Web Servers? Web attacks are very frequent (3-8 attacks / probes per day per IP is normal) Port 80 consistently one of the top 10 attacked (www.incidents.org) Vulnerabilities Plenty to come on Vulnerabilities Asset Estimate of all potential losses and costs. Durkee Consulting www.rd1.net 5

Traditional Threat Categories Threat Target Network Protocols Operating System Commercial Applications Mitigation Firewalls, Routers etc Patching, Hardening, Minimize Services Patching, Configuration Sophistication Automated Automated Automated Durkee Consulting www.rd1.net 6

Custom Application 4 th Threat Category Threat Target Network Protocols Operating System Commercial Applications Custom Application Software Mitigation Firewalls, Routers etc Patching, Hardening, Minimize Services Patching, Configuration Arch. Design & Code Reviews Appl. Testing Appl. Scanners Sophistication Automated Automated Automated Not Yet Automated Durkee Consulting www.rd1.net 7

How Bad Is It? Sanctum reports 97% of 300 Web Applications Audited were Vulnerable Gartner reports 75% of attacks today are at the Application Level If it really is that bad, why aren t majority of web sites defaced and infected with worms? Durkee Consulting www.rd1.net 8

If it really is that bad, Why? Why aren t majority of web sites defaced and infected with worms? Very difficult to write automated worms against custom software. Good news: What can be automated by attackers, can also be discovered by security scanners. Without automation, attack of web applications is semi-manual one-off process. Durkee Consulting www.rd1.net 9

If it really is that bad, Why? (continued) Technical difficulty eliminates the lowest level script kiddies, but do-able by even intermediate attackers. Difficult to estimate the number of Web Applications already compromised especially if attackers are quietly keeping ownership rather than defacing. Durkee Consulting www.rd1.net 10

OWASP Open Web Application Security Project WWW.OWASP.ORG Dedicated to helping organizations understand and improve the security of their web application and web services. Publish Top 10 Web App. Vulnerabilities Open Source Projects (WebGoat, WebScarab) Durkee Consulting www.rd1.net 11

OWASP Top 10 OWASP A1 - Unvalidated Parameters A2 - Broken Access Control A3 - Broken Account & Session Management Description Malicious input may attack server or back-end components. Access not well defined with controls which may be bypassed with client side manipulation. Session or Account authentication may be disclosed or guessed. Durkee Consulting www.rd1.net 12

OWASP Top 10 OWASP A4 - Cross Site Scripting A5 - Buffer Overflows A6 - Cmd Injection Description Malicious script is stored by the Web Application and given to an unsuspecting victim. Providing too much input allows code execution to be manipulated. Manipulates server evaluation of input to execute commands. Durkee Consulting www.rd1.net 13

OWASP Top 10 OWASP A7 - Error Handling A8 - Insecure Cryptography A9 - Remote Admin flaws A10 - Server misconfiguration Description Diagnostics reveal platforms, architecture and identifiers. Improper usage and home grown algorithms Inadequate controls and protection. Not using security configuration guidelines. Durkee Consulting www.rd1.net 14

Types of Input for Validation Form Input parameters <INPUT name=userid value= shmoe > Hidden form parameters <INPUT TYPE=hidden name=sessionid value= 928302757461044230129736 > Keep mind all input parameters are visible and can be modified. Durkee Consulting www.rd1.net 15

URL Query String Parameters Example https://www.rd1.net/servlet/login?userid=shmoe& password=dumb Least secure place for parameters Stored in browser history cache Visible to shoulder surfing Could be Book Marked App. Servers often allow this transparently. Durkee Consulting www.rd1.net 16

Cookies Flavors Persistent with expiration date / time, stored on client hard drive Non-persistent, no expiration, stored in memory until browser closed. Secure option (request https transmission) Durkee Consulting www.rd1.net 17

Cookies Example: Server Response and Client Request Set-Cookie: siteid=91d3dc13713aa579d0f148972384f4; path=/; expires=wednesday, 12-Oct-2003 02:12:40 domain=.www.rd1.net secure Cookie: siteid=91d3dc13713aa579d0f148972384f4 Durkee Consulting www.rd1.net 18

HTTP Headers Carry a good deal of information Access through various program API s. Easy to use HTTP header input without considering the need for validation. Durkee Consulting www.rd1.net 19

HTTP Headers Accept: image/gif, image/x-xbitmap, image/jpeg,..., */* Referer: http://rd1.net/index.html Accept-Language: en-us Content-Type: application/x-www-formurlencoded User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; T312) Host: rd1.net Content-Length: 46 Durkee Consulting www.rd1.net 20

HTTP Headers Java Sample URL server_url = new URL( urlstr); URLConnection conn = server_url.openconnection(); // Additional code int len = conn.getcontentlength(); What if len < 0? Or a very large value? Is the call getting the http header value or the actual length? What happens if they differ? Durkee Consulting www.rd1.net 21

Examples of Malicious Input Buffer overflows Command or Script injection SQL injection Cross Site Scripting (XSS) Improper Error Handling Input encoding Durkee Consulting www.rd1.net 22

Buffer Overflows Traditional C/C++ software Particularly dangerous May Allow arbitrary remote code execution. Not as Serious, but still a problem for Java. Needs to be handled gracefully Check before usage Catch exceptions to prevent a Denial of Service. Front End software should help protect back-end. Example: Check size before passing to DB or OS. Durkee Consulting www.rd1.net 23

Command or SQL injection Input may contain special Meta-characters Some Meta-characters will have significance to the script, OS or database interpreter Meta-characters may be encoded to attempt to circumvent filtering CERT URL http://www.cert.org/tech_tips/malicious_code_mitig ation.html Durkee Consulting www.rd1.net 24

SQL Injection JSP Example String squery = select userid from users where uname= + request.getparameter("user_nm ) + ; ; But What if.. user_nm= %27 or %27x%27=%27x The %27 is an encoded quote and the or x = x will always be true, May bypass the authentication and execute arbitrary SQL statements Durkee Consulting www.rd1.net 25

Cross Site Scripting (XSS) Any dynamic web page using unvalidated data is vulnerable. Data may contain html or client side scripting May originated from a malicious source May attack another client via web server Durkee Consulting www.rd1.net 26

XSS Example Durkee Consulting www.rd1.net 27

XSS Example Malicious XSS Input comment=<script>malicious code</script> Comment is placed in a DB Served up on a web page to an unsuspecting victim. Victims browser execute malicious code, and/or is sent to another site. Durkee Consulting www.rd1.net 28

Error Response Information Helpful Debug messages Provides way too much information! Very helpful to potential attacker. Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access 97 Driver] Can't open database VDPROD'. Durkee Consulting www.rd1.net 29

Improper Error Handling Possible Denial of Service Java Exceptions and Stack traces Very revealing! java.sql.sqlexception: ORA-00600: internal error code, arguments: [ttcgnd-1], [0], [], [], [], at oracle.jdbc.dbaccess.dberror.throwsqlexception (DBError.java:169) at oracle.jdbc.ttc7.ttioer.processerror (TTIoer.java:208) Durkee Consulting www.rd1.net 30

Inappropriate Information Disclosure Web Responses may provide inappropriate information. Example 1: Helpful web pages that let you know when a valid user id has been guessed. Response for valid user/invalid password should be exactly identical to invalid user. Even subtle differences are sufficient Example 2: Source html comments. Durkee Consulting www.rd1.net 31

Input Encoding Malicious Input can be encoded in many ways Each software layer and script languages has additional encoding. Attempts to avoid negative filtration. Examples; & & Double encoding: &amp; Triple? Durkee Consulting www.rd1.net 32

Where to Validate Client validation -- is helpful but does not provide security Server validation Everything received from client must be suspect Validate before usage or interpretation. Durkee Consulting www.rd1.net 33

How to validate Positive filtering preferred rather than Negative Canonical form (decode) where appropriate Encode special characters where appropriate Many types of encoding Durkee Consulting www.rd1.net 34

What to check Minimally Allowed Character Set (Specific to data field) Numeric Range Length too short or too long Optional or required Encoding of potential meta-characters that must be allowed. Null bytes Durkee Consulting www.rd1.net 35

Tips from Sun Security Code Guidelines Full text Available On-line From http://java.sun.com/security/seccodeguide.html Public Static fields Reducing scope Public methods and Variables Protecting packages Make objects immutable if possible Serialization Native methods Clear sensitive information Durkee Consulting www.rd1.net 36

Public Static Variables All Public Static variables should be final Ensure that only the appropriate code has permission to change Durkee Consulting www.rd1.net 37

Reducing scope Each class, method and variable provides an additional access point. Make classes method private where appropriate Make all variables private Restrict scope to the minimal Durkee Consulting www.rd1.net 38

Public Methods & Variables Avoid Public Variables Methods modifying sensitive internal states need to include security check Durkee Consulting www.rd1.net 39

Protecting packages Use sealed Jar files Attacker may try to gain access to package members by defining new classes within the attacked package by extending it. Durkee Consulting www.rd1.net 40

Make objects immutable if possible Especially arrays, vectors etc. Prevent modifications Provides better concurrency Avoid returning reference to sensitive data Never store user given data directly Durkee Consulting www.rd1.net 41

Protect Serialization Serialized Object is outside Java Security controls Requires additional controls to protect data Consider encryption or Digital Signatures Additional tips available on-line java.sun.com/security/seccodeguide.html Durkee Consulting www.rd1.net 42

Native methods CAREFUL! Examined : Return values and parameters bypass security checks Are they public, private,... Whether they contain method calls which bypass package-boundaries, thus bypassing package protection Durkee Consulting www.rd1.net 43

Clear Sensitive Information Such as Passwords etc. Prefer Mutable (such as array) Rather than immutable (such as a string) Perform explicate clearing of the information Do not leave it for the garbage collection. Durkee Consulting www.rd1.net 44

The Future for Web Application Security Application Security Testing tools Available but expensive still a bit green Application Firewalls also a bit new and bit overpriced. Better understanding of Vulnerabilities Better Security input validation support from Development tool Vendors More Design & Code Reviews. Durkee Consulting www.rd1.net 45

Resources www.owasp.org/ Top Ten Web Application Vulnerabilities OWASP guide WebGoat News, e-mail lists, articles etc. www.securityfocus.com/ Vulnerability information News, e-mail lists articles etc. Durkee Consulting www.rd1.net 46