django-security

Implements Django security practices for authentication, authorization, CSRF, XSS, and SQL injection prevention.

1|Updated Oct 11, 2025
One-click install
npx skills add https://github.com/ibytechaos/claude --skill django-security-ibytechaos
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: django-security
Source: https://github.com/ibytechaos/claude/tree/main/plugins/everything-claude-code/skills/django-security
Command: npx skills add https://github.com/ibytechaos/claude --skill django-security-ibytechaos

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Django applications face common web vulnerabilities like SQL injection, XSS, CSRF attacks, and misconfigured production settings. This Skill provides concrete, code-level security patterns to harden Django projects against these threats. ## Core Features & Use Cases - Production Hardening: Configures secure settings including HTTPS redirects, HSTS, secure cookies, and environment-based secret management. - Authentication & Authorization: Implements custom user models, Argon2 password hashing, RBAC, and DRF permission classes like IsOwnerOrReadOnly. - Attack Prevention: Provides safe patterns for ORM queries, template escaping, CSRF tokens, file upload validation, and API rate limiting. - Use Case: Before deploying a Django app to production, use this Skill to audit your settings.py, add security headers middleware, and verify your views properly enforce object-level permissions. ## Quick Start Review my Django project for security issues and apply production-ready security settings following best practices.

Frequently Asked Questions about django-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure a Django application for production?

Set DEBUG to False, configure ALLOWED_HOSTS, enable SECURE_SSL_REDIRECT and HSTS, and mark session and CSRF cookies as secure and HttpOnly. Store SECRET_KEY in environment variables and enable all password validators.

How to prevent SQL injection in Django queries?

Use the Django ORM, which automatically escapes parameters, instead of raw SQL. If raw queries are necessary, always pass user input as parameterized arguments to raw() rather than interpolating strings into the query.

What password hasher should Django use?

Django defaults to PBKDF2, but Argon2 is recommended as the first entry in PASSWORD_HASHERS for stronger resistance to brute-force attacks. Install the argon2-cffi package to enable Argon2PasswordHasher.

Does Django protect against XSS attacks by default?

Yes, Django templates auto-escape variables by default, preventing most XSS. Avoid using the safe filter or mark_safe on user input, and use escapejs for values inserted into JavaScript contexts.

How do I implement role-based access control in Django?

Add a role field to a custom user model with choices like admin, moderator, and user, then enforce access with custom mixins or DRF permission classes. Combine with Django's built-in permissions for object-level checks.

When should I use csrf_exempt in Django views?

Only use csrf_exempt for endpoints that genuinely cannot carry a CSRF token, such as webhooks from external services. Exempting regular views removes protection against cross-site request forgery attacks.