cindovahq/security-skills/django-security
Claude Code and agent skill by cindovahq/security-skills
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Checking that the SKILL.md file is still in the repository.
Security review and secure-coding guidance for Django (4.2 to 6.1) and Django REST framework applications. Use when auditing, reviewing, pentest-prepping or hardening a Django/Python codebase, or when writing or changing Django settings, authentication, authorization (permissions, mixins, LoginRequiredMiddleware), sessions, CSRF, ORM queries and raw SQL, forms and DRF serializers and viewsets, templates, file uploads, admin, Celery tasks or deployment configuration. Triggers on projects containing manage.py and settings.py with django in requirements.txt, pyproject.toml or poetry.lock. Covers settings hardening and check --deploy, authentication and password hashing, IDOR/BOLA and function-level access, CSRF, mass assignment, SQL injection and ORM lookup abuse, XSS, SSRF, open redirects, uploads and downloads, pickle and other deserialization, DRF permissions and throttling, dependencies, and fix verification.
Install
npx vskill@latest install cindovahq/security-skills/django-securitySemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as cindovahq/security-skills/django-security.
Django Security
Find, explain, fix and verify security issues in Django and Django REST framework applications, and write new Django code that does not introduce them.
All paths in this skill (references/...) are relative to the directory containing this SKILL.md.
Modes
- Review mode: the user asks for an audit, security review, pentest prep, or "is this secure?". Follow the workflow below and produce findings.
- Build mode: you are writing or modifying Django code. Apply the build-mode guardrails to every change. Load only the reference for the area you are touching.
If the appsec-review skill is installed, it owns the overall methodology and report format. This skill supplies the Django-specific knowledge. If it is not installed, use the evidence and reporting rules below.
Review workflow
1. Confirm the stack and version
- Confirm Django:
manage.pyat the project root, anddjangoinrequirements*.txt,pyproject.toml,Pipfileor a lock file. - Read the installed version from the lock file (
poetry.lock,uv.lock,Pipfile.lock, pinnedrequirements.txt), not the constraint. If only ranges exist, say the installed version is unknown. - Find the settings module(s).
DJANGO_SETTINGS_MODULEinmanage.py,wsgi.py,asgi.py,pytest.ini, Dockerfiles and CI shows which one runs in production. Projects often havesettings/base.py,production.py,local.py,test.py. Findings in a settings file production never imports are not findings. - Record security-relevant packages:
djangorestframework,django-filter,simplejwt,django-allauth,django-cors-headers,django-axes/django-ratelimit,django-storages,channels,celery,Pillow,whitenoise,django-debug-toolbar,drf-spectacular, GraphQL libraries. - Check support status. Django 4.2 security support ended April 2026; 5.2 LTS is supported until April 2028, 6.0 until April 2027, 6.1 until December 2027. Only the latest patch of a supported series gets fixes. DRF: 3.17.2 or later fixes two 2026 advisories. An unsupported framework or a patch with a reachable advisory is a finding; see
references/dependencies.md. - Note version-dependent behavior:
LoginRequiredMiddleware(5.1+), built-in CSP (6.0+),PickleSerializerremoved (5.0),MAILERS(6.1), signed-cookie salt change (5.2.15/6.0.6, legacy fallback off by default in 6.1),TASKSframework (6.0+).
2. Map the attack surface
- URLs: root
urls.pyplus everyinclude();admin.site.urls; DRF routers (DefaultRouter/SimpleRouter);re_path(..., serve, ...)for media; schema and docs routes. - Views: function views, class-based views, viewsets and
@actions,csrf_exemptviews (webhooks),login_not_requiredviews, anything taking an ID, URL, path, filename, sort field, filter dict, template name or HTML. - Other entry points: Channels consumers, Celery tasks and beat schedules, management commands called from code, signal handlers, GraphQL schema, admin custom views (
get_urls), template tags and filters, middleware order.
3. Review each area
Load the reference for each area as you reach it. Do not load all of them up front.
| Area | Reference | Start by looking for | ||
|---|---|---|---|---|
| Settings & deployment | references/secrets-config.md | DEBUG, SECRET_KEY, ALLOWED_HOSTS, SECURE_*, cookie flags, proxy header trust, CORS, logging, check --deploy | ||
| Authentication | references/authentication.md | PASSWORD_HASHERS, validators, login throttling (none built in), reset flow, remote-user auth, MFA | ||
| Authorization / IDOR / admin | references/authorization.md | get_object_or_404(Model, pk=pk), generic views without get_queryset, @login_required only, get_urls without admin_view, unscoped ModelChoiceField | ||
| Sessions | references/sessions.md | SESSION_ENGINE, signed_cookies, custom serializers, cookie flags, logout, SESSION_COOKIE_DOMAIN | ||
| CSRF | references/csrf.md | csrf_exempt, state-changing GET, CSRF_TRUSTED_ORIGINS, DRF SessionAuthentication | ||
| Validation & mass assignment | references/validation-mass-assignment.md | fields = "__all__", exclude, **request.POST.dict(), read_only_fields, nested writes | ||
| Injection & deserialization | references/injection.md | .raw(/.extra(/RawSQL/cursor.execute with f-strings, order_by(user), filter(**user), shell=True, pickle, yaml.load | ||
| XSS & output | references/xss.md | `\ | safe, mark_safe(f"..."), autoescape off, href="{{ user_url }}", json.dumps in <script>, HttpResponse(f"<...")` | |
| SSRF & redirects | references/ssrf-redirects.md | requests.get(user_url), redirect(request.GET["next"]), missing url_has_allowed_host_and_scheme | ||
| Uploads & downloads | references/file-uploads.md | FileField without validation, serve view in urls.py, FileResponse(open(os.path.join(base, user))), extractall | ||
| DRF permissions & auth | references/drf-permissions.md | No DEFAULT_PERMISSION_CLASSES (default is AllowAny), queryset = X.objects.all(), has_object_permission reliance, token/JWT settings | ||
| API security | references/api-security.md | Throttling, pagination caps, ordering_fields = "__all__", search_fields, browsable API, schema routes, unsigned webhooks | ||
| Background tasks | references/background-tasks.md | Celery serializers and broker exposure, task IDOR, shell in tasks, Flower, secrets in task args | ||
| Dependencies | references/dependencies.md | Support status, pip-audit, notable Django and DRF advisories, supply-chain hygiene | ||
| Verification | references/verification.md | Test-client and APIClient recipes, commands, matrix of proofs per finding class |
4. Classify and report
Every finding needs evidence: file, line, the code or config, and the path from attacker-controlled input to the sensitive operation. Classify findings using the rules below.
5. Remediate and verify (when asked to fix)
Explain the issue before changing code. Make the smallest change that uses Django's own mechanism. Then verify using references/verification.md: the attack no longer works, legitimate use still works, and the same pattern is not repeated elsewhere (search for siblings, other HTTP methods and DRF equivalents of the same view).
High-signal patterns
These are investigation signals, not findings. Trace each one before reporting.
Common false positives
Do not report these without further evidence:
- No explicit `cycle_key()` after `authenticate()`/`login()`.
django.contrib.auth.login()rotates the session key itself. A finding only for custom auth that writes identity into the session manually. - ORM calls with user values (
filter(title__icontains=q),get(pk=pk)), and `raw()`, `extra()`, `RawSQL`, `cursor.execute()` that pass user data through `params` with constant SQL text. - `format_html()` with user data as arguments: it escapes every argument. It becomes unsafe only if an argument is wrapped in
mark_safe.json_script,linebreaksbr,urlizeand ordinary{{ var }}are escaped. - `@csrf_exempt` on webhooks that verify a provider signature (HMAC over
request.bodywithcompare_digest), and no CSRF on DRF token/JWT APIs:SessionAuthenticationis the only DRF class that enforces CSRF. - Fast password hashers (`MD5PasswordHasher`) or `DEBUG = True` in test-only settings that production does not import.
- `CSRF_COOKIE_HTTPONLY` unset, `/admin/` at the default path, `SECRET_KEY` placeholders in `.env.example`.
- `ALLOWED_HOSTS = ["*"]` or missing HSTS are conditional: report with the exploitation condition (reset-link host poisoning, proxy that does not validate hosts) or as Hardening.
- `DEFAULT_PERMISSION_CLASSES` unset when every view sets
permission_classesexplicitly, or when a project base class does. Check before reporting. - `has_object_permission` not called on list views when
get_querysetalready scopes by owner. - Throttling absent in the app when a documented gateway enforces it. DRF's own docs say its throttles are not brute-force protection.
- Paths via `default_storage` / `FileField`: Django sanitizes names and rejects
..for standard storage. Rawopen(os.path.join(...))andFileResponse(open(...))have no such protection. - Unsalted/legacy hashers listed after a strong first hasher only verify and upgrade old hashes.
Severity calibration
Common under-ratings to avoid:
- User-controlled `order_by`/`filter(dict)
field names** on models with secret columns (password, tokens, reset codes, MFA secrets): ordering and lookups are oracles that leak values character by character, including across relations (owner__password). Rate **High** when plaintext tokens, API keys or reset codes are reachable (filterlookups like__startswith` extract them outright), Medium for salted password hashes only or no secret columns, never Low "input validation". - DRF `AllowAny` default + `ModelSerializer` with `fields = "__all__"` on a user/account model is a chain: unauthenticated read/write of privilege fields and password hashes. Rate the chain (often Critical).
- Hard-coded `SECRET_KEY` + `signed_cookies` sessions (or pickle anywhere) is session forgery or code execution. Rate the chain High/Critical, not the key alone.
- `@login_required` on an admin-like action (promote user, export all) is function-level access control failure, High/Critical, not "missing role check".
- Stored XSS rendered to staff in the admin outranks the same bug for ordinary users.
- `@csrf_exempt` on a session-authenticated email or password change is account takeover (change the email, then use password reset). Rate High, not Low because "only profile fields" are exposed.
Build-mode guardrails
When writing Django code, default to:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/django-security/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/cindovahq/security-skills/django-security)