[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7C00CJ9PTS3RTJQ8VSZ7AW4":3,"skill-same:01M7C00CJ9PTS3RTJQ8VSZ7AW4":91},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":15,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":25,"commitSha":26,"skillDirectory":27,"forksCount":28,"repositoryHtmlUrl":29,"repositoryHomepageUrl":6,"ownerHtmlUrl":30,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":31,"install":32,"resources":45},"01M7C00CJ9PTS3RTJQ8VSZ7AW4","django",null,"Application security guide, audit checklist, and static scanner for Django and DRF web applications. Use when writing, refactoring, or reviewing Django views, ORM queries, models, serializers, forms, authentication flows, file uploads, or production settings.","chandanrajpurohit\u002Fappsec-skills","chandanrajpurohit","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F266481166?v=4","01M7C009QVFDKXGMTAPT1KTZFM","01M7C009RECBVGZGR5ESDRRJP4",1,"MIT","https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: django\ndescription: Application security guide, audit checklist, and static scanner for Django and DRF web applications. Use when writing, refactoring, or reviewing Django views, ORM queries, models, serializers, forms, authentication flows, file uploads, or production settings.\nlicense: Complete terms in LICENSE.txt\n---\n\n# Django Application Security\n\nThis skill guides AI agents in identifying, preventing, and remediating application security vulnerabilities across Django applications and Django REST Framework (DRF) APIs.\n\n**Helper Scripts Available**:\n- `scripts\u002Faudit.py` - AST and pattern static security scanner for Django projects\n\n**Always run scripts with `--help` first** to see usage. DO NOT read the source until you try running the script first and find that a customized solution is absolutely necessary. These scripts can be very large and thus pollute your context window. They exist to be called directly as black-box scripts rather than ingested into your context window.\n\n---\n\n## Decision Tree: Choosing Your Approach\n\n```\nDjango Task → What area of the application are you working on?\n    ├─ Views \u002F APIs → Is authentication and object-level ownership verified?\n    │       ├─ No → Filter database query by request.user \u002F organization\n    │       └─ Yes → Check CSRF token & rate limiting\n    │\n    ├─ Database \u002F ORM → Are raw queries or cursors used?\n    │       ├─ Yes → Parameterize with placeholders (%s); eliminate f-strings\n    │       └─ No → Use standard ORM filter\u002Fexclude\n    │\n    ├─ Serializers (DRF) → Is fields = '__all__' present?\n    │       ├─ Yes → Replace with explicit list; mark sensitive fields write_only=True\n    │       └─ No → Proceed with scoped validation\n    │\n    ├─ File Uploads → Are uploaded filenames preserved from client?\n    │       ├─ Yes → Generate UUID filenames, validate magic bytes & size\n    │       └─ No → Verify storage isolation\n    │\n    └─ Deployment \u002F Settings → Is DEBUG = True or ALLOWED_HOSTS = ['*']?\n            ├─ Yes → Bind to environment variables; enforce HSTS & secure cookies\n            └─ No → Run: python manage.py check --deploy\n```\n\n---\n\n## Quick Reference Workflow\n\n### 1. Run Automated Security Scanner\nRun the included AST security scanner on your target directory:\n```bash\npython scripts\u002Faudit.py \u002Fpath\u002Fto\u002Fdjango\u002Fproject\n```\n\n### 2. View & API Authorization (IDOR Defense)\nNever retrieve objects using an unvalidated primary key without verifying requesting user ownership:\n```python\n# VULNERABLE: Direct access without ownership check\ndoc = Document.objects.get(id=doc_id)\n\n# SECURE: Scoped to authenticated user\ndoc = get_object_or_404(Document, id=doc_id, owner=request.user)\n```\nSee: [authz-idor.md](.\u002Freferences\u002Fauthz-idor.md)\n\n### 3. ORM & SQL Injection Defense\nNever use string formatting (f-strings, `.format()`, `%`) in raw SQL:\n```python\n# VULNERABLE: f-string interpolation\nUser.objects.raw(f\"SELECT * FROM auth_user WHERE username = '{username}'\")\n\n# SECURE: Parameterized placeholder\nUser.objects.raw(\"SELECT * FROM auth_user WHERE username = %s\", [username])\n```\nSee: [orm-sql-injection.md](.\u002Freferences\u002Form-sql-injection.md)\n\n### 4. XSS & Template Escaping (`mark_safe`)\nAvoid using `mark_safe` on raw user inputs. If rich HTML is required, sanitize with `nh3`:\n```python\nimport nh3\nfrom django.utils.safestring import mark_safe\n\nclean_html = nh3.clean(user_input, tags={\"p\", \"b\", \"i\", \"strong\", \"em\", \"a\"})\nsafe_content = mark_safe(clean_html)\n```\nSee: [xss-csrf-defense.md](.\u002Freferences\u002Fxss-csrf-defense.md)\n\n### 5. Production Settings Checklist\n- `DEBUG = False`\n- `SECRET_KEY` loaded from environment\n- `ALLOWED_HOSTS` explicit (no wildcard `*`)\n- `SESSION_COOKIE_SECURE = True`\n- `CSRF_COOKIE_SECURE = True`\n- `SECURE_SSL_REDIRECT = True`\n- `SECURE_HSTS_SECONDS = 31536000`\nSee: [settings-hardening.md](.\u002Freferences\u002Fsettings-hardening.md) and [secure_settings.py](.\u002Fexamples\u002Fsecure_settings.py)\n\n---\n\n## References Directory\n\n- [Production Settings Hardening](.\u002Freferences\u002Fsettings-hardening.md)\n- [Preventing SQL Injection in Django ORM](.\u002Freferences\u002Form-sql-injection.md)\n- [Authorization & IDOR \u002F BOLA Prevention](.\u002Freferences\u002Fauthz-idor.md)\n- [XSS & CSRF Defense](.\u002Freferences\u002Fxss-csrf-defense.md)\n- [Secure File Upload Handling](.\u002Freferences\u002Ffile-upload-security.md)\n- [Django REST Framework API Security](.\u002Freferences\u002Fapi-drf-security.md)\n- [Vulnerable vs Secure Code Examples](.\u002Fexamples\u002Fvulnerable_vs_secure.py)\n- [Production-Ready Hardened Settings](.\u002Fexamples\u002Fsecure_settings.py)\n","# Django Application Security\n\nThis skill guides AI agents in identifying, preventing, and remediating application security vulnerabilities across Django applications and Django REST Framework (DRF) APIs.\n\n**Helper Scripts Available**:\n- `scripts\u002Faudit.py` - AST and pattern static security scanner for Django projects\n\n**Always run scripts with `--help` first** to see usage. DO NOT read the source until you try running the script first and find that a customized solution is absolutely necessary. These scripts can be very large and thus pollute your context window. They exist to be called directly as black-box scripts rather than ingested into your context window.\n\n---\n\n## Decision Tree: Choosing Your Approach\n\n```\nDjango Task → What area of the application are you working on?\n    ├─ Views \u002F APIs → Is authentication and object-level ownership verified?\n    │       ├─ No → Filter database query by request.user \u002F organization\n    │       └─ Yes → Check CSRF token & rate limiting\n    │\n    ├─ Database \u002F ORM → Are raw queries or cursors used?\n    │       ├─ Yes → Parameterize with placeholders (%s); eliminate f-strings\n    │       └─ No → Use standard ORM filter\u002Fexclude\n    │\n    ├─ Serializers (DRF) → Is fields = '__all__' present?\n    │       ├─ Yes → Replace with explicit list; mark sensitive fields write_only=True\n    │       └─ No → Proceed with scoped validation\n    │\n    ├─ File Uploads → Are uploaded filenames preserved from client?\n    │       ├─ Yes → Generate UUID filenames, validate magic bytes & size\n    │       └─ No → Verify storage isolation\n    │\n    └─ Deployment \u002F Settings → Is DEBUG = True or ALLOWED_HOSTS = ['*']?\n            ├─ Yes → Bind to environment variables; enforce HSTS & secure cookies\n            └─ No → Run: python manage.py check --deploy\n```\n\n---\n\n## Quick Reference Workflow\n\n### 1. Run Automated Security Scanner\nRun the included AST security scanner on your target directory:\n```bash\npython scripts\u002Faudit.py \u002Fpath\u002Fto\u002Fdjango\u002Fproject\n```\n\n### 2. View & API Authorization (IDOR Defense)\nNever retrieve objects using an unvalidated primary key without verifying requesting user ownership:\n```python\n# VULNERABLE: Direct access without ownership check\ndoc = Document.objects.get(id=doc_id)\n\n# SECURE: Scoped to authenticated user\ndoc = get_object_or_404(Document, id=doc_id, owner=request.user)\n```\nSee: [authz-idor.md](.\u002Freferences\u002Fauthz-idor.md)\n\n### 3. ORM & SQL Injection Defense\nNever use string formatting (f-strings, `.format()`, `%`) in raw SQL:\n```python\n# VULNERABLE: f-string interpolation\nUser.objects.raw(f\"SELECT * FROM auth_user WHERE username = '{username}'\")\n\n# SECURE: Parameterized placeholder\nUser.objects.raw(\"SELECT * FROM auth_user WHERE username = %s\", [username])\n```\nSee: [orm-sql-injection.md](.\u002Freferences\u002Form-sql-injection.md)\n\n### 4. XSS & Template Escaping (`mark_safe`)\nAvoid using `mark_safe` on raw user inputs. If rich HTML is required, sanitize with `nh3`:\n```python\nimport nh3\nfrom django.utils.safestring import mark_safe\n\nclean_html = nh3.clean(user_input, tags={\"p\", \"b\", \"i\", \"strong\", \"em\", \"a\"})\nsafe_content = mark_safe(clean_html)\n```\nSee: [xss-csrf-defense.md](.\u002Freferences\u002Fxss-csrf-defense.md)\n\n### 5. Production Settings Checklist\n- `DEBUG = False`\n- `SECRET_KEY` loaded from environment\n- `ALLOWED_HOSTS` explicit (no wildcard `*`)\n- `SESSION_COOKIE_SECURE = True`\n- `CSRF_COOKIE_SECURE = True`\n- `SECURE_SSL_REDIRECT = True`\n- `SECURE_HSTS_SECONDS = 31536000`\nSee: [settings-hardening.md](.\u002Freferences\u002Fsettings-hardening.md) and [secure_settings.py](.\u002Fexamples\u002Fsecure_settings.py)\n\n---\n\n## References Directory\n\n- [Production Settings Hardening](.\u002Freferences\u002Fsettings-hardening.md)\n- [Preventing SQL Injection in Django ORM](.\u002Freferences\u002Form-sql-injection.md)\n- [Authorization & IDOR \u002F BOLA Prevention](.\u002Freferences\u002Fauthz-idor.md)\n- [XSS & CSRF Defense](.\u002Freferences\u002Fxss-csrf-defense.md)\n- [Secure File Upload Handling](.\u002Freferences\u002Ffile-upload-security.md)\n- [Django REST Framework API Security](.\u002Freferences\u002Fapi-drf-security.md)\n- [Vulnerable vs Secure Code Examples](.\u002Fexamples\u002Fvulnerable_vs_secure.py)\n- [Production-Ready Hardened Settings](.\u002Fexamples\u002Fsecure_settings.py)\n",{"name":5,"license":24,"description":7},"Complete terms in LICENSE.txt","main","b6539f9d79929d74ee253268edc125f2c904da43","skills\u002Fdjango",0,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills","https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit","2026-09-21 15:43:31",{"source":8,"skillName":5,"commands":33,"prompt":43,"zipAvailable":44},[34,37,40],{"tool":35,"command":36},"npx","npx skills add chandanrajpurohit\u002Fappsec-skills --skill django",{"tool":38,"command":39},"bunx","bunx skills add chandanrajpurohit\u002Fappsec-skills --skill django",{"tool":41,"command":42},"pnpm","pnpm dlx skills add chandanrajpurohit\u002Fappsec-skills --skill django","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002FSKILL.md",true,[46,52,56,61,67,71,75,79,83,87],{"path":47,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":50,"sourceHtmlUrl":51},"examples\u002Fsecure_settings.py","SCRIPT","脚本",1754,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Fexamples\u002Fsecure_settings.py",{"path":53,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":54,"sourceHtmlUrl":55},"examples\u002Fvulnerable_vs_secure.py",3554,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Fexamples\u002Fvulnerable_vs_secure.py",{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":15},"LICENSE.txt","LICENSE","许可证",1075,{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"references\u002Fapi-drf-security.md","REFERENCE","参考文档",4159,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Freferences\u002Fapi-drf-security.md",{"path":68,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":69,"sourceHtmlUrl":70},"references\u002Fauthz-idor.md",5263,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Freferences\u002Fauthz-idor.md",{"path":72,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":73,"sourceHtmlUrl":74},"references\u002Ffile-upload-security.md",5088,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Freferences\u002Ffile-upload-security.md",{"path":76,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":77,"sourceHtmlUrl":78},"references\u002Form-sql-injection.md",4263,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Freferences\u002Form-sql-injection.md",{"path":80,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":81,"sourceHtmlUrl":82},"references\u002Fsettings-hardening.md",4544,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Freferences\u002Fsettings-hardening.md",{"path":84,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":85,"sourceHtmlUrl":86},"references\u002Fxss-csrf-defense.md",5178,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Freferences\u002Fxss-csrf-defense.md",{"path":88,"resourceType":48,"resourceTypeDesc":49,"sizeBytes":89,"sourceHtmlUrl":90},"scripts\u002Faudit.py",8211,"https:\u002F\u002Fgithub.com\u002Fchandanrajpurohit\u002Fappsec-skills\u002Fblob\u002Fmain\u002Fskills\u002Fdjango\u002Fscripts\u002Faudit.py",[]]