con un clic
django-security-audit
Perform a security audit on a Django project
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Menú
Perform a security audit on a Django project
Instalar con Codex o Claude Copia este prompt, pégalo en Codex, Claude u otro asistente, y deja que revise la página de la skill y la instale por ti.
Basado en la clasificación ocupacional SOC
Configure the current project with Django 6.x expert tools (rules, skills, agents, hooks) from GitHub. Use when setting up a Django project.
Debug Django issues - ORM queries, migrations, template errors, async problems. Use when debugging Django applications.
Check and validate Django migrations for safety and correctness before deployment
Create a new REST API endpoint following modern DRF best practices
Create a new Django app following modern best practices and cookiecutter-django conventions
Create a new Django model following modern best practices
| name | django-security-audit |
| description | Perform a security audit on a Django project |
| disable-model-invocation | true |
| allowed-tools | Read, Bash, Grep, Glob |
Execute each section of this audit systematically. Report findings by severity.
python manage.py check --deploy
This checks for common security misconfigurations. Fix all warnings.
Check config/settings/production.py for these settings:
# Search for security-related settings
grep -rn "SECRET_KEY\|DEBUG\|ALLOWED_HOSTS\|SECURE_\|CSRF_\|SESSION_\|HSTS" config/settings/
Must verify:
SECRET_KEY loaded from environment (not hardcoded)DEBUG = False in productionALLOWED_HOSTS is explicitly set (not ["*"])SECURE_SSL_REDIRECT = TrueSECURE_HSTS_SECONDS >= 31536000 (1 year)SECURE_HSTS_INCLUDE_SUBDOMAINS = TrueSECURE_HSTS_PRELOAD = TrueSESSION_COOKIE_SECURE = TrueCSRF_COOKIE_SECURE = TrueSECURE_CONTENT_TYPE_NOSNIFF = TrueCSRF_TRUSTED_ORIGINS explicitly setX_FRAME_OPTIONS = "DENY" or "SAMEORIGIN"default-src is set to 'self'unsafe-inline or unsafe-eval in script-src (use nonces if needed)grep -rn "AUTH_PASSWORD_VALIDATORS" config/settings/
MinimumLengthValidator set to >= 10 charactersArgon2PasswordHasher as first hashergrep -rn "CORS_" config/settings/
CORS_ALLOWED_ORIGINS explicitly listed (not CORS_ALLOW_ALL_ORIGINS = True)CORS_ALLOW_CREDENTIALS only if needed (and origins are restricted)# Find mark_safe usage
grep -rn "mark_safe" --include="*.py" .
# Find |safe filter in templates
grep -rn "|safe" --include="*.html" .
# Find format_html_join with user data
grep -rn "format_html" --include="*.py" .
mark_safe() calls (replace with format_html())|safe on user-provided data in templatesformat_html() used correctly (user data as arguments, not in format string)# Find raw SQL
grep -rn "\.raw(" --include="*.py" .
grep -rn "cursor\.execute" --include="*.py" .
grep -rn "\.extra(" --include="*.py" .
grep -rn "RawSQL" --include="*.py" .
%s placeholders).extra() without parameterization# Find csrf_exempt usage
grep -rn "csrf_exempt" --include="*.py" .
# Check forms for csrf_token
grep -rn "method=\"post\"\|method='post'" --include="*.html" . | while read line; do
file=$(echo "$line" | cut -d: -f1)
grep -L "csrf_token" "$file" 2>/dev/null
done
@csrf_exempt without documented justification{% csrf_token %}# Find __all__ in serializers
grep -rn 'fields.*=.*"__all__"\|fields.*=.*__all__' --include="*.py" .
# Find exclude in ModelForm/Serializer
grep -rn "exclude\s*=" --include="*.py" .
fields = "__all__" in serializers or formsexclude pattern (use explicit fields list instead)read_only in serializers# Find FileField/ImageField
grep -rn "FileField\|ImageField" --include="*.py" .
grep -rn "AUTH_USER_MODEL" config/settings/
auth.User)SESSION_COOKIE_AGE)grep -rn "admin.site.urls\|admin/" config/urls.py
/admin/grep -rn "DEFAULT_AUTHENTICATION_CLASSES\|authentication_classes" --include="*.py" .
# Check for known vulnerabilities
pip-audit
# Or using safety
safety check
# Check Django version
python -c "import django; print(django.VERSION)"
# Check for DEBUG mode indicators
grep -rn "DEBUG" --include="*.py" config/settings/production.py
# Check for verbose error pages
grep -rn "handler404\|handler500" --include="*.py" .
# Check for exposed internal URLs
grep -rn "debug_toolbar\|silk\|profiling" --include="*.py" config/
.env, .git/, requirements.txt not accessible via web# Check git history for secrets
git log --all --diff-filter=A -- "*.env" ".env*" "*secret*" "*password*" "*token*" "*key*"
# Check current files for potential secrets
grep -rn "password\s*=\s*['\"]" --include="*.py" . | grep -v "test\|factory\|fixture"
grep -rn "token\s*=\s*['\"]" --include="*.py" . | grep -v "test\|factory\|fixture"
grep -rn "api_key\s*=\s*['\"]" --include="*.py" . | grep -v "test\|factory\|fixture"
.env in .gitignore# Security Audit Report — [Project Name]
**Date:** YYYY-MM-DD
**Auditor:** Claude Code (django-security-audit)
## Summary
- Critical: N findings
- High: N findings
- Medium: N findings
- Low: N findings
## Findings
### [CRITICAL] Finding Title
**Location:** `path/to/file.py:42`
**Description:** ...
**Impact:** ...
**Remediation:** ...
### [HIGH] Finding Title
...