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.
npx agentmods add rules/matank001/cursor-security-rules/xxe-preventiongit clone --depth 1 https://github.com/matank001/cursor-security-rulesWrote 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.
[](https://agentmods.dev/rules/matank001/cursor-security-rules/xxe-prevention)<a href="https://agentmods.dev/rules/matank001/cursor-security-rules/xxe-prevention"><img src="https://agentmods.dev/badge/rules/matank001/cursor-security-rules/xxe-prevention.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.00469 |
| Opus 5 | $0.00000 | $0.00234 |
| Sonnet 5 | $0.00000 | $0.00094 |
| Haiku 4.5 | $0.00000 | $0.00047 |
Grade A, and why
xxe-prevention scanned grade A with 0 findings 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 4d 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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
Copies of this mod
2 near-identical copies found in the catalogue:
- security-global-xxe-prevention — 94% identical, 3 lines differ
- security-global-xxe-prevention — 94% identical, 3 lines differ
How it starts
The opening of the file, as written. The whole thing — 44 lines — stays where its author put it; the contents beside it link to each section on GitHub.
XXE Prevention
These rules apply to all code that parses or processes XML, regardless of language or framework, including AI-generated code.
All violations must include a clear explanation of which rule was triggered and why, to help developers understand and fix the issue effectively.
Generated code must not violate these rules. If a rule is violated, a comment must be added explaining the issue and suggesting a correction.
1. Disable DTDs and External Entities
- Rule: XML parsers must have Document Type Definitions (DTDs) disabled and must not resolve external entities.
- Example (unsafe, Python with lxml):
from lxml import etree etree.fromstring(user_xml) # External entities allowed ➜ XXE - Example (safe, Python using defusedxml):
from defusedxml.ElementTree import fromstring fromstring(user_xml) # External entities blocked
2. Use Secure Parser Features / Libraries
- Rule: Choose parsers with XXE protection by default (e.g.,
defusedxmlin Python,XMLInputFactorywithXMLConstants.FEATURE_SECURE_PROCESSINGin Java). Verify that features to disallow external DTDs and entities are enabled.
3. Restrict Schema and XInclude Processing
- Rule: Do not allow remote or file-based schema, XInclude, or XSLT processing on untrusted XML unless explicitly required and properly sandboxed.
4. Limit Resource Consumption
- Rule: Configure parser limits (file size, entity expansion depth, timeouts) to prevent Billion Laughs and Quadratic Blow-up DoS attacks.
5. Validate and Sanitize Input Before Processing
- Rule: Validate XML against a known schema or allow-list of expected elements. Reject unexpected or malformed content early.
6. Avoid Logging Sensitive XML Content
- Rule: Do not log raw XML that may contain credentials, personal data, or other sensitive information.
7. Keep Parser Libraries Patched
- Rule: Regularly update XML libraries to incorporate security patches that address newly discovered parser flaws.
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.
- 4d ago First seen · 44 lines · 0 tokens per session scan A 602001540bf5
xxe-prevention is a cursor rule published in the GitHub repository matank001/cursor-security-rules (378 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 469 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other cursor rules, from other repositories
ankra-cli
Ankra CLI rules and best practices for managing Kubernetes clusters via the Ankra platform.
go-backend-scalability-cursorrules-prompt-file
Cursor rules for Go development with backend scalability.
cloudflare-email-telegram-cursorrules-prompt-file
Cursor rules for setting up email-to-Telegram forwarding via Cloudflare Email Routing and Workers using the mail2tg CLI.
flutter-riverpod-cursorrules-prompt-file
Cursor rules for Flutter Riverpod.
angular-novo-elements-cursorrules-prompt-file
Cursor rules for Angular development with Novo Elements UI library.
chrome-extension-dev-js-typescript-cursorrules-pro
Cursor rules for VSCode extension development with Electron and TypeScript integration.