SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
XQuery Injection
Web App Vulnerabilities
by Secure Code Warrior Limited is licensed under CC BY-ND 4.0
What is it?
XQuery injection is similar to SQL
injection, but instead takes place when
unsafe user-supplied input is used to
query XML data resulting in execution
of the input. This type of attack is often
called XPath injection as well. What causes it?
If user input is not properly sanitized
before being used in the XPath query,
the user can manipulate the search.
What could happen?
An attacker could be able to access
data that should not be accessible or
even elevate his privileges if XML is
used for authentication. Opposed to
SQL injection, there is no level access
control, allowing an attacker to
retrieve the entire document.
How to prevent it?
Sanitize user input through filtering or
validation. Use parameterized queries and
apply least privilege, such as a read only
user.
XQuery Injection
Understanding the security vulnerability
A website uses an XML-
based database for storing
user credentials and
performing authentication.
An attacker manipulates the query in
an attempt to perform XPath
injection and circumvent the
authentication mechanism.
The injected XML is
processed and results
in the attacker being
logged in as admin
The login field results in an XPath
query that verifies the provided
credentials and retrieves the
account privileges.
User:admin' or
'1' = '1
Pass:whatever
Welcome,
Admin!
User: John
Pass: dragon
Authentication
bypass
<?xml version="1.0"
encoding="ISO-8859-1"?>
<users>
<user>
<username>admin</username>
<password>trustno1</password
> <account>admin</account>
</user>
<user>
<username>john</username>
<password>dragon</password>
<account>guest</account>
</user>
</users>
users.xml
string(//user[username/text()=
‘john' and
password/text()=‘dragon']/
account/text())
Guest
string(//user[username/text()=
‘admin' or '1' = '1' and
password/text()=
‘whatever']/account/text())
Admin
XQuery Injection
Understanding the security vulnerability
A website’s user base is
contained in an XML
document and can be
searched by entering a
username.
The injected code modifies the
query and causes it to be valid for
every user in the XML file.
As a result of the query, the
attacker receives a list of all
user nodes contained in the
document.
An attacker injects some XML code
to try to modify the query.
<?xml version="1.0"
encoding="ISO-8859-1"?>
<users>
<user>
<uname>admin</uname>
<fname>Jane</fname>
<lname>Doe</lname>
</user>
<user>
<uname>jdoe</uname>
<fname>John</fname>
<lname>Doe</lname>
</user>
</users>
Data extraction
Find user:
jdoe
doc("users.xml")/users/
user[uname=“jdoe"]
uname: jdoe
fname: John
lname: Doe
Find user:
Something"
or ""="
doc("users.xml")/
userlist/user[uname=
"something" or
""=""]
XQuery Injection
Realizing the impact
XML used for authentication could allow
an attacker to log in as another user.
A manipulated query could result in data
modification or deletion.
An attacker could be able to retrieve the
entire XML document, resulting in
compromised data.
XQuery Injection
Preventing the mistake
Never trust user input!
Apply application-wide filters or sanitization on all user-
provided input.
GET and POST parameters, Cookies and other HTTP headers.
Apply white-list input validation.
Libraries exist in different frameworks.
Use a parameterized XPath interface.
Use a read only user to perform queries.

More Related Content

What's hot (20)

PDF
POO Java Chapitre 4 Heritage et Polymorphisme
Mouna Torjmen
 
PDF
Angular Directives
iFour Technolab Pvt. Ltd.
 
PDF
Migrating From Cpp To C Sharp
Ganesh Samarthyam
 
PDF
Angular Routing Guard
Knoldus Inc.
 
PPTX
Introduction à React JS
Abdoulaye Dieng
 
PDF
F5 TLS & SSL Practices
Brian A. McHenry
 
PDF
Cours java avance débutant facile l'essentiel swing ,events
Houssem Hamrouni
 
PDF
Chapitre8: Collections et Enumerations En Java
Aziz Darouichi
 
PDF
Angular Framework présentation PPT LIGHT
tayebbousfiha1
 
PDF
Sécurité des Applications WEB -LEVEL1
Tarek MOHAMED
 
PDF
Local File Inclusion to Remote Code Execution
n|u - The Open Security Community
 
PPT
Introduction à JavaScript
Abdoulaye Dieng
 
PDF
Site JEE de ECommerce Basé sur Spring IOC MVC Security JPA Hibernate
ENSET, Université Hassan II Casablanca
 
PDF
Support cours angular
Nizar MAATOUG -ISET Sidi Bouzid
 
PPTX
Introduction to Linux Exploit Development
johndegruyter
 
PPTX
Présentation Git & GitHub
Thibault Vlacich
 
PPTX
Introduction à JavaScript
Abdoulaye Dieng
 
PDF
Introduction au Framework AngularJs
RadhoueneRouached
 
PDF
Maven et industrialisation du logiciel
ENSET, Université Hassan II Casablanca
 
POO Java Chapitre 4 Heritage et Polymorphisme
Mouna Torjmen
 
Angular Directives
iFour Technolab Pvt. Ltd.
 
Migrating From Cpp To C Sharp
Ganesh Samarthyam
 
Angular Routing Guard
Knoldus Inc.
 
Introduction à React JS
Abdoulaye Dieng
 
F5 TLS & SSL Practices
Brian A. McHenry
 
Cours java avance débutant facile l'essentiel swing ,events
Houssem Hamrouni
 
Chapitre8: Collections et Enumerations En Java
Aziz Darouichi
 
Angular Framework présentation PPT LIGHT
tayebbousfiha1
 
Sécurité des Applications WEB -LEVEL1
Tarek MOHAMED
 
Local File Inclusion to Remote Code Execution
n|u - The Open Security Community
 
Introduction à JavaScript
Abdoulaye Dieng
 
Site JEE de ECommerce Basé sur Spring IOC MVC Security JPA Hibernate
ENSET, Université Hassan II Casablanca
 
Support cours angular
Nizar MAATOUG -ISET Sidi Bouzid
 
Introduction to Linux Exploit Development
johndegruyter
 
Présentation Git & GitHub
Thibault Vlacich
 
Introduction à JavaScript
Abdoulaye Dieng
 
Introduction au Framework AngularJs
RadhoueneRouached
 
Maven et industrialisation du logiciel
ENSET, Université Hassan II Casablanca
 

Viewers also liked (15)

PPTX
Secure Code Warrior - Insufficient data encoding
Secure Code Warrior
 
PPTX
Secure Code Warrior - Client side injection
Secure Code Warrior
 
PPTX
Secure Code Warrior - Privacy
Secure Code Warrior
 
PPTX
Secure Code Warrior - CRLF injection
Secure Code Warrior
 
PPTX
Secure Code Warrior - Issues with origins
Secure Code Warrior
 
PPTX
Secure Code Warrior - Least privilege
Secure Code Warrior
 
PPTX
Secure Code Warrior - Logging
Secure Code Warrior
 
PPTX
Secure Code Warrior - Secure by default
Secure Code Warrior
 
PPTX
Secure Code Warrior - Local storage
Secure Code Warrior
 
PPTX
Secure Code Warrior - Cookies and sessions
Secure Code Warrior
 
PPTX
Secure Code Warrior - Fail securely
Secure Code Warrior
 
PPTX
Secure Code Warrior - Unrestricted file upload
Secure Code Warrior
 
PPTX
Secure Code Warrior - Defense in depth
Secure Code Warrior
 
PPTX
Secure Code Warrior - Trust no input
Secure Code Warrior
 
PPTX
Secure Code Warrior - Robust error checking
Secure Code Warrior
 
Secure Code Warrior - Insufficient data encoding
Secure Code Warrior
 
Secure Code Warrior - Client side injection
Secure Code Warrior
 
Secure Code Warrior - Privacy
Secure Code Warrior
 
Secure Code Warrior - CRLF injection
Secure Code Warrior
 
Secure Code Warrior - Issues with origins
Secure Code Warrior
 
Secure Code Warrior - Least privilege
Secure Code Warrior
 
Secure Code Warrior - Logging
Secure Code Warrior
 
Secure Code Warrior - Secure by default
Secure Code Warrior
 
Secure Code Warrior - Local storage
Secure Code Warrior
 
Secure Code Warrior - Cookies and sessions
Secure Code Warrior
 
Secure Code Warrior - Fail securely
Secure Code Warrior
 
Secure Code Warrior - Unrestricted file upload
Secure Code Warrior
 
Secure Code Warrior - Defense in depth
Secure Code Warrior
 
Secure Code Warrior - Trust no input
Secure Code Warrior
 
Secure Code Warrior - Robust error checking
Secure Code Warrior
 
Ad

Similar to Secure Code Warrior - XQuery injection (20)

PDF
XPath Injection
Magno Logan
 
PDF
PXpathV: Preventing XPath Injection Vulnerabilities in Web Applications
ijwscjournal
 
PDF
PXpathV: Preventing XPath Injection Vulnerabilities in Web Applications
ijwscjournal
 
PDF
PXpathV: Preventing XPath Injection Vulnerabilities in Web Applications
ijwscjournal
 
PPTX
xpathinvevevevwvwvwvwvwvwwwwwwwwwwwwwwwjection.pptx
VikasTuwar1
 
PPTX
Xpath injection in XML databases
Triad Square InfoSec
 
PDF
Hacking XPATH 2.0
michelemanzotti
 
PDF
[3.3] Detection & exploitation of Xpath/Xquery Injections - Boris Savkov
OWASP Russia
 
PPT
XPath Injection
Roberto Suggi Liverani
 
PPTX
FORENSIC PRESTTN
Rufa'i Mustapha
 
PPTX
Devouring Security XML Attack surface and Defences
gmaran23
 
ODP
Hands-On XML Attacks
Toe Khaing
 
PPTX
Owasp webgoat
Zakaria SMAHI
 
PPTX
XML & XPath Injections
AMol NAik
 
PDF
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
PDF
Security Vulnerabilities: How to Defend Against Them
Martin Vigo
 
PDF
Drupal campleuven: Secure Drupal Development
Steven Van den Hout
 
PDF
Xpath Injection
Aung Khant
 
PDF
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
Sam Bowne
 
PDF
Drupal Security from Drupalcamp Bratislava
Gábor Hojtsy
 
XPath Injection
Magno Logan
 
PXpathV: Preventing XPath Injection Vulnerabilities in Web Applications
ijwscjournal
 
PXpathV: Preventing XPath Injection Vulnerabilities in Web Applications
ijwscjournal
 
PXpathV: Preventing XPath Injection Vulnerabilities in Web Applications
ijwscjournal
 
xpathinvevevevwvwvwvwvwvwwwwwwwwwwwwwwwjection.pptx
VikasTuwar1
 
Xpath injection in XML databases
Triad Square InfoSec
 
Hacking XPATH 2.0
michelemanzotti
 
[3.3] Detection & exploitation of Xpath/Xquery Injections - Boris Savkov
OWASP Russia
 
XPath Injection
Roberto Suggi Liverani
 
FORENSIC PRESTTN
Rufa'i Mustapha
 
Devouring Security XML Attack surface and Defences
gmaran23
 
Hands-On XML Attacks
Toe Khaing
 
Owasp webgoat
Zakaria SMAHI
 
XML & XPath Injections
AMol NAik
 
xss-100908063522-phpapp02.pdf
yashvirsingh48
 
Security Vulnerabilities: How to Defend Against Them
Martin Vigo
 
Drupal campleuven: Secure Drupal Development
Steven Van den Hout
 
Xpath Injection
Aung Khant
 
CNIT 129S: 12: Attacking Users: Cross-Site Scripting (Part 1 of 2)
Sam Bowne
 
Drupal Security from Drupalcamp Bratislava
Gábor Hojtsy
 
Ad

Recently uploaded (20)

PDF
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PDF
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
PDF
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
PDF
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PDF
Mastering Financial Management in Direct Selling
Epixel MLM Software
 
Automating Feature Enrichment and Station Creation in Natural Gas Utility Net...
Safe Software
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Agentforce World Tour Toronto '25 - Supercharge MuleSoft Development with Mod...
Alexandra N. Martinez
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Transforming Utility Networks: Large-scale Data Migrations with FME
Safe Software
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
Newgen Beyond Frankenstein_Build vs Buy_Digital_version.pdf
darshakparmar
 
Peak of Data & AI Encore AI-Enhanced Workflows for the Real World
Safe Software
 
How do you fast track Agentic automation use cases discovery?
DianaGray10
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
CIFDAQ Market Wrap for the week of 4th July 2025
CIFDAQ
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
Transcript: Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Mastering Financial Management in Direct Selling
Epixel MLM Software
 

Secure Code Warrior - XQuery injection

  • 1. XQuery Injection Web App Vulnerabilities by Secure Code Warrior Limited is licensed under CC BY-ND 4.0
  • 2. What is it? XQuery injection is similar to SQL injection, but instead takes place when unsafe user-supplied input is used to query XML data resulting in execution of the input. This type of attack is often called XPath injection as well. What causes it? If user input is not properly sanitized before being used in the XPath query, the user can manipulate the search. What could happen? An attacker could be able to access data that should not be accessible or even elevate his privileges if XML is used for authentication. Opposed to SQL injection, there is no level access control, allowing an attacker to retrieve the entire document. How to prevent it? Sanitize user input through filtering or validation. Use parameterized queries and apply least privilege, such as a read only user.
  • 3. XQuery Injection Understanding the security vulnerability A website uses an XML- based database for storing user credentials and performing authentication. An attacker manipulates the query in an attempt to perform XPath injection and circumvent the authentication mechanism. The injected XML is processed and results in the attacker being logged in as admin The login field results in an XPath query that verifies the provided credentials and retrieves the account privileges. User:admin' or '1' = '1 Pass:whatever Welcome, Admin! User: John Pass: dragon Authentication bypass <?xml version="1.0" encoding="ISO-8859-1"?> <users> <user> <username>admin</username> <password>trustno1</password > <account>admin</account> </user> <user> <username>john</username> <password>dragon</password> <account>guest</account> </user> </users> users.xml string(//user[username/text()= ‘john' and password/text()=‘dragon']/ account/text()) Guest string(//user[username/text()= ‘admin' or '1' = '1' and password/text()= ‘whatever']/account/text()) Admin
  • 4. XQuery Injection Understanding the security vulnerability A website’s user base is contained in an XML document and can be searched by entering a username. The injected code modifies the query and causes it to be valid for every user in the XML file. As a result of the query, the attacker receives a list of all user nodes contained in the document. An attacker injects some XML code to try to modify the query. <?xml version="1.0" encoding="ISO-8859-1"?> <users> <user> <uname>admin</uname> <fname>Jane</fname> <lname>Doe</lname> </user> <user> <uname>jdoe</uname> <fname>John</fname> <lname>Doe</lname> </user> </users> Data extraction Find user: jdoe doc("users.xml")/users/ user[uname=“jdoe"] uname: jdoe fname: John lname: Doe Find user: Something" or ""=" doc("users.xml")/ userlist/user[uname= "something" or ""=""]
  • 5. XQuery Injection Realizing the impact XML used for authentication could allow an attacker to log in as another user. A manipulated query could result in data modification or deletion. An attacker could be able to retrieve the entire XML document, resulting in compromised data.
  • 6. XQuery Injection Preventing the mistake Never trust user input! Apply application-wide filters or sanitization on all user- provided input. GET and POST parameters, Cookies and other HTTP headers. Apply white-list input validation. Libraries exist in different frameworks. Use a parameterized XPath interface. Use a read only user to perform queries.