Beware of Serialized GUI Objects Bearing Data. David Byrne Rohini Sulatycki

Similar documents
Oracle Developer Day

ASP.NET provides several mechanisms to manage state in a more powerful and easier to utilize way than classic ASP.

Security Course. WebGoat Lab sessions

JavaServer Faces Technology, AJAX, and Portlets: It s Easy if You Know How!

WEB SECURITY WORKSHOP TEXSAW Presented by Solomon Boyd and Jiayang Wang

JSF 2.0: Insight and Opinion

Welcome to the OWASP TOP 10

Provide you with a quick introduction to web application security Increase you awareness and knowledge of security in general Show you that any


CIS 4360 Secure Computer Systems XSS

Copyright

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

The security of Mozilla Firefox s Extensions. Kristjan Krips

Application Security through a Hacker s Eyes James Walden Northern Kentucky University

VIEWSTATE VULNERABILITIES TIMUR YUNUSOV, POSITIVE TECHNOLOGIES

More reading: A series about real world projects that use JavaServer Faces:

CSCE 813 Internet Security Case Study II: XSS

CS 161 Computer Security

Specialized - Mastering JEE 7 Web Application Development

John Coggeshall Copyright 2006, Zend Technologies Inc.

Web Application Security. Philippe Bogaerts

Course 834 EC-Council Certified Secure Programmer Java (ECSP)

JSF 2.0: Insight and Opinion

Attacking the Application OWASP. The OWASP Foundation. Dave Ferguson, CISSP Security Consultant FishNet Security.

Excerpts of Web Application Security focusing on Data Validation. adapted for F.I.S.T. 2004, Frankfurt

Computer Forensics: Investigating Network Intrusions and Cyber Crime, 2nd Edition. Chapter 3 Investigating Web Attacks

Ethical Hacking and Countermeasures: Web Applications, Second Edition. Chapter 3 Web Application Vulnerabilities

Web insecurity Security strategies General security Listing of server-side risks Language specific security. Web Security.

C1: Define Security Requirements

Attacks Against Websites. Tom Chothia Computer Security, Lecture 11

What's New in the Servlet and JavaServer Pages Technologies?

P2_L12 Web Security Page 1

Fast Track to Java EE

Web Application Attacks

Web Security. Jace Baker, Nick Ramos, Hugo Espiritu, Andrew Le

1 About Web Security. What is application security? So what can happen? see [?]

Featuring. and. Göteborg. Ulf Larson Thursday, October 24, 13

OWASP Top 10 Risks. Many thanks to Dave Wichers & OWASP

Web Application Security

Introduction to Ethical Hacking


Application vulnerabilities and defences

Computer Security 3e. Dieter Gollmann. Chapter 18: 1

Lecture Overview. IN5290 Ethical Hacking

Lecture 6: Web hacking 2, Cross Site Scripting (XSS), Cross Site Request Forgery (CSRF), Session related attacks

Security: Threats and Countermeasures. Stanley Tan Academic Program Manager Microsoft Singapore

Exam Questions 1Z0-419

Web Application with AJAX. Kateb, Faris; Ahmed, Mohammed; Alzahrani, Omar. University of Colorado, Colorado Springs

Is Browsing Safe? Web Browser Security. Subverting the Browser. Browser Security Model. XSS / Script Injection. 1. XSS / Script Injection

Sichere Software vom Java-Entwickler

W e b A p p l i c a t i o n S e c u r i t y : T h e D e v i l i s i n t h e D e t a i l s

OWASP Top 10 The Ten Most Critical Web Application Security Risks

WebGoat Lab session overview

Security and Privacy. SWE 432, Fall 2016 Design and Implementation of Software for the Web

MVC :: Preventing JavaScript Injection Attacks. What is a JavaScript Injection Attack?

Secure Frame Communication in Browsers Review

Table of Contents. Introduction... xxi

SAP Security. BIZEC APP/11 Version 2.0 BIZEC TEC/11 Version 2.0

Application Layer Attacks. Application Layer Attacks. Application Layer. Application Layer. Internet Protocols. Application Layer.

Exploiting and Defending: Common Web Application Vulnerabilities

Chapter 6 Enterprise Java Beans

Information Security CS 526 Topic 11

Attacks Against Websites 3 The OWASP Top 10. Tom Chothia Computer Security, Lecture 14

OWASP TOP Release. Andy Willingham June 12, 2018 OWASP Cincinnati

Naresh Information Technologies

e-commerce Study Guide Test 2. Security Chapter 10

epldt Web Builder Security March 2017

Your Turn to Hack the OWASP Top 10!

shortcut Tap into learning NOW! Visit for a complete list of Short Cuts. Your Short Cut to Knowledge

For this week, I recommend studying Chapter 2 of "Beginning Java EE 7".

sessionx Desarrollo de Aplicaciones en Red EL (2) EL (1) Implicit objects in EL Literals José Rafael Rojano Cáceres

Information Security. Gabriel Lawrence Director, IT Security UCSD

Distributed Multitiered Application

Application Security Introduction. Tara Gu IBM Product Security Incident Response Team

jk0-022 Exam Questions Demo CompTIA Exam Questions jk0-022

Combating Common Web App Authentication Threats

MTAT Research Seminar in Cryptography The Security of Mozilla Firefox s Extensions

DESIGN AND IMPLEMENTATION OF SAGE DISPLAY CONTROLLER PROJECT

Client Side Injection on Web Applications

Security context. Technology. Solution highlights

ASP.NET State Management Techniques

Advanced Web Technology 10) XSS, CSRF and SQL Injection

Web Application Penetration Testing

Java- EE Web Application Development with Enterprise JavaBeans and Web Services

RKN 2015 Application Layer Short Summary

Why was an extra step of choosing a Security Image added to the sign-in process?

WEB SECURITY: XSS & CSRF

CS 142 Winter Session Management. Dan Boneh

Security Engineering by Ross Andersson Chapter 18. API Security. Presented by: Uri Ariel Nepomniashchy 31/05/2016

Finding Vulnerabilities in Web Applications

Building Web Applications With The Struts Framework

Web Security II. Slides from M. Hicks, University of Maryland

EasyCrypt passes an independent security audit

WELCOME. APEX Security Primer. About Enkitec. About the Presenter. ! Oracle Platinum Partner! Established in 2004

RIA Security - Broken By Design. Joonas Lehtinen IT Mill - CEO

CNIT 129S: Securing Web Applications. Ch 12: Attacking Users: Cross-Site Scripting (XSS) Part 2

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

Fortify Software Security Content 2017 Update 4 December 15, 2017

Web basics: HTTP cookies

Session 21. Expression Languages. Reading. Java EE 7 Chapter 9 in the Tutorial. Session 21 Expression Languages 11/7/ Robert Kelly,

Transcription:

Beware of Serialized GUI Objects Bearing Data David Byrne Rohini Sulatycki

Schedule Definitions Is this an 0-day? Poor vendor documentation MyFaces demo & code explanation ASP.Net demo & code explanation Recommendations

Definitions: View State Post-back: a request send to the server with the response sent back to the requesting page Select US from country drop down Trigger post-back to populate state drop down A mechanism used by some web application frameworks to preserve the state of a web page s HTML GUI controls across post-backs. JSF: Tree like structure of the UI component hierarchy State for each component.net Changes to control properties

Definitions: View State Tampering Malicious data embedded in client-side view states Server renders attacker s data in its response Data can be client-side code (XSS) or limited server-side code

Affected Web Application Frameworks JavaServer Faces Apache MyFaces 1.2.8 1.1.7 Sun Mojarra 1.2_14 2.0.2 Microsoft ASP.Net 3.5

Is this an 0-day? Specific attacks never documented before Prevented by existing configuration options WEP (wireless encryption) Introduced in 1997 with known weaknesses, but not attacks In 2001, specific attacks were proposed Late in 2001, AirSnort was released WEP is still available on access points today Solution is to configure access points to use WPA

No Advice From Sun http://192.9.76.37/wiki.jsp?page=javaserverfacesri How can I secure view state when using client side state saving? By default, view state will not be encrypted. However, there is a way to do this within Mojarra. Specify a environment entry like so: <env-entry> <env-entry-name>com.sun.faces.clientstatesavingpassword</env-entry-name> <env-entry-type>java.lang.string</env-entry-type> <env-entry-value>[some VALUE]</env-entry-value> </env-entry> The presence of this JNDI entry will cause the state to be encrypted using the specified password. We realize this isn't the most secure way of conveying a password, however, this cannot be accessed easily without having code executed on the server side.

Mostly Bad Apache Recommendation http://wiki.apache.org/myfaces/secure_your_application One consequence of client side state saving is that anyone with a decoder and some time to kill can reconstruct the UI object model on the client side. This can be a problem for those of us who make use of the excellent t:savestate tag. Enabling encryption is as easy as putting the following context parameter in your deployment descriptor. There are two things to note here. First, this uses the default encryption algorithm, DES, so the secret must have a size of eight. Second, although the secret is actually "76543210", we do not put this directly in the deployment descriptor. Instead, we place it's base 64 encoded value. This annoying extra step in the process is required so that secrets are not limited to printable character values.

Bad Microsoft Recommendations http://msdn.microsoft.com/en-us/library/ms691344.aspx http://msdn.microsoft.com/en-us/library/ system.web.configuration.pagessection.enableviewstatemac.aspx http://msdn.microsoft.com/en-us/library/ydy4x04a.aspx EnableViewStateMac A read/write Boolean value. true if ASP.NET should run a message authentication check on the page's view state when the page is posted back from the client; otherwise, false. The default is true. Note: Do not set this property to true if performance is a key consideration.

Good, But Ambiguous Microsoft Recommendations http://msdn.microsoft.com/en-us/library/bb386448.aspx http://msdn.microsoft.com/en-us/library/ms998288.aspx Securing View State By default, view state data is stored in the page in a hidden field and is encoded using base64 encoding. In addition, a hash of the view state data is created from the data by using a machine authentication code (MAC) key. The hash value is added to the encoded view state data and the resulting string is stored in the page. When the page is posted back to the server, the ASP.NET page framework re-computes the hash value and compares it with the value stored in view state. If the hash values do not match, an exception is raised that indicates that view state data might be invalid. By creating a hash value, the ASP.NET page framework can test whether the view state data has been corrupted or tampered with. However, even if it is not tampered with, view state data can still be intercepted and read by malicious users.

Someone at Microsoft Understands http://support.microsoft.com/kb/829743 If you turn the view state MAC feature off, and then you use view state for controls that do not HTML encode (for example, a Label control), attackers can tamper with the view state data and can put arbitrary data in view state. This arbitrary data is decoded and then used by controls when they render the posted page. As a result, attackers can inject script into the application unless you work to prevent the attack. For example, an attacker could decode the data, inject script into the data where a Label control is, and then link to it from a Web site. Anyone who clicks on the link would be the victim of a script injection attack that could potentially steal their authentication cookies or session id. The script could also let an attacker alter state data for controls that use view state and application specific attacks could occur as a result.

Introduction to JavaServer Faces Aids in development of web-based GUIs Java EE Standard Sun Mojarra is the official Java EE reference implementation Apache MyFaces is another popular implementation Built on JavaServer Pages, typically runs on Tomcat Standards process started in 2001 with first release in 2004 No code base in common between the Sun & Apache products

JSF Request/Response Lifecycle 1. Restore View Initial Browser Request Create empty view Go to ProcessResponse Browser Post-back Restore view from state Restored component tree 2. Apply Request Value Traverse component tree Invoke decode() on each component Get component values from request Validate values Queue errors

JSF Request/Response Lifecycle Cont d 3. Update Model Traverse component tree Update server-side model properties 4. Invoke Application Events Handle code specific to the application 5. Process Response Initial Request Delegate to JSP container Add components form page to component tree

JSF Request/Response Lifecycle Cont d 6. Create View State Serialize component tree and encode 7. Generate web page

JSF State Saving Methods Location where view state information is saved Client Entire serialized view state rendered in HTML markup e.g. hidden field Performance issues with large view states Server Serialized view stored in session Unique key sent to client to identify view Issues with clustered environments

JSP Expression Language (EL) Part of the JavaServer Pages (JSP) standard EL allows a page author to access server side data stored in Java Beans #{name.property} Provides access to Implicit Objects #{sessionscope} #{applicationscope} #{requestscope}

Deface Tool Java-based Decodes view state into text object view Generic Java object steam decoding Converts view states into attacks: XSS Session & application objects Thanks to Jon Rose s DeBlaze for naming inspriation

Demo Overview Environment Running latest versions of all software: Apache Tomcat 6.0.24 Apache MyFaces 1.2.8 Web application Credit card form Submits to a thank you page Puts credit card number and security code in session Security code (CVV) should not be permanently persisted and a common place to put is in the session

Deface Demo

JSF View State Tree Structure object: ARRAY (java.lang.object[3]) (#19739141): [0]: (org.apache.myfaces.application.treestructuremanager.treestructcomponent) field "_componentclass": 'javax.faces.component.uiviewroot' (String) field "_componentid": 'j_id_jsp_1379279123_0' (String) field "_children": ARRAY (org.apache.myfaces.application.treestructuremanager $TreeStructComponent[2]): [0]: (org.apache.myfaces.application.treestructuremanager.treestructcomponent) field "_componentclass": 'javax.faces.component.html.htmloutputtext' field "_componentid": 'j_id_jsp_1379279123_2' (String) [1]: (org.apache.myfaces.application.treestructuremanager.treestructcomponent) field "_componentclass": 'javax.faces.component.html.htmlform' (String) field "_componentid": 'form2' (String) field "_children": ARRAY (org.apache.myfaces.application.treestructuremanager $TreeStructComponent[1]):

JSF View State Restore private UIComponent internalrestoretreestructure(treestructcomponent treestructcomp) { String compclass = treestructcomp.getcomponentclass(); String compid = treestructcomp.getcomponentid(); UIComponent component = (UIComponent)ClassUtils.newInstance(compClass); component.setid(compid); TreeStructComponent[] childarray = treestructcomp.getchildren(); if (childarray!= null) { List<UIComponent> childlist = component.getchildren(); for (int i = 0, len = childarray.length; i < len; i++) { UIComponent child = internalrestoretreestructure(childarray[i]); childlist.add(child); } } Object[] facetarray = treestructcomp.getfacets(); if (facetarray!= null) { Map<String, UIComponent> facetmap = component.getfacets(); for (int i = 0, len = facetarray.length; i < len; i++) { Object[] tuple = (Object[])facetArray[i]; String facetname = (String)tuple[0]; TreeStructComponent structchild = (TreeStructComponent)tuple[1]; UIComponent child = internalrestoretreestructure(structchild); facetmap.put(facetname, child); } } } return component;

ASP.NET View State Lifecycle View state is utilized when a control's state are modified programmatically 1. Initial Browser Request Class auto generated Create page control hierarchy programmatically 2. Post-back Load view state Populate page control hierarchy with view state data Validate for tampering etc

ASP.NET View State Lifecycle Cont d 3. Load post-back data Obtain data from request Check if corresponding control in hierarchy implements ipostbackdatahandler interface? Pass value to server control to update state 4. Fire Page Load event

ASP.NET View State Lifecycle Cont d 5. Save View State Recursively call control hierarchy SaveViewState() Construct Page ViewState Serialize to Base64 encoded string Placed in a hidden field VIEWSTATE 6. Generate Web Page

ASP.Net Demo Environment Windows Server 2008 R2 ASP.Net 3.5 All current patches <%@ Page EnableViewStateMac="False" ValidateRequest="True" %> <html runat="server"> <form runat="server"/> </html>

ASP.Net Demo

What can be done with this? Framework exploits XSS Steal session and application data from JSF Developer mistakes SQL injection Authentication bypass Authorization bypass Anything really Attack scenarios Phishing attacks XSS shipping session variables to other web servers Changes to data grid

Recommendations Always, always, always secure the view state Move the view state to the server whenever possible Performance benefits Server farm environments Documentation changes by vendors We don t make up best-practices for fun

Automated vs. Manual Complex vulnerabilities require manual testing Automated tools only find known flaws Automated vs. Manual: You can t filter The Stupid

Links Deface tool & demo environment https://www.trustwave.com/spiderlabs-tools.php Apache MyFaces security http://wiki.apache.org/myfaces/secure_your_application Sun Mojarro security http://192.9.76.37/wiki.jsp?page=javaserverfacesri ASP.Net view state security http://msdn.microsoft.com/en-us/library/ms178199(vs.85).aspx ViewStateHacker http://www.woany.co.uk/viewstatehacker/.net Reflector http://www.red-gate.com/products/reflector/

Questions