# VNX-610: Externally Controlled Reference to a Resource in Another Sphere (XML external references enabled)

Reports Java XML parser calls that explicitly enable external references.

| Field | Value |
|---|---|
| Rule ID | `VNX-610` |
| Severity | Medium |
| SARIF level | `warning` |
| Kind | `sast` |
| Languages | Java |
| CWE | [CWE-610](https://cwe.mitre.org/data/definitions/610.html) |
| CAPEC | [CAPEC-66](https://capec.mitre.org/data/definitions/66.html) |
| ATT&CK | [T1190](https://attack.mitre.org/techniques/T1190/) |
| CWSS vector | `CWSS:1.0/TI:M/AP:A/AL:A/IC:N/FC:LT/RP:N/RL:A/AV:I/AS:N/IN:A/SC:A/BI:M/DI:H/EX:M/EC:N/P:C` |
| Tags | `external-entity` `xml` `cwe-610` |
| Source | [`internal/sast/rules/vnx-610.rego`](https://github.com/Vulnesis/cli/blob/main/internal/sast/rules/vnx-610.rego) |

## Overview

VNX-610 maps to [CWE-610: Externally Controlled Reference to a Resource in Another Sphere](https://cwe.mitre.org/data/definitions/610.html). CWE-610 is a class; this rule reports its most concrete Java form, a call that explicitly turns external references on:

- `setFeature(".../external-general-entities" | ".../external-parameter-entities" | ".../load-external-dtd", true)`
- `setFeature(".../disallow-doctype-decl", false)` and `setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, false)`
- `setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, true)`
- `setAttribute`/`setProperty(ACCESS_EXTERNAL_DTD | ACCESS_EXTERNAL_SCHEMA | ACCESS_EXTERNAL_STYLESHEET, "all")` or a protocol list such as `"file,http"`
- `setXIncludeAware(true)`

Calls whose arguments continue on the next lines are read. Not reported: the same calls switching the feature off, unrelated features, and factories left at defaults (VNX-JAVA-004 and VNX-JAVA-029 judge unhardened factories).

## Why this matters

A document parsed with these settings can make the parser read local files (`file:///etc/passwd`), call internal URLs, or include other documents, and return what it read in the parsed result.

## What gets flagged

```java
reader.setFeature("http://xml.org/sax/features/external-general-entities", true);
xif.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, true);
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "all");
f.setXIncludeAware(true);
parser.getXMLReader().setFeature(
        "http://xml.org/sax/features/external-parameter-entities", true);
spf.setFeature(GENERAL_ENTITIES, true);   // constant holding the feature URL
System.setProperty("javax.xml.accessExternalDTD", "all");
```

## Remediation

1. Remove the call, or set the feature to its safe value: `disallow-doctype-decl` true, external entities false, `ACCESS_EXTERNAL_*` to `""`.
2. If a document needs an external DTD or schema, resolve it from a local catalogue with an `EntityResolver`.
3. For a confirmed false positive, add a `// vulnetix-ignore: VNX-610` comment on the line.

## References

- [CWE-610: Externally Controlled Reference to a Resource in Another Sphere](https://cwe.mitre.org/data/definitions/610.html)
- [OWASP XML External Entity Prevention Cheat Sheet](https://cheatsheetseries.owasp.org/cheatsheets/XML_External_Entity_Prevention_Cheat_Sheet.html)

## Suppressing this rule

Put a `nosec` comment on the line, or on line 1 to cover the whole file. Use the comment marker of the file's language (`#`, `//`, `--` or `;`):

```text
# nosec vnx-610
// nosec vnx-610
```

Or record an ignore rule: `vulnetix ignore add --rule vnx-610 --reason "..."`. See [Suppressing findings](/sast/guides/suppressing-findings.md).
