跳到正文
Skillpedia
安全48k · #4468

django-access-review

它能做什么

这个工具用来检查未经授权的用户,能否访问、修改或删除其他用户的数据,适用于使用 Django 或 DRF 构建的系统。它会分析代码中权限是如何运作的,从而找出安全漏洞。

适用场景

  • ✓当你在审查 Django/DRF 系统的安全代码时。
  • ✓当你怀疑某个用户能够查看或修改别人的数据时。
  • ✓当你要确保只有授权人员才能访问特定信息时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/django-access-review/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/django-access-review/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“检查普通用户能否查看文档系统中其他用户的数据。”

每周 5 个新技能,1 分钟读完。

工作原理

该工具会分析代码,理解权限是如何检查的,追踪数据流向,并寻找访问控制可能不当的地方。它关注的是理解系统自身的特定逻辑,而不是搜索通用的错误模式。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

<!-- Reference material based on OWASP Cheat Sheet Series (CC BY-SA 4.0) https://cheatsheetseries.owasp.org/ -->

Django Access Control & IDOR Review

Find access control vulnerabilities by investigating how the codebase answers one question:

Can User A access, modify, or delete User B's data?

When to Use

  • You need to review Django or DRF code for access control gaps, IDOR risk, or object-level authorization failures.
  • The task involves confirming whether one user can access, modify, or delete another user's data.
  • You want an investigation-driven authorization review instead of generic pattern matching.

Philosophy: Investigation Over Pattern Matching

Do NOT scan for predefined vulnerable patterns. Instead:

  1. Understand how authorization works in THIS codebase
  2. Ask questions about specific data flows
  3. Trace code to find where (or if) access checks happen
  4. Report only what you've confirmed through investigation

Every codebase implements authorization differently. Your job is to understand this specific implementation, then find gaps.


Phase 1: Understand the Authorization Model

Before looking for bugs, answer these questions about the codebase:

How is authorization enforced?

Research the codebase to find:

□ Where are permission checks implemented?
  - Decorators? (@login_required, @permission_required, custom?)
  - Middleware? (TenantMiddleware, AuthorizationMiddleware?)
  - Base classes? (BaseAPIView, TenantScopedViewSet?)
  - Permission classes? (DRF permission_classes?)
  - Custom mixins? (OwnershipMixin, TenantMixin?)

□ How are queries scoped?
  - Custom managers? (TenantManager, UserScopedManager?)
  - get_queryset() overrides?
  - Middleware that sets query context?

□ What's the ownership model?
  - Single user ownership? (document.owner_id)
  - Organization/tenant ownership? (document.organization_id)
  - Hierarchical? (org -> team -> user -> resource)
  - Role-based within context? (org admin vs member)

Investigation commands

# Find how auth is typically done
grep -rn "permission_classes\|@login_required\|@permission_required" --include="*.py" | head -20

# Find base classes that views inherit from
grep -rn "class Base.*View\|class.*Mixin.*:" --include="*.py" | head -20

# Find custom managers
grep -rn "class.*Manager\|def get_queryset" --include="*.py" | head -20

# Find ownership fields on models
grep -rn "owner\|user_id\|organization\|tenant" --include="models.py" | head -30

Do not proceed until you understand the authorization model.


Phase 2: Map the Attack Surface

Identify endpoints that handle user-specific data:

What resources exist?

□ What models contain user data?
□ Which have ownership fields (owner_id, user_id, organization_id)?
□ Which are accessed via ID in URLs or request bodies?

What operations are exposed?

For each resource, map:

  • List endpoints - what data is returned?
  • Detail/retrieve endpoints - how is the object fetched?
  • Create endpoints - who sets the owner?
  • Update endpoints - can users modify others' data?
  • Delete endpoints - can users delete others' data?
  • Custom actions - what do they access?

Phase 3: Ask Questions and Investigate

For each endpoint that handles user data, ask:

The Core Question

"If I'm User A and I know the ID of User B's resource, can I access it?"

Trace the code to answer this:

1. Where does the resource ID enter the system?
   - URL path: /api/documents/{id}/
   - Query param: ?document_id=123
   - Request body: {"document_id": 123}

2. Where is that ID used to fetch data?
   - Find the ORM query or database call

3. Between (1) and (2), what checks exist?
   - Is the query scoped to current user?
   - Is there an explicit ownership check?
   - Is there a permission check on the object?
   - Does a base class or mixin enforce access?

4. If you can't find a check, is there one you missed?
   - Check parent classes
   - Check middleware
   - Check managers
   - Check decorators at URL level

Follow-Up Questions

□ For list endpoints: Does the query filter to user's data, or return everything?

□ For create endpoints: Who sets the owner - the server or the request?

□ For bulk operations: Are they scoped to user's data?

□ For related resources: If I can access a document, can I access its comments?
  What if the document belongs to someone else?


…
常见问题

什么是 IDOR?

IDOR 全称为 “Insecure Direct Object Reference”,即“不安全的直接对象引用”。这是一种安全漏洞:用户只需更改 URL 或请求中的标识符(比如一个数字),就能访问本不该有权限查看的资源(比如数据或文件)。

这个工具如何发现漏洞?

它不会自动扫描错误。相反,它会引导你手动排查系统如何检查“谁能对数据做什么”,沿着代码逻辑找出访问检查可能缺失或失效的地方。

我需要会 Django 编程才能使用它吗?

最好对 Django 的工作方式有一定了解,尤其是数据处理和权限方面。这个工具会引导排查过程,但最终的代码分析仍需要你来完成。

详情

作者的原始描述

Use when reviewing Django or DRF access control: trace authorization flows, IDOR risks, object permissions, query scoping and tenant isolation before proposing a verified fix.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#4468
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能