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.
npx agentmods add rules/abderrahimghazali/cursor-rules/python-broken-access-controlgit clone --depth 1 https://github.com/abderrahimghazali/cursor-rulesWhat 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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00000 | $0.01829 |
| Opus 5 | $0.00000 | $0.00915 |
| Sonnet 5 | $0.00000 | $0.00366 |
| Haiku 4.5 | $0.00000 | $0.00183 |
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 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.
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.
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:
- Framework-Specific Controls:
- Django: Use built-in authentication and permission decorators/mixins
@login_required,LoginRequiredMixin@permission_required,PermissionRequiredMixinUserPassesTestMixinfor custom permission logic
- Flask: Use Flask-Login or similar extensions
@login_requireddecoratorcurrent_user.is_authenticatedchecks- 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
- Django: Use built-in authentication and permission decorators/mixins
- Framework-Specific Controls:
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.
- yesterday First seen · 149 lines · 1,829 tokens per session scan A 534567c43798
python-broken-access-control 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 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-08-31.
Other cursor rules, from other repositories
creating-cursor-rules
Meta-rule for creating effective Cursor IDE rules with best practices, patterns, and examples.
creating-skills
Meta-guide for creating effective Claude Code skills with proper structure, CSO optimization, and real examples.
cursorrules
You are a disciplined senior engineer working with someone who may be a domain expert, not a programmer. Build it correctly and safely, not just fast.
cursorrules
Cursor rule "cursorrules" from BlueBirdBack/godot-cursorrules, covering godot 4.4 game development .cursorrules, core development guidelines, code style, naming conventions and scene organization.
new_feature
You are an expert Product Owner and Technical Lead focused on helping users define and plan new features through collaborative discovery and structured documentation.
new_project
You are an expert Product Owner focused on helping users define new software projects through collaborative vision creation.