gateway: a client-supplied X-Forwarded-Host picks which PublicGateways rules apply, with no way to turn the trust off
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 46/100
Direzione di ricerca
Read gateway/hostname.go and gateway/handler.go, especially NewHostnameHandler and isDeserializedResponsePossible; the issue gives the relevant code paths and an example configuration. First inspect how gateway Config is defined and how Kubo configures it, then check the gateway tests for hostname routing and trustless responses. Done means the trust in forwarded host and proto can be controlled as described, with the example no longer bypassing the configured per-host rules.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
The gateway honours a client-supplied X-Forwarded-Host on every request, with no setting to turn it on or off. That header is what selects the PublicGateways entry, and with it the per-hostname rules. So a client talking to the gateway directly can choose which rules apply to its own request, including "none": the global defaults.
Where (at 3d6ac39):
- The hostname handler:
NewHostnameHandlerreplacesr.Hostwith the header (gateway/hostname.goL46–L51). It then uses that value for the known-gateway match, the subdomain match and the DNSLink fallback (L54–L217). - The trustless check:
isDeserializedResponsePossiblelets the header override everything when it picks the entry whoseDeserializedResponsesapplies (gateway/handler.goL375–L397). That function decides whether a non-trustless request is refused (L293–L298).
Example, on a gateway exposed without a proxy:
- The setup:
PublicGatewayshas"trustless.example.com": {"Paths": ["/ipfs"], "NoDNSLink": true, "DeserializedResponses": false}. The global settings are Kubo's defaults (Gateway.DeserializedResponses: true,Gateway.NoDNSLink: false). - The request:
GET /ipns/<name>/index.html, sent totrustless.example.comwithX-Forwarded-Host: other.invalid. - The routing: the hostname handler finds no entry for
other.invalidand falls through to plain path handling (L219–L220). So/ipnsis served although the entry allows only/ipfs. - The trustless check:
other.invalidisn't a key inPublicGateways, so the globalDeserializedResponses: trueapplies, and the client gets a deserialized response from a hostname configured as trustless-only. - DNSLink: with
X-Forwarded-Hostnaming a DNSLink domain instead, the globalNoDNSLink: falseapplies, and that domain's DNSLink site is served (L212–L216), whateverNoDNSLinksays fortrustless.example.com.
Scope: only the requester's own response changes; a browser can't set this header on a navigation. This assumes nothing in front of the gateway caches responses without X-Forwarded-Host in the cache key. A cache that passes a client's header through, and doesn't key on it, would hand the chosen response to everyone.
Context: the subdomain-gateway spec lists X-Forwarded-Host as an optional request header for gateways behind a reverse proxy (spec), and boxo's AGENTS.md names the trust placed in it. So honouring it is intended. What isn't there is a way to restrict it to the deployments that have such a proxy.
Suggested fix:
- Make trust in
X-Forwarded-Host(andX-Forwarded-Proto) opt-in inConfig, for example a flag or a list of trusted proxy addresses, defaulting off for new users. Kubo can turn it on for its existing behaviour. - Alternatively, honour the header only when its value is itself a configured
PublicGatewayshostname, so it can't select the global defaults or an arbitrary DNSLink name.
Filed in public because this is specified behaviour, and its effect is limited to the requester's own responses. If you'd rather handle it through [email protected], I'm glad to move it there.
🤖 Generated with Claude Code
- Lingua principale
- Go
- Stelle
- 326
- Fork
- 165
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Nessuna guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di ipfs/boxo
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
-
need/triage
Difficoltà 5/5 Più di una settimana Idoneità per principianti 38/100
-
dif/medium effort/hours kind/enhancement P3 topic/devexp
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
-
dif/expert effort/weeks kind/enhancement P2
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
Issue simili
-
area/networking kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 69/100
siderolabs/talos#14972 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
kubectl wait outputs cryptic "error: unrecognized condition: []" when --for is omittedForse già presa @muskan-creates352 l’ha presa oggi. Apertakind/bug needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
kubernetes/kubectl#1910 · 1 commento ·
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
stacklok/toolhive-catalog#1967 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
unbound-force/gaze#353 ·
I maintainer di solito rispondono entro 1 giorno