# Unsanitized user input in XML parsing method

## Overview

* **Rule ID**: `javascript_express_xml_external_entity_vulnerability`
* **Applicable Languages**: Javascript
* **Weakness ID**: CWE-611

## Description

Unsanitized user input in XML parsing can lead to XML External Entity (XXE) injection. This vulnerability occurs when XML input containing a reference to an external entity is processed by an XML parser. The external entity can reference a file URI or network resource, potentially allowing an attacker to access sensitive data or interact with internal systems.

## Remediation Guidelines

* **Do not** parse XML input containing untrusted data without proper sanitization. External entities within the XML should be treated with caution.

  ```javascript
  var libxml = require("libxmljs");
  libxml.parseXmlString(xml, { noent: false, noblanks: true });


  ```
* **Do not** enable the parsing of external entities in XML parsers. **Ensure** the `noent` option is set to `false` to prevent XXE attacks.

## References

* [**OWASP XML External Entity (XXE) prevention cheat sheet**](https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html)
* [**CWE-611: Improper Restriction of XML External Entity Reference**](https://cwe.mitre.org/data/definitions/611.html)
* [**OWASP Top 10: A05:2021 - Security Misconfiguration**](https://owasp.org/Top10/A05_2021-Security_Misconfiguration/)

## Configuration

To omit this rule during a scan, and to provide you with continuous 24/7 code-level scanning, you can employ our [**SAST TOOL**](https://scopy.sec1.io/login)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sec1.io/user-docs/4-sast/3-javascript/unsanitized-user-input-in-xml-parsing-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
