python-broken-access-control

python-broken-access-control is a cursor rule for Cursor from ivangrynenko/cursorrules. It costs 0 tokens per session (1,829 once invoked), scanned A, original, MIT.

A set of checks for Python web code that looks for missing permission checks on Flask routes and Django views, plus possible insecure direct object references. An insecure direct object reference occurs when a user can access a record simply by changing its ID.

In plain words
What is it for?
Use it to review Flask routes, Django class-based views, and code that loads database objects from request data.
Why use it?
It helps prevent users from viewing or changing pages and records they are not allowed to access.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it to review Flask routes, Django class-based views, and code that loads database objects from request data.

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

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

Your own site · 80×15
<a href="https://agentmods.dev/rules/ivangrynenko/cursorrules/python-broken-access-control"><img src="https://agentmods.dev/badge/rules/ivangrynenko/cursorrules/python-broken-access-control.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 1,829 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.01829
Opus 5.5 $0.00000 $0.00732
Sonnet 5.5 $0.00000 $0.00366
Haiku 4.5 $0.00000 $0.00183

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

Security

Grade A, and why

python-broken-access-control 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-broken-access-control.mdc · 149 lines

How it starts

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

Python Broken Access Control Security Standards (OWASP A01:2021)

This rule enforces security best practices to prevent broken access control vulnerabilities in Python applications, as defined in OWASP Top 10:2021-A01.

actions:

  • type: enforce conditions:

    Pattern 1: Missing access control in Flask routes

    • pattern: "@(app|blueprint)\.route\([^)]\)\s\n\sdef\s+[a-zA-Z0-9_]+\([^)]\):\s*(?![^#]*@login_required|[^#]*current_user\.|[^#]*session\[)" message: "Flask route lacks access control. Consider using @login_required or checking user permissions within the function."

    Pattern 2: Missing access control in Django views

    • pattern: "class\s+[A-Za-z0-9_]+View\((?!LoginRequiredMixin|PermissionRequiredMixin|UserPassesTestMixin)[^)]*\):" message: "Django class-based view lacks access control mixins. Consider using LoginRequiredMixin, PermissionRequiredMixin, or UserPassesTestMixin."

    Pattern 3: Insecure direct object reference

    • pattern: "(get|filter|find)_by_id\(\srequest\.(GET|POST|args|form|json)\[['"][^'"]+['"]\]\s\)" message: "Potential insecure direct object reference (IDOR). Validate that the current user has permission to access this object."

    Pattern 4: Hardcoded role checks

    • pattern: "if\s+user\.role\s*==\s*['"]admin['"]|if\s+user\.(is_staff|is_superuser)\s*:" message: "Hardcoded role checks can be fragile. Consider using a permission system or role-based access control framework."

    Pattern 5: Missing authorization in FastAPI

    • pattern: "@(app|router)\.([a-z]+)\([^)]\)\s\n\s*(?:async\s+)?def\s+[a-zA-Z0-9_]+\([^)]\):\s(?![^#]*Depends\(|[^#]*Security\(|[^#]*HTTPBearer\()" message: "FastAPI endpoint lacks security dependencies. Consider using Depends(get_current_user) or similar security dependencies."

    Pattern 6: Bypassing access control with admin flags

    • pattern: "if\s+request\.(GET|POST|args|form|json)\[['"]admin['"]\]|if\s+request\.(GET|POST|args|form|json)\[['"]debug['"]\]" message: "Dangerous admin/debug flags in request parameters could bypass access control. Remove or secure these backdoors."

    Pattern 7: Insecure use of eval or exec with user input

    • pattern: "eval\(|exec\(.*request\." message: "Extremely dangerous use of eval() or exec() with user input can lead to code execution. Avoid these functions entirely."

    Pattern 8: Missing access control in API endpoints

    • pattern: "@api_view\(|@api\.route\(|@app\.api_route\(" message: "API endpoint may lack access control. Ensure proper authentication and authorization checks are implemented."

    Pattern 9: Insecure Flask session usage

    • pattern: "session\[['"][^'"]+['"]\]\s*=\s*request\." message: "Setting session variables directly from request data without validation can lead to session-based access control bypasses."

    Pattern 10: Missing CSRF protection

    • pattern: "class\s+[A-Za-z0-9_]+Form\((?!.csrf).\):|@csrf_exempt" message: "Form or view appears to be missing CSRF protection. Ensure CSRF tokens are properly implemented."
  • type: suggest message: | Python Access Control Best Practices:

    1. Framework-Specific Controls:
      • Django: Use built-in authentication and permission decorators/mixins
        • @login_required, LoginRequiredMixin
        • @permission_required, PermissionRequiredMixin
        • UserPassesTestMixin for custom permission logic
      • Flask: Use Flask-Login or similar extensions
        • @login_required decorator
        • current_user.is_authenticated checks
        • Role-based access control with Flask-Principal
      • FastAPI: Use dependency injection for security
        • Depends(get_current_user) pattern
        • OAuth2 with Security(oauth2_scheme)
        • JWT validation middleware

Read the full file on GitHub · 149 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 · 149 lines · 1,829 tokens per session scan A 534567c43798

Subscribe to this mod's changes

python-broken-access-control 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 1,829 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.