python-integrity-failures

A security rule set for Python software and data handling based on OWASP A08, the category covering software and data integrity failures.

In plain words
What is it for?
It is for detecting uses of unsafe Python deserialization methods such as pickle, marshal, shelve, and unsafe yaml.load calls.
Why use it?
It warns about unsafe ways of loading serialized data that could let malicious input affect an application.

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/abderrahimghazali/cursor-rules/python-integrity-failures
Clone the repo
git clone --depth 1 https://github.com/abderrahimghazali/cursor-rules

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 3,251 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 3 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.00000 $0.03251
Opus 5 $0.00000 $0.01625
Sonnet 5 $0.00000 $0.00650
Haiku 4.5 $0.00000 $0.00325

Measured yesterday against content hash 6bc140c1996f, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

python-integrity-failures scanned grade A with 3 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 yesterday.

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.

Unrestricted tool accesslowExcessive agency

A wildcard tool grant or "run any command" leaves no least-privilege boundary at all.

message: "Insecure use of eval() or exec() detected. These functions can execute arbitrary code and should never be used with untrusted input."

Downgraded: this mod is about security review, or the phrase is quoted, so it is likely naming the pattern rather than instructing it.

Makes network callslowCapability

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

- pattern: "urllib\\.request\\.urlretrieve\\(|requests\\.get\\([^)]*\\.exe['\"]\\)|requests\\.get\\([^)]*\\.zip['\"]\\)|requests\\.get\\([^)]*\\.tar\\.gz['\"]\\)"

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

return subprocess.run(cmd, shell=False, capture_output=True, text=True)
.cursor/rules/python-integrity-failures.mdc · 361 lines

How it starts

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

Python Software and Data Integrity Failures Standards (OWASP A08:2021)

This rule enforces security best practices to prevent software and data integrity failures in Python applications, as defined in OWASP Top 10:2021-A08.

actions:

  • type: enforce conditions:

    Pattern 1: Insecure deserialization with pickle

    • pattern: "pickle\.loads\(|pickle\.load\(|cPickle\.loads\(|cPickle\.load\(" message: "Insecure deserialization detected with pickle. Pickle is not secure against maliciously constructed data and should not be used with untrusted input."

    Pattern 2: Insecure deserialization with yaml.load

    • pattern: "yaml\.load\([^,)]+\)|yaml\.load\([^,)]+,\s*Loader=yaml\.Loader\)" message: "Insecure deserialization detected with yaml.load(). Use yaml.safe_load() instead for untrusted input."

    Pattern 3: Insecure deserialization with marshal

    • pattern: "marshal\.loads\(|marshal\.load\(" message: "Insecure deserialization detected with marshal. Marshal is not secure against maliciously constructed data."

    Pattern 4: Insecure deserialization with shelve

    • pattern: "shelve\.open\(" message: "Potentially insecure deserialization with shelve detected. Shelve uses pickle internally and is not secure against malicious data."

    Pattern 5: Insecure use of eval or exec

    • pattern: "eval\(|exec\(|compile\([^,]+,\s*['"][^'"]+['"]\s*,\s*['"]exec['"]\)" message: "Insecure use of eval() or exec() detected. These functions can execute arbitrary code and should never be used with untrusted input."

    Pattern 6: Missing integrity verification for downloads

    • pattern: "urllib\.request\.urlretrieve\(|requests\.get\([^)]\.exe['"]\)|requests\.get\([^)]\.zip['"]\)|requests\.get\([^)]*\.tar\.gz['"]\)" message: "File download without integrity verification detected. Always verify the integrity of downloaded files using checksums or digital signatures."

    Pattern 7: Insecure package installation

    • pattern: "pip\s+install\s+[^-]|subprocess\.(?:call|run|Popen)\(['"]pip\s+install" message: "Insecure package installation detected. Specify package versions and consider using hash verification for pip installations."

    Pattern 8: Missing integrity checks for configuration

    • pattern: "config\.read\(|json\.loads?\(|yaml\.safe_load\(|toml\.loads?\(" message: "Configuration loading detected. Ensure integrity verification for configuration files, especially in production environments."

    Pattern 9: Insecure temporary file creation

    • pattern: "tempfile\.mktemp\(|os\.tempnam\(|os\.tmpnam\(" message: "Insecure temporary file creation detected. Use tempfile.mkstemp() or tempfile.TemporaryFile() instead to avoid race conditions."

    Pattern 10: Insecure file operations with untrusted paths

    • pattern: "open\([^,)]+\+\srequest\.|open\([^,)]+\+\suser_|open\([^,)]+\+\s*input\(" message: "Potentially insecure file operation with user-controlled path detected. Validate and sanitize file paths from untrusted sources."

    Pattern 11: Missing integrity checks for updates

    • pattern: "auto_update|self_update|check_for_updates" message: "Update mechanism detected. Ensure proper integrity verification for software updates using digital signatures or secure checksums."

    Pattern 12: Insecure plugin or extension loading

    • pattern: "importlib\.import_module\(|import\(|load_plugin|load_extension|load_module" message: "Dynamic module loading detected. Implement integrity checks and validation before loading external modules or plugins."

Read the full file on GitHub · 361 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. yesterday First seen · 361 lines · 3,251 tokens per session scan A 6bc140c1996f

Subscribe to this mod's changes

python-integrity-failures is a cursor rule published in the GitHub repository abderrahimghazali/cursor-rules (2 stars, last pushed 1y ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 3,251 tokens. A static security scan graded it A with 3 findings (unrestricted tool access, makes network calls, runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.