Repository navigation
π fix(mcpserver): derive the idea URL scheme from the request and sanitise forwarded headers - #542
Conversation
β¦ise forwarded headers Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hive status β updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: CI pending β sweep will merge when green. π Hive Agent: β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from Read the diff against the tree at
One note for the record, not a blocker: the PR body says the scheme comes from As the body states, a well-formed forged host (e.g. |
A trusted X-Forwarded-Host means a TLS-terminating proxy is in front of the server, so the idea URL scheme defaults to https there and only falls back to the request scheme for direct connections. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read pkg/mcpserver/server.go at 542c76a plus serveInstructions and the callers of ideaURL. This looks correct to me and resolves both #540 and #541:
NewHandler(server.go:70-85) now derives the scheme fromr.TLSand only letsX-Forwarded-Protooverride it whenforwardedSchemereturnshttp/httpsβ the same allow-listserveInstructionsalready applied at server.go:110, so the two URL builders now agree.forwardedHostValue(server.go:421-427) takes the first hop and rejects/ @ \ ? #and whitespace, so a forged value can no longer smuggle a path/userinfo/fragment into the returned URL;TestSubmitIdeaURLRejectsForgedForwardedHeaderspins that.- The flipped expectation in
TestSubmitIdeaURLUsesRequestHostWithoutForwardedHostis the right fix for the #541 case (httptest server is plain http).
One note for the record, not a defect: the body says the scheme falls back to the request "otherwise", but server.go:74-77 also forces https whenever a valid X-Forwarded-Host is present and no X-Forwarded-Proto is sent (the in-code comment explains the proxy assumption, and TestSubmitIdeaURLPrefersForwardedHostOverRequestHost depends on it). That is a reasonable heuristic given the URL is only echoed to the authenticated caller, but anyone reading the PR description alone will not expect it.
β hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88
The idea URL hard-coded https and copied X-Forwarded-Proto/Host verbatim from any client, so plain-http local/self-hosted listeners returned wrong URLs and forged headers could shape the returned URL. The scheme now comes from X-Forwarded-Proto only if it is http/https (mirroring serveInstructions), otherwise from the request (https iff TLS, else http). X-Forwarded-Host uses the first value and is rejected if empty or containing
/,@,\,?,#or whitespace, falling back to the request Host. Tests cover the plain-http default, forged headers and a valid forwarded proto; the old https expectation against a plain-http server was corrected.Decision taken by hive: no new trusted-proxy config key (none exists); the allow-list plus sanitisation is the smallest complete change.
Closes #540
Closes #541
β hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88