Descrizione
Description
When StormCrawler fetches a host's `/robots.txt` and receives a redirect, `HttpRobotRulesParser`
resolves the `Location` header and re-fetches the target for up to five hops. The loop checks neither
the scheme, the host nor the port of the resolved target, and it is not governed by
`http.allow.redirects`, which only affects the page fetch. A crawled site can therefore point the
robots.txt fetch at any address reachable from the fetcher worker, including loopback interfaces,
private ranges and cloud metadata endpoints. Every crawled URL triggers a robots.txt fetch on a cache
miss, so no unusual configuration is required to reach the loop.
The fetched body is only parsed as robots rules and is not returned to the caller, so the read itself
is blind. The more direct impact is on credentials: the okhttp protocol applies its configured request
headers, including the `Authorization` header built from `http.basicauth.user` and
`http.basicauth.password` and anything in `http.custom.headers`, to every request it makes. Because
StormCrawler follows the redirect itself and issues a new request, okhttp's own removal of the
`Authorization` header across a host change does not apply, and the operator's crawl credentials are
delivered to the host the redirect names.
The connection-time IP filter, `http.filter.ipaddress.include` and `http.filter.ipaddress.exclude`, is
installed as an okhttp network interceptor on the same client and does apply to these hops when it is
configured. It ships with no rules, which is why the path is reachable in a default configuration. URL
filtering never applies, because the robots.txt fetch does not pass through the outlink filter chain.
Mitigation
Upgrade to 4.0.0, where a robots.txt redirect is followed only when the target uses http or https and
shares scheme, host and port with the URL it was reached from. Deployments that legitimately serve
robots.txt through a cross-host redirect can restore the previous behaviour with
`http.robots.redirect.crosshost.allow`.
Users who cannot upgrade immediately should set `http.filter.ipaddress.exclude` to cover loopback,
private, link-local and CGNAT ranges, which is enforced after DNS resolution and therefore also on
redirect hops. Operators who configure `http.basicauth.*` or `http.custom.headers` for a crawl should
assume those credentials may have been sent to third-party hosts and rotate them, and should scope
credentials by running a separate topology per origin.
Credit
Independently reported to the Apache StormCrawler PMC by n0mi1k, with a proof of concept.
Also found by the ASF -- using Claude agents to study the security of open-source projects, validated
and reported by Apache StormCrawler.
Tipo di vulnerabilità
CWE-918
Server-Side Request Forgery (SSRF)
Il server riceve un indirizzo (URL) dall’esterno e ne scarica il contenuto senza verificare a sufficienza che la richiesta vada verso una destinazione prevista: può quindi essere usato per raggiungere sistemi interni.
Impatto sui sistemi
| Ambito | Impatto |
| Riservatezza |
Leggere i dati dell’applicazione |
| Integrità |
Eseguire codice o comandi non autorizzati |
| Controllo degli accessi |
Aggirare i meccanismi di protezione Fornendo URL che puntano a host o porte non previsti, un attaccante può far sembrare che la richiesta parta dal server, aggirando così controlli di accesso come i firewall che gli impediscono di raggiungere quegli indirizzi direttamente. Il server può essere usato come proxy per scansionare le porte dei sistemi della rete interna, leggere documenti presenti sul sistema (con file://) o usare altri protocolli come gopher:// o tftp://, che danno un controllo ancora maggiore sul contenuto delle richieste. |
Come si previene
Sviluppo · Esercizio
Se esiste un elenco noto di applicazioni, indirizzi IP, nomi host o domini con cui il prodotto può comunicare, usa un elenco di destinazioni ammesse per limitare a queste le richieste in uscita. L’elenco può stare nel codice dell’applicazione o essere imposto da firewall o dalla segmentazione della rete.
Sviluppo · Esercizio
Se il prodotto deve potersi collegare a indirizzi IP o domini arbitrari, valuta un elenco di destinazioni vietate che includa gli indirizzi delle reti private, i nomi di dominio interni e simili. L’elenco può stare nel codice dell’applicazione o essere imposto da firewall o dalla segmentazione della rete.
Sviluppo · Validazione dell’input
Considera ogni input come potenzialmente malevolo. Adotta una validazione per «elenco di valori ammessi»: accetta solo gli input che rispettano rigorosamente le specifiche e rifiuta, o trasforma in qualcosa di conforme, tutto il resto. Nel validare considera tutte le proprietà rilevanti: lunghezza, tipo, intervallo dei valori ammessi, input mancanti o in più, sintassi, coerenza tra campi collegati e rispetto delle regole di business (per esempio «barca» è sintatticamente valido perché contiene solo lettere, ma non lo è se il campo deve contenere solo colori come rosso o blu). Non limitarti a cercare input malevoli o malformati: quasi certamente ne sfuggirà qualcuno, soprattutto se l’ambiente del codice cambia, lasciando all’attaccante lo spazio per aggirare la validazione. Le liste di valori vietati restano utili per rilevare possibili attacchi o scartare subito gli input più malformati. Nel costruire richieste in uscita a partire da stringhe di input, usa elenchi rigorosi che limitino i caratteri in base al valore atteso del parametro: riduce indirettamente la portata di un attacco, ma conta meno di una corretta codifica ed escaping dell’output.
Tutte le 4.118 CVE di tipo CWE-918, con andamento e prevenzione