cindovahq/security-skills/django-security

Claude Code and agent skill by cindovahq/security-skills

Trust tier 3
  • community
  • ext:[{"type":"config","description":"Configuration overrides"}]
Source check pending

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-security

Semi-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
  1. Confirm Django: manage.py at the project root, and django in requirements*.txt, pyproject.toml, Pipfile or a lock file.
  2. Read the installed version from the lock file (poetry.lock, uv.lock, Pipfile.lock, pinned requirements.txt), not the constraint. If only ranges exist, say the installed version is unknown.
  3. Find the settings module(s). DJANGO_SETTINGS_MODULE in manage.py, wsgi.py, asgi.py, pytest.ini, Dockerfiles and CI shows which one runs in production. Projects often have settings/base.py, production.py, local.py, test.py. Findings in a settings file production never imports are not findings.
  4. 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.
  5. 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.
  6. Note version-dependent behavior: LoginRequiredMiddleware (5.1+), built-in CSP (6.0+), PickleSerializer removed (5.0), MAILERS (6.1), signed-cookie salt change (5.2.15/6.0.6, legacy fallback off by default in 6.1), TASKS framework (6.0+).
2. Map the attack surface
  • URLs: root urls.py plus every include(); 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_exempt views (webhooks), login_not_required views, 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.

AreaReferenceStart by looking for
Settings & deploymentreferences/secrets-config.mdDEBUG, SECRET_KEY, ALLOWED_HOSTS, SECURE_*, cookie flags, proxy header trust, CORS, logging, check --deploy
Authenticationreferences/authentication.mdPASSWORD_HASHERS, validators, login throttling (none built in), reset flow, remote-user auth, MFA
Authorization / IDOR / adminreferences/authorization.mdget_object_or_404(Model, pk=pk), generic views without get_queryset, @login_required only, get_urls without admin_view, unscoped ModelChoiceField
Sessionsreferences/sessions.mdSESSION_ENGINE, signed_cookies, custom serializers, cookie flags, logout, SESSION_COOKIE_DOMAIN
CSRFreferences/csrf.mdcsrf_exempt, state-changing GET, CSRF_TRUSTED_ORIGINS, DRF SessionAuthentication
Validation & mass assignmentreferences/validation-mass-assignment.mdfields = "__all__", exclude, **request.POST.dict(), read_only_fields, nested writes
Injection & deserializationreferences/injection.md.raw(/.extra(/RawSQL/cursor.execute with f-strings, order_by(user), filter(**user), shell=True, pickle, yaml.load
XSS & outputreferences/xss.md`\safe, mark_safe(f"..."), autoescape off, href="{{ user_url }}", json.dumps in <script>, HttpResponse(f"<...")`
SSRF & redirectsreferences/ssrf-redirects.mdrequests.get(user_url), redirect(request.GET["next"]), missing url_has_allowed_host_and_scheme
Uploads & downloadsreferences/file-uploads.mdFileField without validation, serve view in urls.py, FileResponse(open(os.path.join(base, user))), extractall
DRF permissions & authreferences/drf-permissions.mdNo DEFAULT_PERMISSION_CLASSES (default is AllowAny), queryset = X.objects.all(), has_object_permission reliance, token/JWT settings
API securityreferences/api-security.mdThrottling, pagination caps, ordering_fields = "__all__", search_fields, browsable API, schema routes, unsigned webhooks
Background tasksreferences/background-tasks.mdCelery serializers and broker exposure, task IDOR, shell in tasks, Flower, secrets in task args
Dependenciesreferences/dependencies.mdSupport status, pip-audit, notable Django and DRF advisories, supply-chain hygiene
Verificationreferences/verification.mdTest-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.

text
# Injection / RCE
.raw( .extra( RawSQL( cursor.execute(f" cursor.execute("..." % .format( in SQL strings
order_by(request .values(request filter(**request exclude(** Q(** annotate(** .alias(**
subprocess shell=True os.system( pickle.loads yaml.load( marshal.loads Template(request jinja2.Template(
# Authorization
get_object_or_404(Model, pk= Model.objects.get(pk=request queryset = Model.objects.all() @login_required (only)
permission_classes = [] / [AllowAny] authentication_classes = [] admin_view missing in get_urls @login_not_required
# Mass assignment / exposure
fields = "__all__" exclude = [ create(**request update(**request.data ordering_fields = "__all__" depth =
# XSS / output
|safe mark_safe( autoescape off SafeString( HttpResponse(f" href="{{ <script>... {{ ...|safe
# Files / SSRF / redirects
FileResponse(open( os.path.join(BASE_DIR, request serve extractall upload_to requests.get( urlopen( redirect(request
# Config / secrets
DEBUG = True SECRET_KEY = " ALLOWED_HOSTS = ["*"] SESSION_ENGINE ...signed_cookies MD5PasswordHasher csrf_exempt CORS_ALLOW_ALL_ORIGINS
SECURE_PROXY_SSL_HEADER USE_X_FORWARDED_HOST CSRF_TRUSTED_ORIGINS PickleSerializer CELERY_ACCEPT_CONTENT pickle

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, urlize and ordinary {{ var }} are escaped.
  • `@csrf_exempt` on webhooks that verify a provider signature (HMAC over request.body with compare_digest), and no CSRF on DRF token/JWT APIs: SessionAuthentication is 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_classes explicitly, or when a project base class does. Check before reporting.
  • `has_object_permission` not called on list views when get_queryset already 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. Raw open(os.path.join(...)) and FileResponse(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 (filter lookups 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

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
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/cindovahq/security-skills/django-security/badge)](https://verified-skill.com/skills/cindovahq/security-skills/django-security)

Something wrong with this skill or its page? Tell us.