Exploiting WebSphere Application Server's JSP Engine

Defcon 18

Ed Schaller

Outline

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Outline: WAS Architecture

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: WAS Architecture WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

WebSphere Application Server (WAS)

  • IBM's flagship JEE Application Server1
  • One of the most popular commercial JEE Application Servers 2
  • Heavily used in the financial and insurance sectors
  • Not cheap
    • Time bombed free trial available from web site1
WebSphere Application Server (WAS) IBM's flagship JEE Application Server One of the most popular commercial JEE Application Servers Heavily used in the financial and insurance sectors Not cheap Time bombed free trial available from web site

Common Network Architecture

  • Web servers forward HTTP connections into WAS
  • HTTP connection forwarding handled by WAS Web Server Plugin
Common Network Architecture Web servers forward HTTP connections into WAS HTTP connection forwarding handled by WAS Web Server Plugin

Common Network Architecture (IBM)

3
  • Plug-in is between the Internet and WAS
  • WAS can access many back end resources
    • A vulnerability in a web application or the web container leaves little protection
Common Network Architecture (IBM) Plug-in is between the Internet and WAS WAS can access many back end resources A vulnerability in a web application or the web container leaves little protection

Web server plugin

  • Extension module for web servers
    • Apache
    • IBM HTTP Server (IHS, Apache derivative)
    • IIS
    • ...
Web server plugin Extension module for web servers Apache IBM HTTP Server (IHS, Apache derivative) IIS ...

Web server plugin (continued)

  • Communicates with WAS via HTTP
  • Load balancing
  • Fail over
  • Not security
Web server plugin (continued) Communicates with WAS via HTTP Load balancing Fail over Not security

Plugin URL Handling

  • Not all requests forwarded to WAS
  • Configuration based on URL mappings in web.xml and ibm-web-ext.xmi
    • Simple file globs
  • Matched in sequence
    1. /ctxroot/myservlet
    2. /ctxroot/servlet_with_pathinfo/*
    3. *.jsp
    4. If file serving is enabled: *
Plugin URL Handling Not all requests forwarded to WAS Configuration based on URL mappings in web.xml and ibm-web-ext.xmi Simple file globs Matched in sequence /ctxroot/myservlet /ctxroot/servlet_with_pathinfo/* *.jsp If file serving is enabled: *

Plugin URL Handling (continued)

  • If a match occurs, the connection is forwarded to WAS
  • Otherwise the request is handled by web server
    • Used to serve static content from the web server instead of WAS for optimization.
  • The plugin's URL handling is frequently misunderstood by admins and developers
  • See "Understanding the WebSphere Application Server Web server plug-in"4 for more details.
Plugin URL Handling (continued) If a match occurs, the connection is forwarded to WAS Otherwise the request is handled by web server Used to serve static content from the web server instead of WAS for optimization. The plugin's URL handling is frequently misunderstood by admins and developers See "Understanding the WebSphere Application Server Web server plug-in" for more details.

Outline: JSP & NUL

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: JSP & NUL WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Architecture: WAS

Architecture: WAS

Strings

  • OS under Java written in C
    • NUL terminates string
    • Cannot contain NUL
  • Java
    • Counted
    • NUL allowed in string
  • What happens if you open the filetest.txt\0 in java?
  • You gettest.txt7
Strings OS under Java written in C NUL terminates string Cannot contain NUL Java Counted NUL allowed in string What happens if you open the filetest.txt\0 in java? You gettest.txt

JSP Handling and NUL

  1. Locate and read file
  2. Translate .jsp to .java
  3. Compile
  4. Run as servlet
  • What happens in WAS if we request/ctxroot/test.txt%00.jsp
  • It compiles test.txt as a JSP and runs it.
  • Similar to what Jouko Pynnönen found in Tomcat8
JSP Handling and NUL Locate and read file Translate .jsp to .java Compile Run as servlet What happens in WAS if we request/ctxroot/test.txt%00.jsp It compiles test.txt as a JSP and runs it. Similar to what Jouko Pynnönen found in Tomcat

Reading files through the JSP engine

  • /ctxroot/path_to_file%00.jsp
  • The file must be in the WAR
  • We can't read files in META-INF or WEB-INF
  • Must compile and run as a JSP
  • Not too useful unless "file serving" is disabled in the application
Reading files through the JSP engine /ctxroot/path_to_file%00.jsp The file must be in the WAR We can't read files in META-INF or WEB-INF Must compile and run as a JSP Not too useful unless "file serving" is disabled in the application

What's a Valid JSP?

  • Basically anything that doesn't include<%
  • HTML
  • XML
  • Most text files
  • Some ZIP files
  • Most CLASS files
  • ...
What's a Valid JSP? Basically anything that doesn't include<% HTML XML Most text files Some ZIP files Most CLASS files ...

Directories

  • What about directories?
  • For some reason, accessing directories in this manner gets a directory listing.
    • I'm not sure why...
  • /ctxroot/dir/%00.jsp
  • In some cases, like the context root, a '.' is needed as well
  • /ctxroot/.%00.jsp
  • '..' can can even list the EAR directory
  • /ctxroot/..%00.jsp
  • JSP & NUL just became much more useful
Directories What about directories? For some reason, accessing directories in this manner gets a directory listing. I'm not sure why... /ctxroot/dir/%00.jsp In some cases, like the context root, a '.' is needed as well /ctxroot/.%00.jsp '..' can can even list the EAR directory /ctxroot/..%00.jsp JSP & NUL just became much more useful

Outline: Web Server Plugin & NUL

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: Web Server Plugin & NUL WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Architecture: Plugin

  • Though not intended for security
  • It can interfere with insecurity
Architecture: Plugin Though not intended for security It can interfere with insecurity

Web Server Plugin & NUL

  • %00works great connecting to WAS directly
  • Plugin poses an issue
  • Written in C
    • Doesn't like NUL
  • /ctxroot/test.txt%00.jsp
  • Becomes/ctxroot/test.txt
  • How do we get NUL past the plugin?
Web Server Plugin & NUL %00works great connecting to WAS directly Plugin poses an issue Written in C Doesn't like NUL /ctxroot/test.txt%00.jsp Becomes/ctxroot/test.txt How do we get NUL past the plugin?

Character Encodings

  • ASCII/ISO-8859-1/ISO-LATIN-1
    • Single byte
    • 0-255 or -128-127
    • Standard C
  • UCS-16/UTF-16
    • Two bytes
    • 0-65,535
    • Java in memory
  • UTF-8
    • 1-4 bytes
    • 0-1,114,111
    • Java reading and writing
Character Encodings ASCII/ISO-8859-1/ISO-LATIN-1 Single byte 0-255 or -128-127 Standard C UCS-16/UTF-16 Two bytes 0-65,535 Java in memory UTF-8 1-4 bytes 0-1,114,111 Java reading and writing

UTF-8 Revisited

  • Multi byte encoding
  • Single byte values can be encoded as multiple bytes
  • Explicitly forbidden by the spec 9
    • Who follows specs?
  • Quite a history of those that don't
    • MS IIS exploits 11
    • Java
UTF-8 Revisited Multi byte encoding Single byte values can be encoded as multiple bytes Explicitly forbidden by the spec Who follows specs? Quite a history of those that don't MS IIS exploits Java

Java's Decoding of Overly Long UTF-8

  • Made known publicly by Simon Ryeo and William A. Rowe, Jr.12
  • Fixed by Sun in 1.4.2 update 19, 5.0 update 13 and 6 update 11 (bug id 4486841)
  • Fixed by IBM 1.4.2 SR13, 5.0 SR9 and 6 SR4
  • IBM's fix didn't work
    • IBM fixed NIO but IBM's JVM doesn't use NIO by default
    • Testing security fixes is a good idea...
  • Really fixed in 1.4.2 SR 13 FP5, 5 SR11 FP2 and 6 SR8
  • Not yet in any WAS Fix Packs though
Java's Decoding of Overly Long UTF-8 Made known publicly by Simon Ryeo and William A. Rowe, Jr. Fixed by Sun in 1.4.2 update 19, 5.0 update 13 and 6 update 11 (bug id 4486841) Fixed by IBM 1.4.2 SR13, 5.0 SR9 and 6 SR4 IBM's fix didn't work IBM fixed NIO but IBM's JVM doesn't use NIO by default Testing security fixes is a good idea... Really fixed in 1.4.2 SR 13 FP5, 5 SR11 FP2 and 6 SR8 Not yet in any WAS Fix Packs though

UTF-8 and the Web Server Plugin

  • The plugin is in C and doesn't understand UTF-8 (overly long or otherwise)
    • Just ASCII/ISO-8859-1/ISO-LATIN-1
  • WAS is in Java using a JVM that accepts overly long UTF-8
  • Instead of /ctxroot/test.txt%00.jsp
  • Use /ctxroot/test.txt%C0%80.jsp
  • The plugin is no longer an obstacle
UTF-8 and the Web Server Plugin The plugin is in C and doesn't understand UTF-8 (overly long or otherwise) Just ASCII/ISO-8859-1/ISO-LATIN-1 WAS is in Java using a JVM that accepts overly long UTF-8 Instead of /ctxroot/test.txt%00.jsp Use /ctxroot/test.txt%C0%80.jsp The plugin is no longer an obstacle

Outline: WEB-INF & META-INF

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: WEB-INF & META-INF WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Architecture: WAS

Architecture: WAS

WEB-INF & META-INF

  • Servlet specification says
    • Return 4045
  • Checked many places in WAS
  • They missed one
  • File serving allowed /ctxroot/./WEB-INF/web.xml
    • Fixed in PK64302
    • "Potential security exposure with fileServing feature enabled."15
    • No details so other issues may have been fixed
  • Surely they didn't just check file serving...
WEB-INF & META-INF Servlet specification says Return 404 Checked many places in WAS They missed one File serving allowed /ctxroot/./WEB-INF/web.xml Fixed in PK64302 "Potential security exposure with fileServing feature enabled." No details so other issues may have been fixed Surely they didn't just check file serving...

/WEB-INF/ via JSP

  • Directly: /ctxroot/./WEB-INF/web.xml%00.jsp
  • The plugin also normalizes paths
    • /./ becomes /
  • Via plugin: /ctxroot/%C0%AE/WEB-INF/web.xml%C0%80.jsp
  • Fixed with the %00.jsp issue in PK8138713
  • "Possible application source file exposure"
  • Also works with META-INF
/WEB-INF/ via JSP Directly: /ctxroot/./WEB-INF/web.xml%00.jsp The plugin also normalizes paths /./ becomes / Via plugin: /ctxroot/%C0%AE/WEB-INF/web.xml%C0%80.jsp Fixed with the %00.jsp issue in PK81387 "Possible application source file exposure" Also works with META-INF

Outline: Apache Axis 1 & Attachments

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: Apache Axis 1 & Attachments WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

The Whole Truth?

  • The truth, the whole truth and nothing but the truth?
  • "Possible application source file exposure" can be arbitrary remote code execution...
The Whole Truth? The truth, the whole truth and nothing but the truth? "Possible application source file exposure" can be arbitrary remote code execution...

Architecture: WAS

Architecture: WAS

JSP Strikes Back

  1. Locate and read file
  2. Translate.jsp to.java
  3. Compile
  4. Run as servlet
  • We need to get a file into the exploded WAR
JSP Strikes Back Locate and read file Translate.jsp to.java Compile Run as servlet We need to get a file into the exploded WAR

Tid Bits

  • /ctxroot/%C0%AE/WEB-INF/%C0%80.jsp

  • What's theattachments directory?
Tid Bits /ctxroot/%C0%AE/WEB-INF/%C0%80.jsp What's theattachments directory?

Apache Axis 1

  • SOAP with attachments16
    • SOAP attachments implemented as multi part MIME
  • Caches attachments larger than 32KB to disk
  • /WEB-INF/attachments by default
  • Directory is created if not present at startup
  • Guess what WAS's JAX-RPC is based on...
    • Not to be confused with WAS's JAX-WS which is based on Apache Axis 2
Apache Axis 1 SOAP with attachments SOAP attachments implemented as multi part MIME Caches attachments larger than 32KB to disk /WEB-INF/attachments by default Directory is created if not present at startup Guess what WAS's JAX-RPC is based on... Not to be confused with WAS's JAX-WS which is based on Apache Axis 2

Axis & Attachments

  • Axis bugs me
  • Attachments aren't even read unless referenced by the service
  • So we could get an attachment there if a SOAP service handles attachments
    • Not many do.
  • Can we put a attachment before the SOAP body and force it to be read?
    • Yup...but...
    • Axis has a bug: attachments before the body are saved to java.io.tmpdir instead.
    • So you can DOS two filesystems instead of just one.
Axis & Attachments Axis bugs me Attachments aren't even read unless referenced by the service So we could get an attachment there if a SOAP service handles attachments Not many do. Can we put a attachment before the SOAP body and force it to be read? Yup...but... Axis has a bug: attachments before the body are saved to java.io.tmpdir instead. So you can DOS two filesystems instead of just one.

SOAP Encoding

  • Allows an href attribute that can reference attachments
  • When used with Axis 1, Axis parses the attachments...
    • And caches large ones to disk
  • Requires the application to have a web service with at least one parameter that uses SOAP encoding (RPC/encoded)
    • Can't be document/literal or RPC/literal
SOAP Encoding Allows an href attribute that can reference attachments When used with Axis 1, Axis parses the attachments... And caches large ones to disk Requires the application to have a web service with at least one parameter that uses SOAP encoding (RPC/encoded) Can't be document/literal or RPC/literal

SOAP Faults

  • It's not my fault!
  • Axis 1 provides an interesting ...err... feature
    • It's not present in the WAS's JAX-RPC derivative.
  • The client can send a fault to the server as the first request
    • Server responds with an error since the client shouldn't be sending faults
    • After it parses it...
  • Faults use SOAP encoding
    • So we can send attachments with them...
  • Does not require any web services to be configured
    • Exposure of the Axis 1 servlet is enough.
SOAP Faults It's not my fault! Axis 1 provides an interesting ...err... feature It's not present in the WAS's JAX-RPC derivative. The client can send a fault to the server as the first request Server responds with an error since the client shouldn't be sending faults After it parses it... Faults use SOAP encoding So we can send attachments with them... Does not require any web services to be configured Exposure of the Axis 1 servlet is enough.

Outline: Demo

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: Demo WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Putting it all together

  • Attachment filenames are random
    1. Get the attachment's directory listing first
    2. Send up your attachment
    3. Get the new directory listing and find your file
  • Request your file as a JSP
  • Your file is translated to java
  • Compiled
  • Run
Putting it all together Attachment filenames are random Get the attachment's directory listing first Send up your attachment Get the new directory listing and find your file Request your file as a JSP Your file is translated to java Compiled Run

Shell Over JSP

  1. Baselines the attachments directory
  2. Uploads trojan JSP with a SOAP fault
  3. Finds new attachments in the attachments directory
  4. Checks each until it finds the trojan JSP
  5. JSP copies itself to a non-transient location
    • Attachments are purged after use
  6. Proxies stdin and stdout to a arbitrary command over HTTP
  7. Removes trojan JSP when done
Shell Over JSP Baselines the attachments directory Uploads trojan JSP with a SOAP fault Finds new attachments in the attachments directory Checks each until it finds the trojan JSP JSP copies itself to a non-transient location Attachments are purged after use Proxies stdin and stdout to a arbitrary command over HTTP Removes trojan JSP when done

Demo: Shell Over JSP

Demo: Shell Over JSP

Outline: Demo

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: Demo WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Affected Platforms

  • WAS runs on many different platforms
  • AIX and Linux tested and vulnerable
  • Case insensitive file systems are not vulnerable to %00.jsp
    • An earlier security fix is likely the reason
    • Windows
  • Overly long UTF-8 decoding depends on the JVM in use
    • Non-IBM JVM may have been fixed earlier
    • HPUX & Solaris
Affected Platforms WAS runs on many different platforms AIX and Linux tested and vulnerable Case insensitive file systems are not vulnerable to %00.jsp An earlier security fix is likely the reason Windows Overly long UTF-8 decoding depends on the JVM in use Non-IBM JVM may have been fixed earlier HPUX & Solaris

Fixed Versions

  • WAS 6.0
    • 6.0.2.35
    • Fix Pack 35
  • WAS 6.1
    • 6.1.0.23
    • Fix Pack 23
  • WAS 7.0
    • 7.0.0.3
    • Fix Pack 3
  • Other versions with the IFix for PK81387
Fixed Versions WAS 6.0 6.0.2.35 Fix Pack 35 WAS 6.1 6.1.0.23 Fix Pack 23 WAS 7.0 7.0.0.3 Fix Pack 3 Other versions with the IFix for PK81387

IBM's Response

  • 15 platform variants x 4 maintained versions = 60 different variants
    • I may be off a bit here
    • On the low end
  • The time from disclosure to publicly released fix:
    • 2 Weeks
    • I'm impressed!
  • When reporting security issues to IBM
    • If possible
    • Always do it as a support request (PMR)
IBM's Response 15 platform variants x 4 maintained versions = 60 different variants I may be off a bit here On the low end The time from disclosure to publicly released fix: 2 Weeks I'm impressed! When reporting security issues to IBM If possible Always do it as a support request (PMR)

IBM's Fix

  • Checks that the path it thinks it's opening is the same as the path it's really opening.
  • Something like
    File jsp;
    
    if(!jsp.getAbsoluteFile().equals(
    	jsp.getCanonicalFile()))
    	throw new HTTP404();
    
  • Make sure /WEB-INF/ doesn't appear anywhere in the path.
    • Not as elegant
    • But works
IBM's Fix Checks that the path it thinks it's opening is the same as the path it's really opening. Something like File jsp; if(!jsp.getAbsoluteFile().equals( jsp.getCanonicalFile())) throw new HTTP404(); Make sure /WEB-INF/ doesn't appear anywhere in the path. Not as elegant But works

Outline: Extras

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: Extras WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

Workarounds

  • First:
    • You're more than a year behind on fixes!
    • I sure hope you're not running IIS as well...
  • Disable runtime compilation and reloading of JSPs
    • See info center for disableJspRuntimeCompilation in the application
    • disableJspRuntimeCompilation seems to no longer be supported at the container level.
    • Precompile JSPs at or before deployment time
  • Block access to *.jsp before WAS
    • Direct access to JSPs will not be possible
    • Perhaps your JSPs are only used for MVC view though
    • Blocking rules must consider more issues...
Workarounds First: You're more than a year behind on fixes! I sure hope you're not running IIS as well... Disable runtime compilation and reloading of JSPs See info center for disableJspRuntimeCompilation in the application disableJspRuntimeCompilation seems to no longer be supported at the container level. Precompile JSPs at or before deployment time Block access to *.jsp before WAS Direct access to JSPs will not be possible Perhaps your JSPs are only used for MVC view though Blocking rules must consider more issues...

Handling of invalid UTF-8

  • What do the following byte sequences have in common?
    • 80 - C1 BF
    • E0 80 80 - E0 9F BF
    • F0 80 80 80 - F0 8F BF BF
  • Invalid byte sequences for UTF-8
  • How does the fixed IBM JVM handle them?
    • ""
    • AKA: the empty string
  • The unfixed IBM JVM only does this for 80 - FF
  • Useful?
    • IDS evasion
    • Bypassing blocking rules
    • If overly long wasn't enough...
Handling of invalid UTF-8 What do the following byte sequences have in common? 80 - C1 BF E0 80 80 - E0 9F BF F0 80 80 80 - F0 8F BF BF Invalid byte sequences for UTF-8 How does the fixed IBM JVM handle them? "" AKA: the empty string The unfixed IBM JVM only does this for 80 - FF Useful? IDS evasion Bypassing blocking rules If overly long wasn't enough...

JSP Extensions

  • The JSP engine handles more than *.jsp by default:
    • *.jsv
    • *.jsw
  • In some cases:
    • *.jspx
JSP Extensions The JSP engine handles more than *.jsp by default: *.jsv *.jsw In some cases: *.jspx

Blocking JSPs

  • JSP blocking rules must handle
    • UTF-8 overly long decoding
    • UTF-8 invalid code replacement with empty string
    • Multiple JSP extensions
  • I would recommend the patch....
Blocking JSPs JSP blocking rules must handle UTF-8 overly long decoding UTF-8 invalid code replacement with empty string Multiple JSP extensions I would recommend the patch....

A Note on Browsers

  • Browsers normalize URLs before sending requests
    • /./ becomes /
  • URL encoding usually resolves this
    • Except firefox on windows
    • /%2E/ becomes /
A Note on Browsers Browsers normalize URLs before sending requests /./ becomes / URL encoding usually resolves this Except firefox on windows /%2E/ becomes /

A Note on Plugin Load Balancing

  • You need to hit the same server for each request
  • Server affinity is handled by the servlet session
    • Eg:JSESSION cookie
  • JSPs default to creating a session if one does not exist
    • Getting a baseline on the attachments directory will create a session
    • Keep your cookie
A Note on Plugin Load Balancing You need to hit the same server for each request Server affinity is handled by the servlet session Eg:JSESSION cookie JSPs default to creating a session if one does not exist Getting a baseline on the attachments directory will create a session Keep your cookie

On the Defcon CD

  • One text file with
    • A URL to a website
  • Sorry...
    • I missed the deadline for the CD
On the Defcon CD One text file with A URL to a website Sorry... I missed the deadline for the CD

On the Web site

  • http://www.darkmist.net/~schallee/defcon18/
  • Slides
  • Tool to view unicode mappings for your JVM
  • Sample application for WAS with both Axis 1 and Web Services for J2EE
  • Exploit for Axis 1 faults
  • Source to all of the above
On the Web site http://www.darkmist.net/~schallee/defcon18/ Slides Tool to view unicode mappings for your JVM Sample application for WAS with both Axis 1 and Web Services for J2EE Exploit for Axis 1 faults Source to all of the above

Outline: Conclusions

  • WebSphere Application Server (WAS) Architecture
  • JSP & NUL
  • Web Server Plugin & NUL
  • WEB-INF & META-INF
  • Apache Axis 1 & Attachments
  • Demo
  • Fixes
  • Extras
  • Conclusions
Outline: Conclusions WebSphere Application Server (WAS) Architecture JSP & NUL Web Server Plugin & NUL WEB-INF & META-INF Apache Axis 1 & Attachments Demo Fixes Extras Conclusions

In Conclusion

  • Implementation variations at software component boundaries are a fertile ground for bugs.
    • Plugin <=> Java <=> OS
  • Native applications are not the only one susceptible to such issues.
    • Java is not immune
  • A series of small security issues can sometimes be used in concert to create a much bigger vulnerability.
    • encoding issues + null bytes + axis 1 => remote code execution
In Conclusion Implementation variations at software component boundaries are a fertile ground for bugs. Plugin <=> Java <=> OS Native applications are not the only one susceptible to such issues. Java is not immune A series of small security issues can sometimes be used in concert to create a much bigger vulnerability. encoding issues + null bytes + axis 1 => remote code execution

Questions?

Questions?

Bibliography

Switch to "handout" mode for bibliography.

Bibliography
[1] WebSphere Application Server web site
url: http://www-01.ibm.com/software/webservers/appserv/was/
date: 5 July 2010
[2] Magic Quadrant for Enterprise Application Servers
author: Yefim V. Natis, Massimo Pezzini, Kimihiko Iijima
publisher: Gartner RAS Core Research Note G00170610
date: 24 September 2009
note: You can get a free copy of this at https://inquiries.redhat.com/go/redhat/gartner.
[3] WebSphere Application Server: Security presentation series
author: Keys Botzum
date: 22 Nov 2006
publisher: IBM
url: http://www.ibm.com/developerworks/websphere/library/techarticles/0409_botzum/0409_botzum.html
[4] Understanding the WebSphere Application Server Web server plug-in
author: Sharad Cocasse & Makarand Kulkarni
date: 21 Oct 2003
publisher: IBM
url: http://www.ibm.com/developerworks/websphere/library/techarticles/0310_cocasse/cocasse.html
[5] Java(TM) Servlet 2.4 Specification
author: Danny Coward, Tutaka Yoshida & others
date: 24 Nov 2003
publisher: Sun Microsystems, Inc
url: http://jcp.org/aboutJava/communityprocess/final/jsr154/index.html
[6] Java Server Pages(TM) Specification Version 2.0
author: Mark Roth, Eduardo Pelegri-Llopart & others
date: 24 Nov 2003
publisher: Sun Microsystems, Inc
url: http://jcp.org/aboutJava/communityprocess/final/jsr152/
[7] Java Null Byte Injections
author: Arshan Dabirsiaghi
date: 23 Dec 2007
url: http://i8jesus.com/?p=9
note: First reference of null byte injection in Java. Doubtlessly known before hand by some.
[8] Apache Tomcat Null Byte Directory/File Disclosure Vulnerability
cve: CVE-2003-0042
discovered-by: Jouko Pynnönen
url: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2003-0042
[9] RFC-3629: UTF-8, a transformation format of ISO 10646
author: F. Yergeau
date: Nov 2003
url: http://tools.ietf.org/html/rfc3629
note: Current RFC for UTF-8.
[10] UTF-8
author: Wikipedia
url: http://en.wikipedia.org/wiki/Utf-8
note: Very good reference on UTF-8 and a good place to start learning about it.
[11] Microsoft IIS and PWS Extended Unicode Directory Traversal Vulnerability
cve: CVE-2000-0884
discovered-by: Anonymous
url: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2000-0884
[12] Directory traversal vulnerability in Apache Tomcat
cve: CVE-2008-2938
discovered-by: Simon Ryeo & William A. Rowe, Jr.
url: http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2008-2938
[13] PK81387; 7.0.0.1: Possible application source file exposure
cve: CVE-2009-0508
discovered-by: Ed Schaller
url: http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg24022456
note: See also
[14] Potential risk when using Web based applications on WebSphere Application Server (PK81387)
date: 24 March 2009
author: IBM
published: IBM
url: http://www-01.ibm.com/support/docview.wss?rs=180&uid=swg21376806
[15] Fix list for WebSphere Application Server Version 6.0.2
date: 20 Oct 2008
author: IBM
published: IBM
url: http://www-01.ibm.com/support/docview.wss?uid=swg27006876#60231
note: Only known public details about PK64302.
[16] SOAP Messages with Attachments
date: 11 Dec 2000
author: John J. Barton, Satish Thatte & Henrik Frystyk Nielsen
published: W3C
url: http://www.w3.org/TR/SOAP-attachments
[17] Digital Blasphemy
url: http://www.digitalblasphemy.com/
note: Slide background and other great wall papers