SlideShare a Scribd company logo
1 of 22
Download to read offline
No locked doors, No windows barred
                       Hacking OpenAM Infrastructure
                 George Noseevich
                 Andrew Petukhov


                              ZeroNights 2012

Monday, November 19,
WTF OpenAM?
               •       Open source Access Management, Entitlements and
                       Federation server platform
                   ➡     successor of Sun OpenSSO Enterprise

               •       Written in Java, very Enterprisey
                   ➡     hard to configure and maintain securely

               •       Rather popular
                   ➡     inurl:/amserver/UI/Login or inurl:/openam/UI/Login

               •       Common use case: SSO across legacy apps
               •       Usually extended via custom code



Monday, November 19,
Motivation, Positioning & Layout
             • Not just another hack via XXE
             • Wanted to share our knowledge on how to develop
               an attack on OpenAM given an LFR and SSRF abilities
             • Attack vectors on different OpenAM instances
                  ➡    will start from the simplest one
                  ➡    and steadily proceed to the worst case scenario (a security hardened one)

             • Several interesting tricks
                  ➡    data retrieval in blind XXE cases
                  ➡    zip upload via HTTP PUT over gopher

             • What is the proper way to fix XXE in Java?


Monday, November 19,
Problem Statement
             • OpenAM infrastructure
             • Tomcat as a web container
             • An ability to read local files and do SSRF
                  ➡    e.g. XXE with gopher protocol enabled

             • Goal: get an Admin in OpenAM Management Panel
             • A side note: will not focus on general SSRF
               elaboration methodology, which is still valid here




Monday, November 19,
To begin with: Loot da FileSystem!




Monday, November 19,
Looting the FileSystem
              • Gotta traverse directories
                  ➡    Luckily possible to list them with XXE
                  ➡    How would you tell a directory listing from a file contents?

              • Gotta read files
                  ➡    Special chars and binary are a problem as usual

              • Would like to use GREP (General Resource
                Enumeration Protocol) and other posix tools




Monday, November 19,
And along comes...

                         XXE Fuse Demo

                 A team of specially trained
                monkeys are supporting this
                         SaaS solution 24/7
                        Request a free trial!


                 http://www.youtube.com/watch?v=7GtPgavI-sI
Monday, November 19,
Looting the FileSystem
                             XML-in-XML and OOB channels




              • The vulnerable servlet performs two rounds of xml parsing
              • In the first round we retrieve the data
              • In the second round we pass it to the attacker host




Monday, November 19,
Looting the FileSystem
                                    Possible Targets and Outcomes
           1. Other apps on host
              ➡        especially management and monitoring

           2. Configs (& credentials)
              ➡        read container config and extract HTTP credentials if needed
              ➡        ldap.conf may be especially juicy

           3. Logs
              ➡        may contain private data (e.g. SQL query logs)
              ➡        may enable further attacks (see below)




Monday, November 19,
Demo Time
                 RCE via SSRF over XXE using Tomcat App Manager




               http://www.youtube.com/watch?v=ZnsFhGYqI3g
Monday, November 19,
RCE via SSRF over XXE
                                      Wait, tell us the details!!!
           • How do you POST or PUT via XXE?
                 ➡     use gopher; at least until admins won’t update Java

           • How do you upload ZIP through gopher?
                 ➡     java gopher contains byte [] => String => byte [] conversion
                 ➡     this mangles characters >= 0x80
                 ➡     use zip -0 (store compression method)
                 ➡     with a bit of luck you can use 0x00 instead of mangled chars (i.e. find&replace)
                 ➡     the resulting file will have invalid checksums
                 ➡     surprisingly (!) Tomcat WAR parser tolerates this




Monday, November 19,
Looting the FileSystem
                           Configs & credentials
           • Container configs
                   ➡   e.g. /usr/share/tomcat6/conf/

           • OpenAM configs
                   ➡   /home/user/openam/{install.log, .configParam}
                   ➡   /home/user/openam/config/xml/

           • Password file
                   ➡   recommended way of configuring OpenAM is via ssoadm CLI tool:
                       “In most ssoadm subcommands, the password file is required option.The password file is a simple file that
                       contains the administrator password for the given task.”

                       may encourage admins to store passwords in plaintext




Monday, November 19,
Exploring OpenAM Features
           • OpenAM uses custom Auth tokens
               ➡       web container session tokens are useless
               ➡       good targets to highjack privileged sessions

           • OpenAM does Encryption
               ➡       uses Password-Based Encryption (PBEWithMD5AndDES) with low iteration
                       count
               ➡       admin pwd is encrypted with default key and stored in bootstrap file
               ➡       XXE won’t let you read the bootstrap file
               ➡       other pwds and session tokens are encrypted using randomly generated
                       instance key which is stored in binary data store
               ➡       instance key is shared across interconnected OpenAM instances (e.g. failover)




Monday, November 19,
Juicy OpenAM Features
           • Debugging
               ➡       {CONFIG_DIR}/{INSTANCE_NAME}/debug/
               ➡       If verbose debugging is enabled, we can read auth tokens and hijack sessions
               ➡       Quickly check via grep -r "AQIC"
               ➡       Admins do not log in too frequently
               ➡       Sessions expire
               ➡       Disabled by default =(

           • Monitoring
               ➡       HTTP/JMX/SNMP facility to monitor OpenAM instance
               ➡       OpenAM-specific MBeans do not seem to provide anything useful
               ➡       Also disabled by default




Monday, November 19,
Wait, but we need the features!
           • Debugging
               ➡       Every single action in admin interface is СSRF-protected
               ➡       Debug.jsp is a quick page to control debug settings
               ➡       Devs didn't worry too much about CSRF there => you can CSRF verbose
                       logging
               ➡       SSRF at Tomcat Shutdown Port to force admin login (or social engineer him)

           • Monitoring
               ➡       Enable monitoring using the hijacked session; it will have the default (i.e. known)
                       password
               ➡       SSRF at Tomcat Shutdown Port again to force reload




Monday, November 19,
Putting it All Together
                                    Dealing with the Worst Case
           • Enable debugging
               ➡       CSRF and then read admin session token from logs

           • Use admin session token to enable Monitoring
               ➡       SSRF at Tomcat Shutdown Port to force reload

           • Pwn
               ➡       Use HotSpotDiagnostic MBean to force a heap dump into DOC_ROOT
               ➡       Download and analyze the dump (strings util would do)
               ➡       Grep out the encryption key and encrypted admin password
               ➡       Decrypt the password and rule'em all




Monday, November 19,
Demo Time
                       Debugging, Monitoring and Heap Dump Scenario




                 http://www.youtube.com/watch?v=Fb2zEqwvbpw
Monday, November 19,
Wrap Up
                        Fixing XXE




Monday, November 19,
Fixing XXE in Java
           • Problem statement - devs want to:
              ➡        use a single class for all XML parsing (validating and not)
              ➡        use external DTD's from local jar files
              ➡        avoid being pwned

           • Most XML hardening guides recommend:
              ➡        turn off general and parameter entities:
                       setFeature("http://xml.org/sax/features/external-general-entities", false)
                       setFeature("http://xml.org/sax/features/external-parsed-entities", false)
              ➡        enable XMLConstants.FEATURE_SECURE_PROCESSING to prevent entity
                       expansion DoS

           • Not Enough!



Monday, November 19,
Fixing XXE in Java
           • In Java, if validation is enabled, SSRF is still possible




           • Devs: okay, let's use our custom Entity resolver:
              ➡        documentBuilder.setEntityResolver(new XMLHandler())

           • Almost there!
              ➡        make sure that XMLHandler returns an empty InputStream on error
              ➡        if you return null, JAXP will fall back to default resolvers!




Monday, November 19,
Wrap Up
                                                  Conclusions
           • Specific advice
              ➡        Never store passwords in files (who may have thought... )
              ➡        It's good to change monitoring password even if you do not use the feature
              ➡        Update Java and OpenAM (fix is available in nightly builds) - this would prevent
                       XXE and disable gopher

           • General advice: in SSRF world it is no longer safe to
             trust
              ➡        IP-based authentication could be subverted instantly
              ➡        Defying patching? Pwned! (think about delayed exploitation)
              ➡        Defying least privilege in DMZ? Very arrogant!




Monday, November 19,
Question Time!
           • George Noseevich
               ➡       Twitter: @webpentest
               ➡       Email: webpentest@gmail.com

           • Andrew Petukhov
               ➡       Twitter: @p3tand
               ➡       Email: andrew.petukhov@internalsecurity.ru

           • Show us the Source!
               ➡       Tools: http://internalsecurity.ru/media/resources/openam-xxe-tools.zip
               ➡       Video: http://www.youtube.com/playlist?
                       list=PL1CBT43qUw294xCw79B01PbRQNKI6Qqdj
               ➡       WWW: http://internalsecurity.ru/research/




Monday, November 19,

More Related Content

What's hot

OffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with XenOffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with XenTamas K Lengyel
 
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis SystemScalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis SystemTamas K Lengyel
 
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis44CON
 
44CON 2014 - Breaking AV Software
44CON 2014 - Breaking AV Software44CON 2014 - Breaking AV Software
44CON 2014 - Breaking AV Software44CON
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesScott K. Larson
 
Pitfalls of virtual machine introspection on modern hardware
Pitfalls of virtual machine introspection on modern hardwarePitfalls of virtual machine introspection on modern hardware
Pitfalls of virtual machine introspection on modern hardwareTamas K Lengyel
 
Launch Impossible Current State of Application Control Bypasses on ATMs.
Launch Impossible Current State of Application Control Bypasses on ATMs.Launch Impossible Current State of Application Control Bypasses on ATMs.
Launch Impossible Current State of Application Control Bypasses on ATMs.Payment Village
 
Derbycon Bromium Labs: Sandboxes
Derbycon Bromium Labs: SandboxesDerbycon Bromium Labs: Sandboxes
Derbycon Bromium Labs: SandboxesBromium Labs
 
Toorcon Seattle 2011 - Browser Exploit Packs
Toorcon Seattle 2011 - Browser Exploit PacksToorcon Seattle 2011 - Browser Exploit Packs
Toorcon Seattle 2011 - Browser Exploit PacksAditya K Sood
 
Virtual Machine Introspection with Xen
Virtual Machine Introspection with XenVirtual Machine Introspection with Xen
Virtual Machine Introspection with XenTamas K Lengyel
 
CrySys guest-lecture: Virtual machine introspection on modern hardware
CrySys guest-lecture: Virtual machine introspection on modern hardwareCrySys guest-lecture: Virtual machine introspection on modern hardware
CrySys guest-lecture: Virtual machine introspection on modern hardwareTamas K Lengyel
 
We shall play a game....
We shall play a game....We shall play a game....
We shall play a game....Sadia Textile
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System ServerOpersys inc.
 
Maemo Development Platform
Maemo Development PlatformMaemo Development Platform
Maemo Development Platformtko
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux DevelopersOpersys inc.
 

What's hot (19)

OffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with XenOffensiveCon2022: Case Studies of Fuzzing with Xen
OffensiveCon2022: Case Studies of Fuzzing with Xen
 
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis SystemScalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
Scalability, Fidelity and Stealth in the DRAKVUF Dynamic Malware Analysis System
 
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
44CON London 2015 - 15-Minute Linux Incident Response Live Analysis
 
44CON 2014 - Breaking AV Software
44CON 2014 - Breaking AV Software44CON 2014 - Breaking AV Software
44CON 2014 - Breaking AV Software
 
Android Internals
Android InternalsAndroid Internals
Android Internals
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
 
Pitfalls of virtual machine introspection on modern hardware
Pitfalls of virtual machine introspection on modern hardwarePitfalls of virtual machine introspection on modern hardware
Pitfalls of virtual machine introspection on modern hardware
 
Launch Impossible Current State of Application Control Bypasses on ATMs.
Launch Impossible Current State of Application Control Bypasses on ATMs.Launch Impossible Current State of Application Control Bypasses on ATMs.
Launch Impossible Current State of Application Control Bypasses on ATMs.
 
Derbycon Bromium Labs: Sandboxes
Derbycon Bromium Labs: SandboxesDerbycon Bromium Labs: Sandboxes
Derbycon Bromium Labs: Sandboxes
 
Porting Android
Porting AndroidPorting Android
Porting Android
 
Toorcon Seattle 2011 - Browser Exploit Packs
Toorcon Seattle 2011 - Browser Exploit PacksToorcon Seattle 2011 - Browser Exploit Packs
Toorcon Seattle 2011 - Browser Exploit Packs
 
Virtual Machine Introspection with Xen
Virtual Machine Introspection with XenVirtual Machine Introspection with Xen
Virtual Machine Introspection with Xen
 
CrySys guest-lecture: Virtual machine introspection on modern hardware
CrySys guest-lecture: Virtual machine introspection on modern hardwareCrySys guest-lecture: Virtual machine introspection on modern hardware
CrySys guest-lecture: Virtual machine introspection on modern hardware
 
We shall play a game....
We shall play a game....We shall play a game....
We shall play a game....
 
Understanding the Android System Server
Understanding the Android System ServerUnderstanding the Android System Server
Understanding the Android System Server
 
Maemo Development Platform
Maemo Development PlatformMaemo Development Platform
Maemo Development Platform
 
Fuzzing
FuzzingFuzzing
Fuzzing
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Installing and Upgrading AtoM
Installing and Upgrading AtoMInstalling and Upgrading AtoM
Installing and Upgrading AtoM
 

Similar to Noseevich, petukhov no locked doors no windows barred. hacking open am infrastructure

No locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureNo locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureAndrew Petukhov
 
Malware analysis
Malware analysisMalware analysis
Malware analysisxabean
 
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...Serdar Basegmez
 
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Chris Tankersley
 
Hacked? Pray that the Attacker used PowerShell
Hacked? Pray that the Attacker used PowerShellHacked? Pray that the Attacker used PowerShell
Hacked? Pray that the Attacker used PowerShellNikhil Mittal
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Chris Tankersley
 
Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015
Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015
Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015CODE BLUE
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systemssosorry
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxWO Community
 
Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Chris Tankersley
 
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Patricia Aas
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Puppet
 
Defcon - Veil-Pillage
Defcon - Veil-PillageDefcon - Veil-Pillage
Defcon - Veil-PillageVeilFramework
 
[ENG] IPv6 shipworm + My little Windows domain pwnie
[ENG] IPv6 shipworm + My little Windows domain pwnie[ENG] IPv6 shipworm + My little Windows domain pwnie
[ENG] IPv6 shipworm + My little Windows domain pwnieZoltan Balazs
 
Metasploit For Beginners
Metasploit For BeginnersMetasploit For Beginners
Metasploit For BeginnersRamnath Shenoy
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...Hackito Ergo Sum
 
Gentoo Linux, or Why in the World You Should Compile Everything
Gentoo Linux, or Why in the World You Should Compile EverythingGentoo Linux, or Why in the World You Should Compile Everything
Gentoo Linux, or Why in the World You Should Compile EverythingDonnie Berkholz
 

Similar to Noseevich, petukhov no locked doors no windows barred. hacking open am infrastructure (20)

No locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructureNo locked doors, no windows barred: hacking OpenAM infrastructure
No locked doors, no windows barred: hacking OpenAM infrastructure
 
Malware analysis
Malware analysisMalware analysis
Malware analysis
 
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
Engage 2022: The Superpower of Integrating External APIs for Notes and Domino...
 
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
Your Inner Sysadmin - Tutorial (SunshinePHP 2015)
 
Hacked? Pray that the Attacker used PowerShell
Hacked? Pray that the Attacker used PowerShellHacked? Pray that the Attacker used PowerShell
Hacked? Pray that the Attacker used PowerShell
 
Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015Your Inner Sysadmin - LonestarPHP 2015
Your Inner Sysadmin - LonestarPHP 2015
 
Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015
Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015
Is there an EFI monster inside your apple? by Pedro Vilaça - CODE BLUE 2015
 
12 tricks to avoid hackers breaks your CI / CD
12 tricks to avoid hackers breaks your  CI / CD12 tricks to avoid hackers breaks your  CI / CD
12 tricks to avoid hackers breaks your CI / CD
 
Sonatype DevSecOps Leadership forum 2020
Sonatype DevSecOps Leadership forum 2020Sonatype DevSecOps Leadership forum 2020
Sonatype DevSecOps Leadership forum 2020
 
(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems(phpconftw2012) PHP as a Middleware in Embedded Systems
(phpconftw2012) PHP as a Middleware in Embedded Systems
 
Deployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS LinuxDeployment of WebObjects applications on CentOS Linux
Deployment of WebObjects applications on CentOS Linux
 
Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015Your Inner Sysadmin - MidwestPHP 2015
Your Inner Sysadmin - MidwestPHP 2015
 
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)Linux Security  and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
Linux Security and How Web Browser Sandboxes Really Work (NDC Oslo 2017)
 
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
Continuous Infrastructure: Modern Puppet for the Jenkins Project - PuppetConf...
 
Volatility101
Volatility101Volatility101
Volatility101
 
Defcon - Veil-Pillage
Defcon - Veil-PillageDefcon - Veil-Pillage
Defcon - Veil-Pillage
 
[ENG] IPv6 shipworm + My little Windows domain pwnie
[ENG] IPv6 shipworm + My little Windows domain pwnie[ENG] IPv6 shipworm + My little Windows domain pwnie
[ENG] IPv6 shipworm + My little Windows domain pwnie
 
Metasploit For Beginners
Metasploit For BeginnersMetasploit For Beginners
Metasploit For Beginners
 
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
[HES2013] Virtually secure, analysis to remote root 0day on an industry leadi...
 
Gentoo Linux, or Why in the World You Should Compile Everything
Gentoo Linux, or Why in the World You Should Compile EverythingGentoo Linux, or Why in the World You Should Compile Everything
Gentoo Linux, or Why in the World You Should Compile Everything
 

More from DefconRussia

[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...DefconRussia
 
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...DefconRussia
 
[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobinding[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobindingDefconRussia
 
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/LinuxDefconRussia
 
Георгий Зайцев - Reversing golang
Георгий Зайцев - Reversing golangГеоргий Зайцев - Reversing golang
Георгий Зайцев - Reversing golangDefconRussia
 
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC [DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC DefconRussia
 
Cisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneCisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneDefconRussia
 
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...DefconRussia
 
HTTP HOST header attacks
HTTP HOST header attacksHTTP HOST header attacks
HTTP HOST header attacksDefconRussia
 
Attacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринAttacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринDefconRussia
 
Weakpass - defcon russia 23
Weakpass - defcon russia 23Weakpass - defcon russia 23
Weakpass - defcon russia 23DefconRussia
 
nosymbols - defcon russia 20
nosymbols - defcon russia 20nosymbols - defcon russia 20
nosymbols - defcon russia 20DefconRussia
 
static - defcon russia 20
static  - defcon russia 20static  - defcon russia 20
static - defcon russia 20DefconRussia
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20DefconRussia
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20DefconRussia
 
Nedospasov defcon russia 23
Nedospasov defcon russia 23Nedospasov defcon russia 23
Nedospasov defcon russia 23DefconRussia
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23DefconRussia
 
Miasm defcon russia 23
Miasm defcon russia 23Miasm defcon russia 23
Miasm defcon russia 23DefconRussia
 
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...DefconRussia
 
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхSergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхDefconRussia
 

More from DefconRussia (20)

[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...[Defcon Russia #29] Борис Савков -  Bare-metal programming на примере Raspber...
[Defcon Russia #29] Борис Савков - Bare-metal programming на примере Raspber...
 
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
[Defcon Russia #29] Александр Ермолов - Safeguarding rootkits: Intel Boot Gua...
 
[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobinding[Defcon Russia #29] Алексей Тюрин - Spring autobinding
[Defcon Russia #29] Алексей Тюрин - Spring autobinding
 
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
[Defcon Russia #29] Михаил Клементьев - Обнаружение руткитов в GNU/Linux
 
Георгий Зайцев - Reversing golang
Георгий Зайцев - Reversing golangГеоргий Зайцев - Reversing golang
Георгий Зайцев - Reversing golang
 
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC [DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
[DCG 25] Александр Большев - Never Trust Your Inputs or How To Fool an ADC
 
Cisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-oneCisco IOS shellcode: All-in-one
Cisco IOS shellcode: All-in-one
 
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
Олег Купреев - Обзор и демонстрация нюансов и трюков из области беспроводных ...
 
HTTP HOST header attacks
HTTP HOST header attacksHTTP HOST header attacks
HTTP HOST header attacks
 
Attacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей ТюринAttacks on tacacs - Алексей Тюрин
Attacks on tacacs - Алексей Тюрин
 
Weakpass - defcon russia 23
Weakpass - defcon russia 23Weakpass - defcon russia 23
Weakpass - defcon russia 23
 
nosymbols - defcon russia 20
nosymbols - defcon russia 20nosymbols - defcon russia 20
nosymbols - defcon russia 20
 
static - defcon russia 20
static  - defcon russia 20static  - defcon russia 20
static - defcon russia 20
 
Zn task - defcon russia 20
Zn task  - defcon russia 20Zn task  - defcon russia 20
Zn task - defcon russia 20
 
Vm ware fuzzing - defcon russia 20
Vm ware fuzzing  - defcon russia 20Vm ware fuzzing  - defcon russia 20
Vm ware fuzzing - defcon russia 20
 
Nedospasov defcon russia 23
Nedospasov defcon russia 23Nedospasov defcon russia 23
Nedospasov defcon russia 23
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
Miasm defcon russia 23
Miasm defcon russia 23Miasm defcon russia 23
Miasm defcon russia 23
 
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
Andrey Belenko, Alexey Troshichev - Внутреннее устройство и безопасность iClo...
 
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условияхSergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
Sergey Belov - Покажите нам Impact! Доказываем угрозу в сложных условиях
 

Noseevich, petukhov no locked doors no windows barred. hacking open am infrastructure

  • 1. No locked doors, No windows barred Hacking OpenAM Infrastructure George Noseevich Andrew Petukhov ZeroNights 2012 Monday, November 19,
  • 2. WTF OpenAM? • Open source Access Management, Entitlements and Federation server platform ➡ successor of Sun OpenSSO Enterprise • Written in Java, very Enterprisey ➡ hard to configure and maintain securely • Rather popular ➡ inurl:/amserver/UI/Login or inurl:/openam/UI/Login • Common use case: SSO across legacy apps • Usually extended via custom code Monday, November 19,
  • 3. Motivation, Positioning & Layout • Not just another hack via XXE • Wanted to share our knowledge on how to develop an attack on OpenAM given an LFR and SSRF abilities • Attack vectors on different OpenAM instances ➡ will start from the simplest one ➡ and steadily proceed to the worst case scenario (a security hardened one) • Several interesting tricks ➡ data retrieval in blind XXE cases ➡ zip upload via HTTP PUT over gopher • What is the proper way to fix XXE in Java? Monday, November 19,
  • 4. Problem Statement • OpenAM infrastructure • Tomcat as a web container • An ability to read local files and do SSRF ➡ e.g. XXE with gopher protocol enabled • Goal: get an Admin in OpenAM Management Panel • A side note: will not focus on general SSRF elaboration methodology, which is still valid here Monday, November 19,
  • 5. To begin with: Loot da FileSystem! Monday, November 19,
  • 6. Looting the FileSystem • Gotta traverse directories ➡ Luckily possible to list them with XXE ➡ How would you tell a directory listing from a file contents? • Gotta read files ➡ Special chars and binary are a problem as usual • Would like to use GREP (General Resource Enumeration Protocol) and other posix tools Monday, November 19,
  • 7. And along comes... XXE Fuse Demo A team of specially trained monkeys are supporting this SaaS solution 24/7 Request a free trial! http://www.youtube.com/watch?v=7GtPgavI-sI Monday, November 19,
  • 8. Looting the FileSystem XML-in-XML and OOB channels • The vulnerable servlet performs two rounds of xml parsing • In the first round we retrieve the data • In the second round we pass it to the attacker host Monday, November 19,
  • 9. Looting the FileSystem Possible Targets and Outcomes 1. Other apps on host ➡ especially management and monitoring 2. Configs (& credentials) ➡ read container config and extract HTTP credentials if needed ➡ ldap.conf may be especially juicy 3. Logs ➡ may contain private data (e.g. SQL query logs) ➡ may enable further attacks (see below) Monday, November 19,
  • 10. Demo Time RCE via SSRF over XXE using Tomcat App Manager http://www.youtube.com/watch?v=ZnsFhGYqI3g Monday, November 19,
  • 11. RCE via SSRF over XXE Wait, tell us the details!!! • How do you POST or PUT via XXE? ➡ use gopher; at least until admins won’t update Java • How do you upload ZIP through gopher? ➡ java gopher contains byte [] => String => byte [] conversion ➡ this mangles characters >= 0x80 ➡ use zip -0 (store compression method) ➡ with a bit of luck you can use 0x00 instead of mangled chars (i.e. find&replace) ➡ the resulting file will have invalid checksums ➡ surprisingly (!) Tomcat WAR parser tolerates this Monday, November 19,
  • 12. Looting the FileSystem Configs & credentials • Container configs ➡ e.g. /usr/share/tomcat6/conf/ • OpenAM configs ➡ /home/user/openam/{install.log, .configParam} ➡ /home/user/openam/config/xml/ • Password file ➡ recommended way of configuring OpenAM is via ssoadm CLI tool: “In most ssoadm subcommands, the password file is required option.The password file is a simple file that contains the administrator password for the given task.” may encourage admins to store passwords in plaintext Monday, November 19,
  • 13. Exploring OpenAM Features • OpenAM uses custom Auth tokens ➡ web container session tokens are useless ➡ good targets to highjack privileged sessions • OpenAM does Encryption ➡ uses Password-Based Encryption (PBEWithMD5AndDES) with low iteration count ➡ admin pwd is encrypted with default key and stored in bootstrap file ➡ XXE won’t let you read the bootstrap file ➡ other pwds and session tokens are encrypted using randomly generated instance key which is stored in binary data store ➡ instance key is shared across interconnected OpenAM instances (e.g. failover) Monday, November 19,
  • 14. Juicy OpenAM Features • Debugging ➡ {CONFIG_DIR}/{INSTANCE_NAME}/debug/ ➡ If verbose debugging is enabled, we can read auth tokens and hijack sessions ➡ Quickly check via grep -r "AQIC" ➡ Admins do not log in too frequently ➡ Sessions expire ➡ Disabled by default =( • Monitoring ➡ HTTP/JMX/SNMP facility to monitor OpenAM instance ➡ OpenAM-specific MBeans do not seem to provide anything useful ➡ Also disabled by default Monday, November 19,
  • 15. Wait, but we need the features! • Debugging ➡ Every single action in admin interface is СSRF-protected ➡ Debug.jsp is a quick page to control debug settings ➡ Devs didn't worry too much about CSRF there => you can CSRF verbose logging ➡ SSRF at Tomcat Shutdown Port to force admin login (or social engineer him) • Monitoring ➡ Enable monitoring using the hijacked session; it will have the default (i.e. known) password ➡ SSRF at Tomcat Shutdown Port again to force reload Monday, November 19,
  • 16. Putting it All Together Dealing with the Worst Case • Enable debugging ➡ CSRF and then read admin session token from logs • Use admin session token to enable Monitoring ➡ SSRF at Tomcat Shutdown Port to force reload • Pwn ➡ Use HotSpotDiagnostic MBean to force a heap dump into DOC_ROOT ➡ Download and analyze the dump (strings util would do) ➡ Grep out the encryption key and encrypted admin password ➡ Decrypt the password and rule'em all Monday, November 19,
  • 17. Demo Time Debugging, Monitoring and Heap Dump Scenario http://www.youtube.com/watch?v=Fb2zEqwvbpw Monday, November 19,
  • 18. Wrap Up Fixing XXE Monday, November 19,
  • 19. Fixing XXE in Java • Problem statement - devs want to: ➡ use a single class for all XML parsing (validating and not) ➡ use external DTD's from local jar files ➡ avoid being pwned • Most XML hardening guides recommend: ➡ turn off general and parameter entities: setFeature("http://xml.org/sax/features/external-general-entities", false) setFeature("http://xml.org/sax/features/external-parsed-entities", false) ➡ enable XMLConstants.FEATURE_SECURE_PROCESSING to prevent entity expansion DoS • Not Enough! Monday, November 19,
  • 20. Fixing XXE in Java • In Java, if validation is enabled, SSRF is still possible • Devs: okay, let's use our custom Entity resolver: ➡ documentBuilder.setEntityResolver(new XMLHandler()) • Almost there! ➡ make sure that XMLHandler returns an empty InputStream on error ➡ if you return null, JAXP will fall back to default resolvers! Monday, November 19,
  • 21. Wrap Up Conclusions • Specific advice ➡ Never store passwords in files (who may have thought... ) ➡ It's good to change monitoring password even if you do not use the feature ➡ Update Java and OpenAM (fix is available in nightly builds) - this would prevent XXE and disable gopher • General advice: in SSRF world it is no longer safe to trust ➡ IP-based authentication could be subverted instantly ➡ Defying patching? Pwned! (think about delayed exploitation) ➡ Defying least privilege in DMZ? Very arrogant! Monday, November 19,
  • 22. Question Time! • George Noseevich ➡ Twitter: @webpentest ➡ Email: webpentest@gmail.com • Andrew Petukhov ➡ Twitter: @p3tand ➡ Email: andrew.petukhov@internalsecurity.ru • Show us the Source! ➡ Tools: http://internalsecurity.ru/media/resources/openam-xxe-tools.zip ➡ Video: http://www.youtube.com/playlist? list=PL1CBT43qUw294xCw79B01PbRQNKI6Qqdj ➡ WWW: http://internalsecurity.ru/research/ Monday, November 19,