Home > Ask the Security Experts > Application Security Questions & Answers > Do XPath injection attacks require the same response as SQL injections?
Ask The Security Expert: Questions & Answers
EMAIL THIS

Do XPath injection attacks require the same response as SQL injections?

Michael Cobb EXPERT RESPONSE FROM: Michael Cobb

Pose a Question
Other Security Categories
Meet all Security Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 29 January 2007
How do XPath injection attacks differ from SQL injection attacks? Would SQL injection mitigating techniques protect against XPath injection attacks?

>
EXPERT RESPONSE
XPath (XML Path Language) 1.0 is an expression language that many applications use to carry out operations based on the content in an XML document. An XML document serves as the database, and the XPath query is used to access the data within the document. The benefits to using an XML database instead of a conventional database include portability, compatibility, re-usability and structured formatting.

While the syntax of an XPath expression is similar in many ways to an SQL query, XPath injection is more dangerous than SQL injection. When Web applications construct XPath queries without first validating user-supplied data, XPath injections can exploit these applications. An attacker can inject data into a query, thereby changing its semantics. By inserting a series of Boolean queries – crafted expressions that produce a value of "true" or "false" – the attacker can iterate through all the nodes of the document. Using such techniques, even an attacker who has no prior knowledge of the XPath query can retrieve a complete XML database document.

Most databases provide some level of access and privilege controls, restricting users to certain tables, fields or queries. This restriction generally limits an attacker to the application's database account. XPath provides no access control for the database document, so an attacker can query all XML objects within it. Also, since XPath is a standard language, an attacker can create an automated attack to fit any XPath-based application. Because of SQL's many variants, SQL injection attacks must be customized for the particular version of SQL being targeted.

Measures taken to defend against SQL injection do in fact help protect against XPath injection. To review, here are a few preventative steps to take. First, your application must validate and sanitize all user input. Second, assume all data is from an un-trusted source; before it's used by your scripts, data access routines and XPath queries, validate the data for type, length, format and range. It's also worth noting that this validation must be performed on the server-side, not the client-side, since client-side validation is easily bypassed. Unfortunately, there isn't a native XPath equivalent to parameterized queries, and for that reason, XPath queries have to be constructed using string-building techniques. This makes validating user-supplied input all the more important. Testing whether your application is vulnerable to XPath injection is easy. Just add a single quotation mark within the data sent to your server, and see if an error occurs. If it does, then it's likely that an XPath injection is possible. The XPath 2.0 specification, which is in the final stages of the World Wide Web Consortium (W3C)'s approval process, offers a greatly expanded set of functions and capabilities, but sadly no increased security.

More information:

  • Use this XML Security Learning Guide to improve your Web services.
  • Prevent blind SQL injection attacks.

  • Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


    RELATED CONTENT
    Application Security
    Can IBM's SMash technology secure Web applications?
    Why is backscatter spam so difficult to block?
    What are the risks of disabling the User Account Control (UAC) feature on Windows Vista?
    Protecting exposed servers from Google hacks (and Google 'dorks')
    Which automated quality assurance tools can be used to test software?
    Has proof-of-concept mobile device malware translated into any meaningful attacks?
    Is it possible to ban chat programs on an enterprise LAN?
    How to test the security of personal details submitted to a website
    Is security improved when the number of Internet gateways is reduced?
    Are Internet cafe users' email credentials at risk?

    Web Services Security and SOA Security
    MySpace, Facebook ignoring basic principles of security
    Kaminsky: DNS flaw capable of attacks on many fronts
    Information security book excerpts and reviews
    Kaminsky on DNS rebinding attacks, hacking techniques
    Which operating system can best secure an FTP site?
    IBM's Watchfire halts network research, focuses on Web apps
    How does identity propagation work?
    Citrix adds Web security with acquisition
    Are attackers using malware to exploit service oriented architectures?
    Using an XML security gateway in a service-oriented architecture

    Database Security
    Microsoft to patch critical flaws in Office, SQL Server
    Critical Oracle flaw to get emergency fix
    NitroSecurity covers its bases with RippleTech deal
    Oracle releases 45 database, application fixes
    Microsoft to issue Windows, SQL Server updates
    Fortinet acquires database vulnerability scanner from IPLocks
    Information security book excerpts and reviews
    Product review: Symantec Database Security 3.1
    New SQL injection technique threatens Oracle databases
    Oracle fixes 41 flaws in April CPU
    Database Security Research

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    data encryption/decryption IC  (SearchSecurity.com)
    International Data Encryption Algorithm  (SearchSecurity.com)
    link encryption  (SearchSecurity.com)
    MD2  (SearchSecurity.com)
    MD4  (SearchSecurity.com)
    MD5  (SearchSecurity.com)

    RELATED RESOURCES
    2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
    Search Bitpipe.com for the latest white papers and business webcasts
    Whatis.com, the online computer dictionary



    Search and Browse the Expert Answer Center
    Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
    Browse our Expert Advice



    Find Security Solutions for Your Business
    Targeted Security Channel Tips for Resellers, Integrators and Consultants
    TechTarget Security Media
    Information Security View this month\\'s issue and subscribe today.
    Information Security Decisions Apply online for free conference admission.
    SearchSecurity.com
    HomeNewsMagazineMultimediaWhite PapersLearningAdviceTopicsEventsAbout Us

    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




    All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts