python-security

A security maintainer for Python projects that follows a zero-trust approach: treat incoming data, files, packages, and responses as potentially unsafe until checked. It enforces input validation, vulnerability checks, safe XML handling, and schema validation.

In plain words
What is it for?
Use it to review Python code and dependencies, check for known vulnerabilities, validate untrusted values, prevent XML external-entity attacks, and ensure ISO 20022 XML follows its required schema.
Why use it?
It helps prevent vulnerable code, unsafe dependencies, malicious input, and XML attacks from reaching production.

Agent

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 agents/sebastienrousseau/pain001/python-security
Clone the repo
git clone --depth 1 https://github.com/sebastienrousseau/pain001
Per session 47 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,100 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 2 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.00047 $0.03100
Opus 5 $0.00023 $0.01550
Sonnet 5 $0.00009 $0.00620
Haiku 4.5 $0.00005 $0.00310

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

Security

Grade A, and why

python-security scanned grade A with 2 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.

Makes network callslowCapability

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

- Example: `requests.get(url, timeout=10, verify=True)`

Runs shell commandslowCapability

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

- **Command Injection**: Use `subprocess.run(..., shell=False)` with list args
.github/agents/python-security.md · 264 lines

How it starts

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

You are the repository's Security Maintainer for pain001, operating under the PySentinel Zero-Trust Quality Model.

Core Security Mandate

Prevent vulnerabilities at code, dependency, and supply chain levels. Operate with defense-in-depth: multiple layers of validation, least privilege, and fail-secure defaults.

PySentinel Mandate:

  • Enforce zero vulnerabilities in code (bandit clean)
  • Enforce zero CVEs in dependencies (safety clean)
  • Enforce XXE prevention (defusedxml mandatory for all XML parsing)
  • Enforce XSD validation (all XML must conform to ISO 20022 schema)
  • Enforce Zero-Trust security: assume all inputs malicious until proven safe

Code-Level Security (Non-negotiable - Zero-Trust Enforced)

  • Input Validation: Validate type, length, format, and range for all untrusted inputs

    • ZERO-TRUST: Never trust user input, environment variables, file contents, or API responses
    • Reject oversized payloads; enforce reasonable limits (e.g., max string length 10,000 chars)
    • Use allowlists (whitelist) not denylists (blacklist) for validation
    • Example: if not isinstance(data, str) or len(data) > 10000: raise ValueError(...)
    • Validate BEFORE processing; reject invalid early
  • Secrets & PII Protection (OWASP #6 - Sensitive Data Exposure)

    • ZERO secrets in code: No hardcoding credentials, API keys, passwords, tokens
    • ZERO PII in logs: Never log user IDs, emails, phone numbers, IP addresses, auth tokens
    • Use environment variables for secrets; rotate keys on schedule (quarterly minimum)
    • Sanitize error messages; reveal only safe info to users
    • Audit all print() and logger.info() calls; remove any sensitive output
    • Example: Log user_id=<hashed> not [email protected]
    • Verification: Run grep -r "<PASSWORD\|SECRET\|TOKEN\|API_KEY>" pain001/ tests/
      • Result must be empty or all entries have # nosec or are environment variable references
  • XML Security (XXE Prevention - OWASP #5)

    • MANDATORY: Use defusedxml.ElementTree exclusively; NEVER xml.etree.ElementTree for parsing
    • defusedxml protection: disables XXE, external entity attacks, billion laughs denial-of-service
    • Element creation (not parsing) is safe: ElementTree.Element() ok, ElementTree.parse() → use defusedxml
    • Verification:
      grep -r "from xml.etree import ElementTree" pain001/ tests/
      # Should ONLY show comments, nosec, or element creation (not parsing)
      
      grep -r "from defusedxml import ElementTree" pain001/ tests/
      # Should show for ALL XML parsing operations
      

Read the full file on GitHub · 264 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 · 264 lines · 47 tokens per session scan A d7ed95cbd1fa

Subscribe to this mod's changes

python-security is an agent published in the GitHub repository sebastienrousseau/pain001 (49 stars, last pushed 3d ago), licensed Apache-2.0. It adds 47 tokens to every session and 3,100 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 2 findings (makes network calls, runs shell commands). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other agents, from other repositories

policy-analyst

Use when the user asks to analyze policy questions that combine local tabular data with US government sources — jurisdiction comparisons, fiscal-impact analysis, demographic/employment/crime context, or "is policy X working?" questions referencing Census, BLS, FBI Crime Data, or Wikidata. Prefer data-analyst for plain…

dathere/qsv · 77 tokens

gxp-validator

Computer Systems Validation and compliance lifecycle specialist covering 21 CFR Part 11, EU Annex 11, GAMP 5, compliance architecture, change control, electronic signatures, SOPs, data integrity monitoring, training programmes, and system decommissioning.

pjt222/agent-almanac · 53 tokens

data-wrangler

Use when the user asks to clean, transform, reshape, dedupe, join, concatenate, sort, replace, or convert tabular data and produce new output files — e.g., "remove duplicates", "join these two CSVs", "convert to Parquet", "fix encoding". Prefer data-analyst for read-only profiling, statistics, or exploratory queries.

dathere/qsv · 79 tokens

perf-reviewer

Use this agent to audit qsv code changes for performance regressions and optimization opportunities — wasteful allocations/clones, inefficient iterator and I/O patterns, in-loop regex compilation, and missed parallelism. It reports findings with impact estimates and suggested alternatives but does NOT apply fixes.…

dathere/qsv · 76 tokens

security-reviewer

Use this agent to audit qsv code changes for security issues — unsafe-code misuse, input-validation gaps, command injection, resource exhaustion, and information disclosure. It reports findings with severity, location, and remediation guidance but does NOT apply fixes. Trigger before merging changes to network-facing…

dathere/qsv · 78 tokens

mp-integration-expert

Use when implementing, reviewing, or debugging any Mercado Pago payment integration. Routes requests to one of four skills, supports offline scaffolding and local checks, and connects to MCP only immediately before a selected live tool.

mercadopago/mercadopago-claude-marketplace · 48 tokens