prompt-injection

Security rules for handling content retrieved from outside sources in AI systems. They require source tracking, cautious trust levels, treating unknown content as untrusted data, and rejecting model output that does not match its required format.

In plain words
What is it for?
Use them when fetching content, storing it in an AI memory or search index, deciding whether it can be trusted, or validating structured model responses.
Why use it?
They help prevent text from websites, documents, or memory stores from secretly changing an agent's instructions or causing unsafe actions.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/onesimplecode/agent-engineering-standards/prompt-injection
Clone the repo
git clone --depth 1 https://github.com/onesimplecode/agent-engineering-standards

Made for: Cursor.

Per session 641 This file is loaded in full into every session.
When invoked 641 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
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 $0.00641 $0.00641
Opus 5 $0.00320 $0.00320
Sonnet 5 $0.00128 $0.00128
Haiku 4.5 $0.00064 $0.00064

Measured 2d ago against content hash e04355ac9de5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

prompt-injection 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 2d 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.

examples/cursor-rules/.cursor/rules/prompt-injection.mdc · 25 lines

How it starts

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

Prompt Injection

TR-SEC-005 — Externally retrieved content treated as untrusted

Retrieved content must not authorize tool calls or override system-level reasoning. When retrieved content may contain PII, TR-SEC-003 routing takes precedence.

TR-SEC-011 — Content provenance tracked and trust derived fail-closed at retrieval

Content ingested into an agentic memory or RAG index must be tagged with its source type at write time. Trust level is derived from source type via a mapping defined in code (not stored as data), so a mapping revision is a code change, not a migration. The mapping is fail-closed: only explicitly named self-authored source types earn the most-trusted tier; any unrecognized or unclassified type falls to the least-trusted tier, and content whose provenance was never recorded is treated as unverified, equivalent to untrusted. Provenance is validated at retrieval time, not only at ingest. Untrusted and unverified content is quarantined data under TR-SEC-005 — spotlighted at the reasoning boundary, never treated as instructions.

TR-SEC-012 — Strict LLM output-schema validation — reject, never coerce

Every field returned by a model call must pass both a type check and a range/shape check before use. A field that fails either check must be rejected, never silently coerced to a compatible type. Coercion can fail open: Python's bool("false") evaluates to True because any non-empty string is truthy, so a bare bool() cast on a model-returned string can flip a relevance or safety gate the wrong way. A missing optional field is a defined, valid state; a present field of the wrong type is not, and the two must not share a fallback path. Pairs with TR-GOV-001's single-source-of-truth convention — a strict parser for a given output schema is defined once and used by every caller of that boundary.

TR-SEC-015 — Graded outlet confidence never upgrades a TR-SEC-011 trust tier

Read the full file on GitHub · 25 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. 2d ago First seen · 25 lines · 641 tokens per session scan A e04355ac9de5

Subscribe to this mod's changes

prompt-injection is a cursor rule published in the GitHub repository onesimplecode/agent-engineering-standards (3 stars, last pushed 4d ago), licensed MIT. It adds 641 tokens to every session, about $0.0032 per session on Opus 5. 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-31.