Web Application and Mobile Applications have become the new form of Enterprise Information Technology enabling of business and entities through the World Wide Web. Extensible Markup Language (XML) has been in use in the Internet Domain, since year 1998, and the design goals of XML emphasises simplicity, generality, and usability across the Internet. XML is a file format for storing, transmitting, and reconstructing arbitrary data for Web Applications. The XML in addition, defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. It is also a format that is for ‘Free Open Standards’.
The “Injection Attack” have been a form of attack on Information Systems and among these forms of attacks, it is the ‘SQL Injection Attack’ that is know to one and all. The ‘XML Injection Attacks’ is another form of Injection Attack that can occur when an application is able to parses specially-crafted XML input inturn causing destruction to Web Applications.
What is XML?
XML is a derivative of SGML (Standard Generalized Markup Language) (upon which HTML is also based) which is used to represent structured data objects as human-readable text. XML is extensible so that it can be tailored for any application by defining how data is organised and represented. The first line of the text file unambiguously identifies the file as an XML document and declares that it is encoded as Unicode “UTF-8” characters. This Language is extensively used in Web Application design. Although the design of XML focuses on documents, the language is widely used for the representation of arbitrary data structures such as those used in web services. Several schema systems exist to aid in the definition of XML-based languages, while programmers have developed many Application Programming Interfaces (APIs) to aid the processing of XML data.
What Is XML Injection Attack?
An Overview of the Different Types of XML Injection Attacks
XML injections is not a singular referable attack, and it has its own variances. Practically speaking, XML injection technique can be used against virtually any type of software that uses XML for data input, output and/or storage. They’re a whole umbrella category that consists of multiple unvalidated input-related vulnerabilities, which is also otherwise overlapping:
XML Entity Expansion (XEE) — Also known as XML bombs (aka an XML DoS attack or the “billion laughs attack”), this tactic involves an attacker injecting a massive number of recursive or nested references to crash your web app or server.
XML External Entity (XXE) — This is where an attacker inserts an external entity reference into their input to either access sensitive XML files that they shouldn’t have access to, or to make malicious queries to external URIs.
XPath Injection — This type of attack involves an attacker sending malicious data or commands via an XPath expression to your XML document or database. (XPaths allows you to select specific parts of XML or HTML documents to display on your site or in your app.) By injecting a malicious value into the XPath expression, an attacker can modify or add something to your XML-enabled database or document or do something else (e.g., gain remote access to sensitive data by bypassing authentication).
Blind XPath Injection — This is done as a way to carry out an XPath injection when an attacker doesn’t know how a target XML document is structured or if you’re not displaying errors, they find useful. This helps an attacker discover how your files are structured and modify the data contained within as desired. This attack method typically consists of XML crawling and Boolean testing to generate true/false responses that inform them whether an attack is successful or failed.
XQuery Injection — An attacker uses a malicious XQuery input to execute a malicious command or add unauthorized info to your XML-enabled database or files. XQL injections use XML query language characters to create inputs with invalid syntax to access or modify sensitive information contained within your XML documents or database.
Further, these types of attacks are directed with malicious intentions and also allow the attack surface to be exposed for subsequent exploitation:
To achieve Bypass on web app’s authentication. An XML injection can gain unauthorized access to stored sensitive data by inputting code that allows them to bypass the authentication requirements altogether; this then can provide a work-around to the Authentication Measures in the design.
Ability to Read organization’s stored sensitive files. XML injections typically allow malicious actors to read or modify the contents of the XML data files. This is then an unauthorised activity causing damage to the setup.
Alter or modify XML files. Some XML injection attacks allow the malicious actors to change the data contained within them. Hence, going beyond the possibility of just reading the XML files.
Carry out XML-based Denial of Service (DoS) attacks. Attackers can overload a web app’s memory and block legitimate traffic from accessing the web apps or services. Also, if the illegitimate query includes info that’s repeated over and over, then it can result in overloading the XML parser activity as a DoS attack.
How to Mitigate XML Injection Risks
XML Injection Attacks can also result from poor cybersecurity awareness, or due to inadequacy in audit and continued review. Ensuring secure coding best practices and patching and updating of software and systems; will also provider the essential security from XML Injection Attacks. Compliance to regulations, employee training and awareness, etc, are requirements that the management will also need to pay attention to. (For example- All Government of India Websites and Web Application need to be complaint to the “Guidelines for Indian Government Websites (GIGW)” and “Guidelines for Development of e-Governance Applications (GuDApps)”). In the case of XML Injection Attacks, the steps taken to block an attacker’s action to inject non-approved code into any XML document or query, will ensure a strong and secure application. These are among the few things that the organisation can do, to ensure immediate protection against XML Injection Attacks:
Regular check for compliance. Regular Certification audit, routine Surveillance Audit, and QA activities.
Sanitize user inputs to filter out unacceptable characters. This can be ensured by filtering or disallowing characters like ’, ”, <, >, /, etc. — from your web form user input fields.
Specify which inputs are allowed. Rather than trying to cover all of possibilities, one can take a different approach and specify which characters are allowed by setting a default deny policy. For example, if you want to include a field for a user’s age, restrict user inputs to only allow the use of numbers.
Keep an eye on your XML parser. To help make your XML parser more secure against these types of attacks, keep an eye on your parser to identify any vulnerabilities. Also be sure to disallow DTDs.
Implementation of Application Programming Interface (API) Security Gateway. Many Interaction on Web Applications are now-a-days through APIs, the use of ‘API Gateway’ Utilities can ensure security through disallowing of malicious XMLs.
Implement a Content Security Policy (CSP). An HTTP CSP response header restricts the types of resources a user can load while using your site to a set list of predetermined resources. This need to be implemented with appropriate configuration to ensure countering of XML Injection Attacks