

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
123456# Python Broken Access Control Security Standards (OWASP A01:2021)78This rule enforces security best practices to prevent broken access control vulnerabilities in Python applications, as defined in OWASP Top 10:2021-A01.910<rule>11name: python_broken_access_control12description: Detect and prevent broken access control vulnerabilities in Python applications as defined in OWASP Top 10:2021-A0113filters:14 - type: file_extension15 pattern: "\\.(py)$"16 - type: file_path17 pattern: ".*"1819actions:20 - type: enforce21 conditions:22 # Pattern 1: Missing access control in Flask routes23 - pattern: "@(app|blueprint)\\.route\\([^)]*\\)\\s*\\n\\s*def\\s+[a-zA-Z0-9_]+\\([^)]*\\):\\s*(?![^#]*@login_required|[^#]*current_user\\.|[^#]*session\\[)"24 message: "Flask route lacks access control. Consider using @login_required or checking user permissions within the function."2526 # Pattern 2: Missing access control in Django views27 - pattern: "class\\s+[A-Za-z0-9_]+View\\((?!LoginRequiredMixin|PermissionRequiredMixin|UserPassesTestMixin)[^)]*\\):"28 message: "Django class-based view lacks access control mixins. Consider using LoginRequiredMixin, PermissionRequiredMixin, or UserPassesTestMixin."2930 # Pattern 3: Insecure direct object reference31 - pattern: "(get|filter|find)_by_id\\(\\s*request\\.(GET|POST|args|form|json)\\[['\"][^'\"]+['\"]\\]\\s*\\)"32 message: "Potential insecure direct object reference (IDOR). Validate that the current user has permission to access this object."3334 # Pattern 4: Hardcoded role checks35 - pattern: "if\\s+user\\.role\\s*==\\s*['\"]admin['\"]|if\\s+user\\.(is_staff|is_superuser)\\s*:"36 message: "Hardcoded role checks can be fragile. Consider using a permission system or role-based access control framework."3738 # Pattern 5: Missing authorization in FastAPI39 - pattern: "@(app|router)\\.([a-z]+)\\([^)]*\\)\\s*\\n\\s*(?:async\\s+)?def\\s+[a-zA-Z0-9_]+\\([^)]*\\):\\s*(?![^#]*Depends\\(|[^#]*Security\\(|[^#]*HTTPBearer\\()"40 message: "FastAPI endpoint lacks security dependencies. Consider using Depends(get_current_user) or similar security dependencies."4142 # Pattern 6: Bypassing access control with admin flags43 - pattern: "if\\s+request\\.(GET|POST|args|form|json)\\[['\"]admin['\"]\\]|if\\s+request\\.(GET|POST|args|form|json)\\[['\"]debug['\"]\\]"44 message: "Dangerous admin/debug flags in request parameters could bypass access control. Remove or secure these backdoors."4546 # Pattern 7: Insecure use of eval or exec with user input47 - pattern: "eval\\(|exec\\(.*request\\."48 message: "Extremely dangerous use of eval() or exec() with user input can lead to code execution. Avoid these functions entirely."4950 # Pattern 8: Missing access control in API endpoints51 - pattern: "@api_view\\(|@api\\.route\\(|@app\\.api_route\\("52 message: "API endpoint may lack access control. Ensure proper authentication and authorization checks are implemented."5354 # Pattern 9: Insecure Flask session usage55 - pattern: "session\\[['\"][^'\"]+['\"]\\]\\s*=\\s*request\\."56 message: "Setting session variables directly from request data without validation can lead to session-based access control bypasses."5758 # Pattern 10: Missing CSRF protection59 - pattern: "class\\s+[A-Za-z0-9_]+Form\\((?!.*csrf).*\\):|@csrf_exempt"60 message: "Form or view appears to be missing CSRF protection. Ensure CSRF tokens are properly implemented."6162 - type: suggest63 message: |64 **Python Access Control Best Practices:**6566 1. **Framework-Specific Controls:**67 - **Django**: Use built-in authentication and permission decorators/mixins68 - `@login_required`, `LoginRequiredMixin`69 - `@permission_required`, `PermissionRequiredMixin`70 - `UserPassesTestMixin` for custom permission logic71 - **Flask**: Use Flask-Login or similar extensions72 - `@login_required` decorator73 - `current_user.is_authenticated` checks74 - Role-based access control with Flask-Principal75 - **FastAPI**: Use dependency injection for security76 - `Depends(get_current_user)` pattern77 - OAuth2 with `Security(oauth2_scheme)`78 - JWT validation middleware7980 2. **General Access Control Principles:**81 - Implement access control at the server side, never rely on client-side checks82 - Use deny-by-default approach (whitelist vs blacklist)83 - Implement proper session management84 - Apply principle of least privilege85 - Use contextual access control (time, location, device-based restrictions when appropriate)8687 3. **Object-Level Authorization:**88 - Validate user has permission to access specific resources89 - Implement row-level security for database access90 - Use UUIDs instead of sequential IDs when possible91 - Always verify ownership or permission before allowing operations on objects9293 4. **API Security:**94 - Implement proper authentication for all API endpoints95 - Use token-based authentication with proper validation96 - Apply rate limiting to prevent brute force attacks97 - Implement proper CORS configuration98 - Log and monitor access control failures99100 5. **Testing Access Control:**101 - Write tests specifically for authorization logic102 - Test vertical access control (different permission levels)103 - Test horizontal access control (same permission level, different users)104 - Verify access control works after session timeout/expiration105106 - type: validate107 conditions:108 # Check 1: Proper Django permission usage109 - pattern: "@login_required|@permission_required|LoginRequiredMixin|PermissionRequiredMixin"110 message: "Using Django's built-in access control mechanisms."111112 # Check 2: Proper Flask authentication113 - pattern: "@login_required|current_user\\.is_authenticated|@auth\\.login_required"114 message: "Implementing proper Flask authentication checks."115116 # Check 3: Object-level permission checks117 - pattern: "\\.has_permission\\(|has_object_permission\\(|can_view\\(|can_edit\\("118 message: "Implementing object-level permission checks."119120 # Check 4: FastAPI security dependencies121 - pattern: "Depends\\(get_current_user\\)|Security\\(|HTTPBearer\\("122 message: "Using FastAPI's security dependency injection."123124metadata:125 priority: 90126 version: "1.0"127 tags:128 - python129 - security130 - access_control131 - owasp132 - language:python133 - category:security134 - subcategory:authorisation135 - subcategory:access-control136 - standard:owasp-top10137 - risk:a01-broken-access-control138 - framework:django139 - framework:flask140 - framework:fastapi141 references:142 - https://owasp.org/Top10/A01_2021-Broken_Access_Control/143 - https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html144 - https://cheatsheetseries.owasp.org/cheatsheets/Access_Control_Cheat_Sheet.html145 - https://docs.djangoproject.com/en/stable/topics/auth/default/146 - https://flask-login.readthedocs.io/en/latest/147 - https://fastapi.tiangolo.com/tutorial/security/148 - https://cheatsheetseries.owasp.org/cheatsheets/Access_Control_Cheat_Sheet.html149</rule>
One repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| ivangrynenko/cursorrules.cursor/rules/cursor-rules.mdc · 86 | Cursor rules | teststylearchgit+2 | 77/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-steps.mdc · 86 | Cursor rules | lint-formatstyleperformanceagent-behaviour | 42/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/php-drupal-development-standards.mdc · 86 | Cursor rules | no sections | 34/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-insecure-design.mdc · 86 | Cursor rules | no sections | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-cryptographic-failures.mdc · 86 | Cursor rules | security | 40/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/python-injection.mdc · 86 | Cursor rules | styledo-not | 51/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/node-dependencies.mdc · 86 | Cursor rules | no sections | 16/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/behat-ai-guide.mdc · 86 | Cursor rules | testtesting-strategydo-not | 45/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/new-pull-request.mdc · 86 | Cursor rules | archtesting-strategygitsecurity+3 | 58/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/accessibility-standards.mdc · 86 | Cursor rules | ui | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/api-standards.mdc · 86 | Cursor rules | api | 44/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/build-optimization.mdc · 86 | Cursor rules | build | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/code-generation-standards.mdc · 86 | Cursor rules | lint-formatstyletypesdocs | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/confluence-editing-standards.mdc · 86 | Cursor rules | stylearchsecuritydeployment | 60/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/debugging-standards.mdc · 86 | Cursor rules | no sections | 30/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/docker-compose-standards.mdc · 86 | Cursor rules | style | 62/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-authentication-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-broken-access-control.mdc · 86 | Cursor rules | stylesecurity | 52/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-cryptographic-failures.mdc · 86 | Cursor rules | security | 48/100 | 14 days ago | |
| ivangrynenko/cursorrules.cursor/rules/drupal-database-standards.mdc · 86 | Cursor rules | database | 30/100 | 14 days ago |
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 14 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 14 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/gh-task-plan.mdc · 1.4k | Cursor rules | teststylearchtypes+2 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| skillrecordings/egghead-next.cursor/rules/project-update-user-rules.mdc · 1.4k | Cursor rules | buildtestlint-formatstyle+7 | 96/100 | 14 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/proto.mdc · 126 | Cursor rules | buildlint-formatstylearch+3 | 96/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/ivangrynenko-cursorrules-cursor-rules-python-broken-access-control)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.
Directory