Copyright © 2004 - The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.

Slides:



Advertisements
Similar presentations
Chapter 6 Server-side Programming: Java Servlets
Advertisements

OWASP’s Ten Most Critical Web Application Security Vulnerabilities
JLab Lattice Portal – Data Grid Web Service Ying Chen, Chip Watson Thomas Jefferson National Accelerator Facility.
Apache Tomcat as a container for Servlets and JSP
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the Creative Commons Attribution-ShareAlike.
Creating Stronger, Safer, Web Facing Code JPL IT Security Mary Rivera June 17, 2011.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Automating Bespoke Attack Ruei-Jiun Chapter 13. Outline Uses of bespoke automation ◦ Enumerating identifiers ◦ Harvesting data ◦ Web application fuzzing.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Servlets Compiled by Dr. Billy B. L. Lim. Servlets Servlets are Java programs which are invoked to service client requests on a Web server. Servlets extend.
A Servlet’s Job Read explicit data sent by client (form data) Read implicit data sent by client (request headers) Generate the results Send the explicit.
Java Servlets and JSP.
Web Application Vulnerabilities Checklist. EC-Council Parameter Checklist  URL request  URL encoding  Query string  Header  Cookie  Form field 
Struts 2.0 an Overview ( )
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the Creative Commons Attribution-ShareAlike.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Lecture 14 – Web Security SFDV3011 – Advanced Web Development 1.
Chapter 9 Web Applications. Web Applications are public and available to the entire world. Easy access to the application means also easy access for malicious.
Use to Implement: Input validation Page-Level authorization Session Management Audit Logging Use to Implement: Input validation Page-Level authorization.
Servlets. - Java technology for Common Gateway Interface (CGI) programming. - It is a Java class that dynamically extends the function of a web server.
Copyright 2007 © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
J2EE training: 1 Course Material Usage Rules PowerPoint slides for use only in full-semester, for-credit courses at degree-granting.
111 Java Servlets Dynamic Web Pages (Program Files) Servlets versus Java Server Pages Implementing Servlets Example: F15 Warranty Registration Tomcat Configuration.
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Web Server Programming 1. Nuts and Bolts. Premises of Course Provides general introduction, no in-depth training Assumes some HTML knowledge Assumes some.
Chapter 2. Core Defense Mechanisms. Fundamental security problem All user input is untrusted.
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Top Five Web Application Vulnerabilities Vebjørn Moen Selmersenteret/NoWires.org Norsk Kryptoseminar Trondheim
OWASP Top Ten #1 Unvalidated Input. Agenda What is the OWASP Top 10? Where can I find it? What is Unvalidated Input? What environments are effected? How.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Java Servlets & Java Server Pages Lecture July 2013.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
nd Joint Workshop between Security Research Labs in JAPAN and KOREA Marking Scheme for Semantic- aware Web Application Security HPC.
Web Applications Testing By Jamie Rougvie Supported by.
Saving Client State Session Tracking: Maintain state about series of requests from same client over time Using Cookies: Clients hold small amount of their.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
Li Tak Sing COMPS311F. A web page that counts the number of times that you have visited the page. You can try the page at:
Java Servlets and Java Server Pages Norman White Stern School of Business.
JSP Pages. What and Why of JSP? JSP = Java code imbedded in HTML or XML –Static portion of the page is HTML –Dynamic portion is Java Easy way to develop.
Java.sun.com/javaone/sf | 2004 JavaOne SM Conference | Session How to Attack Java™ 2 Platform, Enterprise Edition (J2EE) Applications Jeff Williams.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
Mark Dixon 1 11 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
PHP Error Handling Section :I Source: 1.
Introduction to Servlets Allen Day. Notes This is a training NOT a presentation Please ask questions Prerequisites.
CHAPTER 7 Unexpected Input. INTRODUCTION What is Unexpected Input? Something (normally user-supplied data) that is unexpected happen to an application.
Java Servlets and Java Server Pages
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the OWASP License. The OWASP.
Defending Applications Against Command Insertion Attacks Penn State Web Conference 2003 Arthur C. Jones June 18, 2003.
S ERVLETS Form Data 19-Mar-16. F ORM P ROCESSING You must have come across many situations when you need to pass some information from your browser to.
SlideSet #20: Input Validation and Cross-site Scripting Attacks (XSS) SY306 Web and Databases for Cyber Operations.
SECURE DEVELOPMENT. SEI CERT TOP 10 SECURE CODING PRACTICES Validate input Use strict compiler settings and resolve warnings Architect and design for.
CS320 Web and Internet Programming Introduction to Java Servlets Chengyu Sun California State University, Los Angeles.
Distributed Web Systems Java Servlets Lecturer Department University.
CS3220 Web and Internet Programming Introduction to Java Servlets
Web Application Vulnerabilities, Detection Mechanisms, and Defenses
Marking Scheme for Semantic-aware Web Application Security
Sessions.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Servlets Servlets are modules that extend the functionality of a “java-enabled” web-server They normally generate HTML code and web content dynamically.
Basic servlet structure
Presentation transcript:

Copyright © The OWASP Foundation Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License. The OWASP Foundation OWASP AppSec June 2004 NYC Input Validation Jeff Williams, OWASP Chair CEO, Aspect Security

OWASP AppSec It’s All Jon Postel’s Fault  “TCP implementations will follow a general principle of robustness: be conservative in what you do, be liberal in what you accept from others.” -- Jon Postel, RFC 793, Sept. 1981

OWASP AppSec “Sender Validates” Mindset  Assume that data is valid  Or only check a few pathological cases  Common problems with this approach  Buffer overflows  Forced browsing  Cookie poisoning  SQL injection  Command injection  Format string

OWASP AppSec Common Validation Approaches  Deep Packet Inspection  Web Application Firewall  Server Plugin  J2EE Filter  Validation Component  Validation Pattern in Code  Validate Everywhere Completely outside application Completely within application

OWASP AppSec Confusing Terms  Filter  Often used synonymously with “Validate,” but implies stripping out something bad.  Blacklist  Validation done against a list of known bad patterns in the input. Generally considered bad practice.  Whitelist  Validation done against a list of known good patterns in the input. Generally considered good practice.

OWASP AppSec Architecture  Needs  Nonbypassable control point  Access to the “rules”  Access to any required contextual information  Requirements  Positive security model (deny all)  Easy to maintain for developers

OWASP AppSec “Boundary Validation”  Validate at reasonable system boundaries  Between client and business logic  Between business logic and database (e.g.)  Between application and major libraries  Between major subsystems within an application  A better “principle of robustness”  Modified Postel’s Law…  “…be liberal in what you accept from others, then validate the hell out of it.”

OWASP AppSec What Are the “Rules”?  Examples:  What punctuation is allowed in a textbox?  What is the zipcode format?  What are the header rules? Cookies?  What are all the possible responses to an error?  How can we detect an attack in progress?  Extra, Missing, Duplicate, and Malformed

OWASP AppSec What “Actions” Can You Take?  log "Extra cookie detected, value = $value."  message "Extra cookie detected."  invalidate  delete  sanitize  replace "new_value"  "Extra cookie detected"  errorpage "Extra cookie detected"  redirect error.jsp?message="Extra cookie detected"  sleep 2000  shutdown

OWASP AppSec What “Severity” Applies?  Some errors are “fatal”  Almost certainly an attack  Stop validating, invalidate session (go away)  You can “continue” after some errors  Sanitize, use default, log  Continue validating  Some conditions you just want to “ignore”  Unexpected header

OWASP AppSec How to Capture a Rule JSESSIONID cookie ^[A-F0-9]{32}$ fatal invalidate log verbose "Cookie tampering detected." continue log "Cookie missing." redirect “/login”

OWASP AppSec How to Assemble a Ruleset Validation rules for the login form /login true …

OWASP AppSec How To Review Code for Validation  Trace the “taint” from all calls used to get input  HttpServletRequest.getParameter()  HttpServletRequest.getCookies()  HttpServletRequest.getHeader()  Etc…  Bad Patterns  Input -> Output == cross-site scripting  Input -> System == command injection  Input -> Query == SQL injection  Input -> Fixed buffer or format string == overflow  Input -> Integer == overflow

OWASP AppSec Validation Checklist  Is your validation centralized?  Is your validation mandatory?  Do you canonicalize before validating?  Are you validating URL params, cookies, and other headers  NOT just forms? (Struts fails this)  Do you catch extra, missing, and duplicate input?  NOT just corrupt input?  Do you have options for handling validation problems?  Can you detect an attack based on repeated failed input validation?  Is what you log different than what you show the user?  Do your requirements specify all the stuff above?  Do your requirements or detailed design docs specify all the validation rules?  Does you use HTML Entity encoding (e.g. <) on output?

OWASP AppSec Simple Audit Exercise public class HelloWorld extends HttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(" "); out.println(" Hello World "); out.println(" "); out.println("Hello, " + request.getParameter("name")); out.println(" "); }

OWASP AppSec Harder Audit Exercise public class DamagedStrutsForm extends ActionForm { public void doForm( HttpServletRequest request) { UserBean u = session.getUserBean(); u.setName(request.getParameter("name")); u.setFavoriteColor(request.getParameter("color")); } public boolean validate( HttpServletRequest request) { try { if ( request.getParameter("Name").indexOf("<script") != -1 ) { logger.log("Script detected" ); return false; } } catch( Exception e ) {} return true; }

OWASP AppSec Haystack Full of Needles  Validation is incredibly important  Difficult to get correct  Spend some time designing your approach  Consider participating in or sponsoring the OWASP Stinger project