gateway: a client-supplied X-Forwarded-Host picks which PublicGateways rules apply, with no way to turn the trust off
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 46/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Go
- Stars
- 326
- Forks
- 165
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ipfs/boxo
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
need/triage
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
dif/medium effort/hours kind/enhancement P3 topic/devexp
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
dif/expert effort/weeks kind/enhancement P2
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
affects-8.5 component/session severity/moderate sig/transaction type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
harvester/harvester#12311 · 1 comment ·
Maintainers usually reply within 1 day
-
verifyrun --bracket-digest --credit: relative --witness is could-not-check, absolute path creditsOpenbug effort:s impact:low raised-by:desk risk:low
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
medici-finance/assay#6580 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 80/100
blinklabs-io/gouroboros#3026 ·
Maintainers usually reply within 1 day