python-insecure-design

python-insecure-design is a cursor rule for Cursor from ivangrynenko/cursorrules. It costs 0 tokens per session (2,425 once invoked), scanned A, original, MIT.

A set of checks for insecure design patterns in Python applications, such as missing input validation, hardcoded business rules, missing rate limits, and unsafe default settings. Rate limiting restricts how often an endpoint can be called.

In plain words
What is it for?
Use it when reviewing Python functions, API endpoints, configuration, and application rules.
Why use it?
It catches design choices that can allow invalid data, abuse, difficult-to-change rules, or unsafe deployments before they become security problems.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when reviewing Python functions, API endpoints, configuration, and application rules.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/ivangrynenko/cursorrules/python-insecure-design
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.

Clone the repo
git clone --depth 1 https://github.com/ivangrynenko/cursorrules

Made for: Cursor.

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 python-insecure-design

README.md
[![agentmods](https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/python-insecure-design/github.svg)](https://agentmods.dev/rules/ivangrynenko/cursorrules/python-insecure-design)
Your own site
<a href="https://agentmods.dev/rules/ivangrynenko/cursorrules/python-insecure-design"><img src="https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/python-insecure-design/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 python-insecure-design

Your own site · 80×15
<a href="https://agentmods.dev/rules/ivangrynenko/cursorrules/python-insecure-design"><img src="https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/python-insecure-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,425 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. 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.00000 $0.02425
Opus 5.5 $0.00000 $0.00970
Sonnet 5.5 $0.00000 $0.00485
Haiku 4.5 $0.00000 $0.00243

Measured 1mo ago against content hash 6b510f95ccdb, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

python-insecure-design 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 1mo 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.

Origin

Copies of this mod

1 near-identical copy found in the catalogue:

.cursor/rules/python-insecure-design.mdc · 252 lines

How it starts

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

Python Insecure Design Security Standards (OWASP A04:2021)

This rule enforces security best practices to prevent insecure design vulnerabilities in Python applications, as defined in OWASP Top 10:2021-A04.

actions:

  • type: enforce conditions:

    Pattern 1: Lack of input validation

    • pattern: "def\s+[a-zA-Z0-9_]+\([^)]\):\s(?![^#]*validate|[^#]*clean|[^#]*sanitize|[^#]*check|[^#]*is_valid)" message: "Function lacks input validation. Consider implementing validation for all user-supplied inputs."

    Pattern 2: Hardcoded business rules

    • pattern: "if\s+[a-zA-Z0-9_]+\s*(==|!=|>|<|>=|<=)\s*['"][^'"]+['"]:" message: "Hardcoded business rules detected. Consider using configuration files or database-driven rules for better maintainability."

    Pattern 3: Lack of rate limiting

    • pattern: "@(app|api|route|blueprint)\.(get|post|put|delete|patch)\([^)]\)\s\n\s*(?![^#]*rate_limit|[^#]*throttle|[^#]*limiter)" message: "API endpoint lacks rate limiting. Consider implementing rate limiting to prevent abuse."

    Pattern 4: Insecure default configurations

    • pattern: "DEBUG\s*=\sTrue|DEVELOPMENT\s=\sTrue|TESTING\s=\s*True" message: "Insecure default configuration detected. Ensure debug/development modes are disabled in production."

    Pattern 5: Lack of error handling

    • pattern: "(?<!try:\s*\n)[^#]\n\s(?!except|finally)" message: "Consider implementing proper error handling with try-except blocks for operations that might fail."

    Pattern 6: Insecure direct object references

    • pattern: "get_object_or_404\(\s*[^,]+,\spk\s=\srequest\.(GET|POST|args|form|json)\[['"][^'"]+['"]\]\s\)|get\(\sid\s=\s*request\.(GET|POST|args|form|json)" message: "Potential insecure direct object reference. Validate user's permission to access the requested object."

    Pattern 7: Missing authentication checks

    • pattern: "@(app|api|route|blueprint)\.(get|post|put|delete|patch)\([^)]\)\s\n\s*(?!.@login_required|.@auth\.login_required|.*@jwt_required|.*current_user|.*request\.user)" message: "Endpoint lacks authentication checks. Consider adding authentication requirements for sensitive operations."

    Pattern 8: Lack of proper logging

    • pattern: "except\s+[a-zA-Z0-9_]+\s*(?:as\s+[a-zA-Z0-9_]+)?:\s*(?!.*logger\.|.*logging\.|.*print)" message: "Exception caught without proper logging. Implement proper logging for exceptions to aid in debugging and monitoring."

    Pattern 9: Insecure file uploads

    • pattern: "request\.files\[['"][^'"]+['"]\]|FileField\(|FileStorage\(" message: "File upload functionality detected. Ensure proper validation of file types, sizes, and implement virus scanning if applicable."

    Pattern 10: Lack of security headers

    • pattern: "response\.(headers|set_header)\([^)]\)|return\s+Response\([^)]\)|return\s+make_response\([^)]*\)" message: "Consider adding security headers (Content-Security-Policy, X-Content-Type-Options, etc.) to HTTP responses."
  • type: suggest message: | Python Secure Design Best Practices:

    1. Implement Defense in Depth:

      • Layer security controls throughout your application
      • Don't rely on a single security mechanism
      • Assume that each security layer can be bypassed
    2. Use Secure Defaults:

      • Start with secure configurations by default
      • Require explicit opt-in for less secure options
      • Example for Flask:
        app.config.update(
            SESSION_COOKIE_SECURE=True,
            SESSION_COOKIE_HTTPONLY=True,
            SESSION_COOKIE_SAMESITE='Lax',
            PERMANENT_SESSION_LIFETIME=timedelta(hours=1)
        )
        

Read the full file on GitHub · 252 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. 1mo ago First seen · 252 lines · 2,425 tokens per session scan A 6b510f95ccdb

Subscribe to this mod's changes

python-insecure-design is a cursor rule published in the GitHub repository ivangrynenko/cursorrules (88 stars, last pushed 11mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,425 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-09-03.