About this skill
This skill equips an AI agent with a structured methodology and specific focus areas required to conduct comprehensive security reviews of Django applications. It targets common authorization vulnerabilities, particularly Insecure Direct Object References (IDOR) and general access control flaws. The skill guides the agent to investigate Django views, Django REST Framework (DRF) viewsets, ORM queries, and any Python/Django code dealing with user authentication and authorization. It emphasizes an 'Investigation Over Pattern Matching' philosophy, prompting the agent to critically analyze whether 'User A can access, modify, or delete User B's data,' drawing inspiration from OWASP Cheat Sheet Series principles.
Best use case
Automated or semi-automated security auditing of Django and Django REST Framework applications; identifying and reporting potential IDOR vulnerabilities; assessing the robustness of access control implementations in Django projects; assisting developers in pre-deployment security checks for their Django code.
django-access-review
A detailed report identifying potential access control vulnerabilities, specifically IDORs, within the reviewed Django code components; contextual explanations of the identified vulnerabilities, including affected code snippets; actionable recommendations for remediating the security flaws, often referencing best practices; an assessment of whether specific user roles or tenants can improperly access or modify data belonging to others.
Practical example
Example input
Analyze the `PostDetailView` and `CommentViewSet` in `blog/views.py` for any IDOR or access control issues. Focus on ensuring users can only edit or delete their own posts/comments.
Example output
```json
{
"review_summary": "Access control and IDOR review for `PostDetailView` and `CommentViewSet`",
"findings": [
{
"component": "PostDetailView",
"vulnerability_type": "IDOR (Insecure Direct Object Reference)",
"description": "The `PostDetailView` allows any authenticated user to retrieve, update, or delete any post by ID, without verifying ownership. For example, a user can modify another user's post by navigating to `/posts/<other_user_post_id>/edit/`.",
"affected_code_snippets": [
"class PostDetailView(UpdateView):",
" model = Post",
" fields = ['title', 'content']",
" template_name = 'blog/post_detail.html'"
],
"recommendation": "Implement `UserPassesTestMixin` or override `get_queryset` to filter posts by `request.user`. Example: `queryset = Post.objects.filter(author=request.user)` for update/delete actions.",
"severity": "High",
"references": ["OWASP IDOR Cheat Sheet"]
},
{
"component": "CommentViewSet",
"vulnerability_type": "Missing Object-Level Permissions",
"description": "The `CommentViewSet` allows any authenticated user to delete comments, even if they are not the author of the comment. The `destroy` action lacks an ownership check.",
"affected_code_snippets": [
"class CommentViewSet(viewsets.ModelViewSet):",
" queryset = Comment.objects.all()",
" serializer_class = CommentSerializer",
" permission_classes = [IsAuthenticated]"
],
"recommendation": "Add a custom permission class, e.g., `IsOwnerOrReadOnly`, that checks `obj.author == request.user` for `PUT`, `PATCH`, and `DELETE` methods, and apply it to the `CommentViewSet`.",
"severity": "Medium",
"references": ["DRF Permissions Documentation"]
}
],
"overall_assessment": "Potential IDORs and missing object-level permissions identified. Critical to implement proper ownership checks for all sensitive operations in both views."
}
```When to use this skill
- When performing a security review of a Django application's codebase; when auditing Django views, DRF viewsets, or custom authorization logic; when an agent is prompted with keywords like 'IDOR,' 'access control,' 'authorization,' 'Django permissions,' 'object permissions,' or 'tenant isolation'; during code review phases focused on security and data segregation.
When not to use this skill
- For security reviews of non-Django applications; for general code quality checks unrelated to authorization or access control; as a substitute for professional penetration testing (this skill assists in finding *potential* issues for human review); for generating exploits or malicious payloads.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/django-access-review/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How django-access-review Compares
| Feature / Agent | django-access-review | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
django-access-review
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
ChatGPT vs Claude for Agent Skills
Compare ChatGPT and Claude for AI agent skills across coding, writing, research, and reusable workflow execution.
SKILL.md Source
---
name: django-access-review
description: Django access control and IDOR security review. Use when reviewing Django views, DRF viewsets, ORM queries, or any Python/Django code handling user authorization. Trigger keywords: "IDOR", "access control", "authorization", "Django permissions", "object permissions", "tenant...
--- LICENSE
---
<!--
Reference material based on OWASP Cheat Sheet Series (CC BY-SA 4.0)
https://cheatsheetseries.owasp.org/
-->
# Django Access Control & IDOR Review
Find access control vulnerabilities by investigating how the codebase answers one question:
**Can User A access, modify, or delete User B's data?**
## When to Use
- You need to review Django or DRF code for access control gaps, IDOR risk, or object-level authorization failures.
- The task involves confirming whether one user can access, modify, or delete another user's data.
- You want an investigation-driven authorization review instead of generic pattern matching.
## Philosophy: Investigation Over Pattern Matching
Do NOT scan for predefined vulnerable patterns. Instead:
1. **Understand** how authorization works in THIS codebase
2. **Ask questions** about specific data flows
3. **Trace code** to find where (or if) access checks happen
4. **Report** only what you've confirmed through investigation
Every codebase implements authorization differently. Your job is to understand this specific implementation, then find gaps.
---
## Phase 1: Understand the Authorization Model
Before looking for bugs, answer these questions about the codebase:
### How is authorization enforced?
Research the codebase to find:
```
□ Where are permission checks implemented?
- Decorators? (@login_required, @permission_required, custom?)
- Middleware? (TenantMiddleware, AuthorizationMiddleware?)
- Base classes? (BaseAPIView, TenantScopedViewSet?)
- Permission classes? (DRF permission_classes?)
- Custom mixins? (OwnershipMixin, TenantMixin?)
□ How are queries scoped?
- Custom managers? (TenantManager, UserScopedManager?)
- get_queryset() overrides?
- Middleware that sets query context?
□ What's the ownership model?
- Single user ownership? (document.owner_id)
- Organization/tenant ownership? (document.organization_id)
- Hierarchical? (org -> team -> user -> resource)
- Role-based within context? (org admin vs member)
```
### Investigation commands
```bash
# Find how auth is typically done
grep -rn "permission_classes\|@login_required\|@permission_required" --include="*.py" | head -20
# Find base classes that views inherit from
grep -rn "class Base.*View\|class.*Mixin.*:" --include="*.py" | head -20
# Find custom managers
grep -rn "class.*Manager\|def get_queryset" --include="*.py" | head -20
# Find ownership fields on models
grep -rn "owner\|user_id\|organization\|tenant" --include="models.py" | head -30
```
**Do not proceed until you understand the authorization model.**
---
## Phase 2: Map the Attack Surface
Identify endpoints that handle user-specific data:
### What resources exist?
```
□ What models contain user data?
□ Which have ownership fields (owner_id, user_id, organization_id)?
□ Which are accessed via ID in URLs or request bodies?
```
### What operations are exposed?
For each resource, map:
- List endpoints - what data is returned?
- Detail/retrieve endpoints - how is the object fetched?
- Create endpoints - who sets the owner?
- Update endpoints - can users modify others' data?
- Delete endpoints - can users delete others' data?
- Custom actions - what do they access?
---
## Phase 3: Ask Questions and Investigate
For each endpoint that handles user data, ask:
### The Core Question
**"If I'm User A and I know the ID of User B's resource, can I access it?"**
Trace the code to answer this:
```
1. Where does the resource ID enter the system?
- URL path: /api/documents/{id}/
- Query param: ?document_id=123
- Request body: {"document_id": 123}
2. Where is that ID used to fetch data?
- Find the ORM query or database call
3. Between (1) and (2), what checks exist?
- Is the query scoped to current user?
- Is there an explicit ownership check?
- Is there a permission check on the object?
- Does a base class or mixin enforce access?
4. If you can't find a check, is there one you missed?
- Check parent classes
- Check middleware
- Check managers
- Check decorators at URL level
```
### Follow-Up Questions
```
□ For list endpoints: Does the query filter to user's data, or return everything?
□ For create endpoints: Who sets the owner - the server or the request?
□ For bulk operations: Are they scoped to user's data?
□ For related resources: If I can access a document, can I access its comments?
What if the document belongs to someone else?
□ For tenant/org resources: Can User in Org A access Org B's data by changing
the org_id in the URL?
```
---
## Phase 4: Trace Specific Flows
Pick a concrete endpoint and trace it completely.
### Example Investigation
```
Endpoint: GET /api/documents/{pk}/
1. Find the view handling this URL
→ DocumentViewSet.retrieve() in api/views.py
2. Check what DocumentViewSet inherits from
→ class DocumentViewSet(viewsets.ModelViewSet)
→ No custom base class with authorization
3. Check permission_classes
→ permission_classes = [IsAuthenticated]
→ Only checks login, not ownership
4. Check get_queryset()
→ def get_queryset(self):
→ return Document.objects.all()
→ Returns ALL documents!
5. Check for has_object_permission()
→ Not implemented
6. Check retrieve() method
→ Uses default, which calls get_object()
→ get_object() uses get_queryset(), which returns all
7. Conclusion: IDOR - Any authenticated user can access any document
```
### What to look for when tracing
```
Potential gap indicators (investigate further, don't auto-flag):
- get_queryset() returns .all() or filters without user
- Direct Model.objects.get(pk=pk) without ownership in query
- ID comes from request body for sensitive operations
- Permission class checks auth but not ownership
- No has_object_permission() and queryset isn't scoped
Likely safe patterns (but verify the implementation):
- get_queryset() filters by request.user or user's org
- Custom permission class with has_object_permission()
- Base class that enforces scoping
- Manager that auto-filters
```
---
## Phase 5: Report Findings
Only report issues you've confirmed through investigation.
### Confidence Levels
| Level | Meaning | Action |
|-------|---------|--------|
| **HIGH** | Traced the flow, confirmed no check exists | Report with evidence |
| **MEDIUM** | Check may exist but couldn't confirm | Note for manual verification |
| **LOW** | Theoretical, likely mitigated | Do not report |
### Suggested Fixes Must Enforce, Not Document
**Bad fix**: Adding a comment saying "caller must validate permissions"
**Good fix**: Adding code that actually validates permissions
A comment or docstring does not enforce authorization. Your suggested fix must include actual code that:
- Validates the user has permission before proceeding
- Raises an exception or returns an error if unauthorized
- Makes unauthorized access impossible, not just discouraged
Example of a BAD fix suggestion:
```python
def get_resource(resource_id):
# IMPORTANT: Caller must ensure user has access to this resource
return Resource.objects.get(pk=resource_id)
```
Example of a GOOD fix suggestion:
```python
def get_resource(resource_id, user):
resource = Resource.objects.get(pk=resource_id)
if resource.owner_id != user.id:
raise PermissionDenied("Access denied")
return resource
```
If you can't determine the right enforcement mechanism, say so - but never suggest documentation as the fix.
### Report Format
```markdown
## Access Control Review: [Component]
### Authorization Model
[Brief description of how this codebase handles authorization]
### Findings
#### [IDOR-001] [Title] (Severity: High/Medium)
- **Location**: `path/to/file.py:123`
- **Confidence**: High - confirmed through code tracing
- **The Question**: Can User A access User B's documents?
- **Investigation**:
1. Traced GET /api/documents/{pk}/ to DocumentViewSet
2. Checked get_queryset() - returns Document.objects.all()
3. Checked permission_classes - only IsAuthenticated
4. Checked for has_object_permission() - not implemented
5. Verified no relevant middleware or base class checks
- **Evidence**: [Code snippet showing the gap]
- **Impact**: Any authenticated user can read any document by ID
- **Suggested Fix**: [Code that enforces authorization - NOT a comment]
### Needs Manual Verification
[Issues where authorization exists but couldn't confirm effectiveness]
### Areas Not Reviewed
[Endpoints or flows not covered in this review]
```
---
## Common Django Authorization Patterns
These are patterns you might find - not a checklist to match against.
### Query Scoping
```python
# Scoped to user
Document.objects.filter(owner=request.user)
# Scoped to organization
Document.objects.filter(organization=request.user.organization)
# Using a custom manager
Document.objects.for_user(request.user) # Investigate what this does
```
### Permission Enforcement
```python
# DRF permission classes
permission_classes = [IsAuthenticated, IsOwner]
# Custom has_object_permission
def has_object_permission(self, request, view, obj):
return obj.owner == request.user
# Django decorators
@permission_required('app.view_document')
# Manual checks
if document.owner != request.user:
raise PermissionDenied()
```
### Ownership Assignment
```python
# Server-side (safe)
def perform_create(self, serializer):
serializer.save(owner=self.request.user)
# From request (investigate)
serializer.save(**request.data) # Does request.data include owner?
```
---
## Investigation Checklist
Use this to guide your review, not as a pass/fail checklist:
```
□ I understand how authorization is typically implemented in this codebase
□ I've identified the ownership model (user, org, tenant, etc.)
□ I've mapped the key endpoints that handle user data
□ For each sensitive endpoint, I've traced the flow and asked:
- Where does the ID come from?
- Where is data fetched?
- What checks exist between input and data access?
□ I've verified my findings by checking parent classes and middleware
□ I've only reported issues I've confirmed through investigation
```Related Skills
constant-time-analysis
Analyze cryptographic code to detect operations that leak secret data through execution timing variations.
codebase-cleanup-deps-audit
You are a dependency security expert specializing in vulnerability scanning, license compliance, and supply chain security. Analyze project dependencies for known vulnerabilities, licensing issues, outdated packages, and provide actionable remediation strategies.
burpsuite-project-parser
Searches and explores Burp Suite project files (.burp) from the command line. Use when searching response headers or bodies with regex patterns, extracting security audit findings, dumping proxy history or site map data, or analyzing HTTP traffic captured in a Burp project.
lightning-architecture-review
Review Bitcoin Lightning Network protocol designs, compare channel factory approaches, and analyze Layer 2 scaling tradeoffs. Covers trust models, on-chain footprint, consensus requirements, HTLC/PTLC compatibility, liveness, and watchtower support.
gha-security-review
Find exploitable vulnerabilities in GitHub Actions workflows. Every finding MUST include a concrete exploitation scenario — if you can't build the attack, don't report it.
gh-review-requests
Fetch unread GitHub notifications for open PRs where review is requested from a specified team or opened by a team member. Use when asked to "find PRs I need to review", "show my review requests", "what needs my review", "fetch GitHub review requests", or "check team review queue".
fixing-accessibility
Audit and fix HTML accessibility issues including ARIA labels, keyboard navigation, focus management, color contrast, and form errors. Use when adding interactive controls, forms, dialogs, or reviewing WCAG compliance.
fix-review
Verify fix commits address audit findings without new bugs
error-debugging-multi-agent-review
Use when working with error debugging multi agent review
django-pro
Master Django 5.x with async views, DRF, Celery, and Django Channels. Build scalable web applications with proper architecture, testing, and deployment.
django-perf-review
Django performance code review. Use when asked to "review Django performance", "find N+1 queries", "optimize Django", "check queryset performance", "database performance", "Django ORM issues", or audit Django code for performance problems.
differential-review
Security-focused code review for PRs, commits, and diffs.