Repository navigation
fix(fsregion): refuse cross-origin redirects for the credential-bearing region catalog request - #95
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A critical security issue remains because the Digest-authenticated fsregion client can inherit a caller-provided CheckRedirect policy instead of enforcing SameOriginRedirect, risking cross-origin redirect following and credential leakage (with an additional minor endpoint-validation error-message clarity nit).
2 open issues
What changed in this PR
Hardens the filesystem region-catalog fetch path to prevent credential leakage via cross-origin redirects when using Digest authentication by enforcing a same-origin redirect policy and validating the catalog endpoint.
Changes:
- Centralize a shared same-origin-only redirect policy in
internal/api/transportand reuse it across credential-bearing clients. - Update
internal/fsregionto apply the redirect policy, surface refused redirects with a dedicated error code, and validate catalog endpoints before any request. - Add unit tests for redirect and endpoint-validation behavior, and document the credential-safe redirect rule.
| File | Description |
|---|---|
| README.md | Documents the credential-safe redirect rule and security constraints around the filesystem region catalog endpoint and redirects. |
| internal/fsregion/fsregion_test.go | Adds tests covering cross-origin redirect refusal, same-origin redirect following, caller-supplied client behavior, and insecure endpoint rejection. |
| internal/fsregion/client.go | Implements same-origin redirect handling for the Digest-authenticated region-catalog request and validates the catalog endpoint (scheme/host and disallowed components). |
| internal/api/transport/transport.go | Introduces shared helpers/constants for credential-safe redirect handling (same-origin checks, redirect cap, and redirect errors). |
| internal/api/transport/transport_test.go | Adds unit tests validating the shared redirect policy behavior (same-origin allowed, cross-origin refused, and redirect-limit handling). |
| internal/api/client.go | Switches the internal API client to use the shared redirect policy and origin-check helpers from internal/api/transport. |
| AGENTS.md | Codifies the repository rule that credential-bearing HTTP clients must not use a nil CheckRedirect and must refuse cross-origin redirects. |
Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
e049c6d to
07bc328
Compare
mornyx
left a comment
There was a problem hiding this comment.
Review summary
This PR closes the cross-origin credential-leakage vector on the Digest-authenticated Filesystem region catalog client by extracting the same-origin redirect policy into internal/api/transport, composing caller-supplied policies through SameOriginThen across both internal/fsregion and internal/api, and validating the catalog origin before any round trip. Both items raised earlier on the thread—caller CheckRedirect widening and folded endpoint-validation messages—are cleanly resolved and verified on 07bc328. Under a strict maintainability and security bar, there are no merge blockers, though two non-blocking follow-ups around shared origin validation (including secret redaction on rejected URLs) and broadening the repo-wide credential-redirect invariant to cover Basic-auth SQL HTTP requests are worth addressing.
What looks good
- Extracting
SameOriginRedirect,SameOriginThen,SameOrigin,MaxRedirects, andErrTooManyRedirectsintointernal/api/transportpicks the clean package boundary shared byinternal/apiandinternal/fsregionwithout creating import cycles. SameOriginThenenforces the origin check and redirect cap before delegating to any caller-suppliedCheckRedirect, closing the caller-client widening seam in bothinternal/fsregionandinternal/apiwithout mutating caller-owned*http.Clientvalues.- Cross-origin redirect refusals surface a dedicated
api.fs_regions_redirect_refusedcode naming onlyscheme://hostfrom the targetLocation, and tests verify zero outbound requests hit the second origin under a Digest401challenge.
Should fix (non-blocking, strong)
1. Deduplicate fsregion origin validation and avoid echoing embedded secrets in rejected endpoint errors
Client.Fetch (internal/fsregion/client.go:77-90) duplicates the secure-origin validation already in NormalizeServiceAddress (internal/fsregion/fsregion.go:156-166) inside the same package with inverted check ordering (User/RawQuery/Fragment before Scheme in client.go, vice versa in fsregion.go). More importantly, right after detecting parsedBase.User != nil || parsedBase.RawQuery != "" || parsedBase.Fragment != "" (internal/fsregion/client.go:81-83), %q formats the raw baseURL into the returned apperr.Error, which prints embedded userinfo passwords or query tokens in cleartext to stderr (for example, "https://user:pass@fs.tidbapi.com" in TestFetchRejectsInsecureCatalogEndpoint includes "pass" in the error message). Both copies also check parsed.Host == "" rather than parsed.Hostname() == "" (allowing port-only inputs like "https://:8443") and miss parsed.ForceQuery (trailing ?).
- Fix: Extract one unexported origin-validation helper in
internal/fsregionshared byClient.FetchandNormalizeServiceAddressthat enforces a single check order, requiresparsed.Hostname() != ""and!parsed.ForceQuery, and stripsUser/RawQuery/Fragment(plus appliesapitransport.Redactoron unparseable inputs) before formatting the rejected endpoint into an error message.
2. Broaden the CheckRedirect invariant beyond Digest/Bearer and align internal/db/sqlhttp
AGENTS.md:1071 states that every credential-bearing client must use transport.SameOriginRedirect, whereas AGENTS.md:1080-1081 narrows the prohibition to clients carrying "Digest or Bearer credentials" (mirroring the assumption that net/http strips header-based Authorization on cross-origin redirects). In Go's net/http (shouldCopyHeaderOnRedirect), plain Authorization headers such as req.SetBasicAuth are still copied across https -> http scheme downgrades on the same host, port changes on the same hostname, and redirects to subdomains, while custom credential headers (such as X-TiDBCloud-Private-Key) are copied across all hosts. Currently, internal/db/sqlhttp/sqlhttp.go:41-44 still constructs &http.Client{Timeout: 30 * time.Second} with a nil CheckRedirect (and leaves opts.HTTPClient.CheckRedirect unwrapped) when sending Basic-authenticated SQL requests.
- Fix: Broaden the rule in
AGENTS.mdto cover all credential-bearing HTTP clients (Digest, Bearer, Basic, and custom credential headers), and wireapitransport.SameOriginThenintointernal/db/sqlhttphere or in an immediate follow-up PR.
Nits
internal/api/client.go:29,280&internal/fsregion/client.go:152-161:var sameOriginRedirect = apitransport.SameOriginRedirectininternal/api/client.gois now dead production code (only referenced byTestSameOriginRedirectRulesininternal/api/redirect_test.go:169, which duplicatestransport_test.go), andfsregion.Client.httpClient()allocates a default&http.Clientthat is immediately discarded whenc.HTTPClient != nil. Sinceapitransport.SameOriginThen(nil)returnsSameOriginRedirect,httpClient()can copy-and-configure a singlehttp.Clientvalue just likeinternal/api.New.internal/api/transport/transport.go:27,56: Now thatSameOriginRedirectandSameOriginare exported functions, guardingreq == nil || req.URL == nil || len(via) == 0 || via[0] == nil(returninghttp.ErrUseLastResponse) anda != nil && b != nil && a.Scheme != "" && a.Host != "" && strings.EqualFold(a.Scheme, b.Scheme)avoids nil/empty-slice panics on direct callers (noteinternal/fsregion/client.go:178checksresponse.Request != nilwithout checkingresponse.Request.URL != nil).README.md:229: Theti fs list-regionsuser documentation mentions internal GoCheckRedirectcaller-policy composition and loopbackhttptest servers; keeping user-visible redirect refusal (api.fs_regions_redirect_refused) inREADME.mdwhile leaving Go test-seam mechanics inAGENTS.mdwould keep the CLI README focused on user-facing behavior.
Recommendation
Comment. No merge-blocking defects remain on current HEAD, with two non-blocking maintainability and security-hardening improvements recommended above.
07bc328 to
de48d2d
Compare
|
Addressed Should-fix 1 — shared origin validation, and no secrets in rejected-endpoint errors. Should-fix 2 — the invariant now covers every credential-bearing client, and sqlhttp is wired. Nits.
Verification at |
mornyx
left a comment
There was a problem hiding this comment.
Review summary
Re-reviewing de48d2d confirms that all items from the previous round—shared parseSecureOrigin validation, credential-bearing coverage for internal/db/sqlhttp and AGENTS.md, SameOrigin/SameOriginRedirect nil safety, dead-code cleanup in internal/api, and README.md trimming—landed cleanly without regressions or caller http.Client mutation. Under a strict maintainability and security bar, there are no merge blockers; two non-blocking edge cases in the newly added sqlhttp redirect classification/logging and describeRejectedOrigin's field-denylist sanitization are worth tightening.
What looks good
- Extending
transport.SameOriginThentointernal/db/sqlhttpclosesnet/http'sAuthorizationforwarding acrosshttps -> httpdowngrades, port changes, and subdomain hops for Basic-authenticated SQL requests, backed by zero-attacker-hit tests. parseSecureOriginunifiesClient.FetchandNormalizeServiceAddressunder a single validation path covering port-only hosts (:8443),ForceQuery(trailing?), and standardscheme://user:pass@host?query#fragredaction.- Nil and empty-
viaguards ontransport.SameOriginandtransport.SameOriginRedirectfail closed cleanly for direct callers.
Should fix (non-blocking, strong)
1. Guard sqlhttp 3xx refusal on cross-origin Location (shared helper) and record db.sql_http_redirect_loop in oplog
Unlike internal/api/client.go and internal/fsregion/client.go, which only classify a 3xx as redirect_refused when res.Location() resolves to a different origin, sqlhttp.Execute (internal/db/sqlhttp/sqlhttp.go:92-96) maps every 300 <= res.StatusCode < 400 response to db.sql_http_redirect_refused. If a caller supplies a stricter CheckRedirect (such as refusing all redirects, explicitly supported by SameOriginThen) and receives a same-origin 302, refusedSQLRedirectError emits the self-contradictory message "refused a SQL HTTPS API redirect from <origin> to <origin>: ti follows redirects only within the same scheme and host", and Location-less 3xx responses (e.g. 304) are misclassified instead of falling through to statusError(res). In addition, recordSQLHTTPEvent (internal/db/sqlhttp/sqlhttp.go:84,141-144) always logs ErrorCode: "db.sql_http_network" to oplog even when Execute returns db.sql_http_redirect_loop.
- Fix: Extract a small helper in
internal/api/transport(e.g.CrossOriginRedirect(res *http.Response, fallbackReq *http.Request) (fromOrigin, toOrigin string, ok bool)) shared acrossinternal/api,internal/fsregion, andinternal/db/sqlhttpso same-origin caller refusals andLocation-less3xxresponses fall through to normal status handling without three-way duplication, and setevent.ErrorCode = "db.sql_http_redirect_loop"inrecordSQLHTTPEventwhenerrors.Is(requestErr, transport.ErrTooManyRedirects).
2. Use a scheme://host allowlist in describeRejectedOrigin so Opaque / Path inputs cannot echo secrets
describeRejectedOrigin (internal/fsregion/fsregion.go:199-213) clears a field denylist (User, RawQuery, ForceQuery, Fragment) before calling copied.String(). For malformed inputs without //—such as "https:user:secret@fs.tidbapi.com" (Opaque = "user:secret@..."), "user:secret@fs.tidbapi.com", or a raw token accidentally pasted in place of a URL (Path = "ti_fs_...")—url.Parse leaves User == nil and Hostname() == "", so parseSecureOrigin returns (parsed, errOriginNeedsHost) and copied.String() still echoes Opaque or Path verbatim to stderr. Relatedly, parseSecureOrigin (internal/fsregion/fsregion.go:177) checks parsed.Hostname() == "" without parsed.Scheme == "", causing scheme-relative "//fs.tidbapi.com" to report errOriginInsecureScheme instead of errOriginNeedsHost.
- Fix: Check
if parsed.Scheme == "" || parsed.Hostname() == ""forerrOriginNeedsHostinparseSecureOrigin, and replace the four field resets indescribeRejectedOriginwith an explicitscheme://hostallowlist: format(&url.URL{Scheme: parsed.Scheme, Host: parsed.Host}).String()only whenparsed != nil && parsed.Opaque == "" && parsed.Scheme != "" && parsed.Hostname() != ""(leavingdisplay = ""otherwise), and add an opaque-URL case toTestRejectedOriginsNeverEchoSecrets.
Nits
internal/api/transport/transport_test.go:132&internal/db/sqlhttp/sqlhttp_test.go:219: WhenTestSameOriginRedirectRuleswas consolidated frominternal/api/redirect_test.go, the same-host port-mismatch case (:8443) and directnil/empty-viaassertions were not carried over totransport_test.go; andTestExecuteHTTPFollowsSameOriginRedirectuses302 Found(which convertsPOSTto a bodylessGET) rather than307 Temporary RedirectassertingPOST, JSON body, andBasicAuthpreservation on/moved.
Recommendation
Comment. All prior findings and cross-origin credential-redirect protections are verified on de48d2d with no merge blockers; two non-blocking edge-case cleanups in the newly added helpers are recommended above.
de48d2d to
4968670
Compare
|
Second round addressed on head Should-fix 1 — shared cross-origin classifier, and the oplog no longer contradicts the error. Added
Tests: Should-fix 2 — Nits. Verification at |
mornyx
left a comment
There was a problem hiding this comment.
Review summary
Re-reviewing 4968670 confirms that all items from the previous round—shared transport.CrossOriginRedirect wiring across all three clients, db.sql_http_redirect_loop operation-log consistency, the scheme://host allowlist in describeRejectedOrigin, //host handling in parseSecureOrigin, and the expanded 307/port-mismatch/opaque-URL test cases—landed cleanly with no merge blockers. Under a strict correctness and maintainability bar, one non-blocking logic bug remains in the newly exported transport.CrossOriginRedirect helper around relative Location resolution on its fallbackReq path and originless redirect targets.
What looks good
- Consolidating redirect classification behind
transport.CrossOriginRedirectremoves the three-way duplication acrossinternal/api,internal/fsregion, andinternal/db/sqlhttpwhile keeping caller-refused same-origin redirects on their normal status path. describeRejectedOriginnow uses a strictscheme://hostallowlist (Opaque == "" && Scheme != "" && Hostname() != ""), verified against opaque URLs and pasted-token inputs inTestRejectedOriginsNeverEchoSecrets.TestExecuteHTTPFollowsSameOriginRedirect(307preservingPOST, body, andBasicAuth) andTestExecuteHTTPRecordsRedirectLoopEventpin both the wire behavior andoplogerror-code contract.
Should fix (non-blocking, strong)
1. Resolve Location against req.URL and reject empty origins in transport.CrossOriginRedirect
CrossOriginRedirect (internal/api/transport/transport.go:63-79) accepts fallbackReq for responses without res.Request, sets req = fallbackReq when res.Request == nil, and then calls res.Location() (internal/api/transport/transport.go:74). In Go's net/http, (*http.Response).Location() resolves relative Location headers only against res.Request.URL and falls back to bare url.Parse when res.Request == nil. As a result, whenever fallbackReq is exercised (custom RoundTrippers or direct callers), a relative same-origin redirect such as Location: /other parses without scheme or host, fails SameOrigin, and is misclassified as a cross-origin redirect with toOrigin == "" (ok == true), while Location: //evil.example/other also yields toOrigin == "". In addition, even when res.Request != nil, an originless Location such as about:blank, https:///moved, or https://:8443/moved causes CrossOriginRedirect to return ok == true with an empty (or port-only) toOrigin, producing "refused a ... redirect from https://... to : ...".
- Fix: Fall back to
fallbackReqwheneverres.Request == nil || res.Request.URL == nil, resolveres.Header.Get("Location")directly viareq.URL.Parse(location), requireu.Opaque == "" && u.Scheme != "" && u.Hostname() != ""inOrigin(andSameOrigin), and return("", "", false)iffromOrigin == "" || toOrigin == "". Add relativeLocation: "/other"/"//evil.example/other"(withres.Request == niland non-nilfallbackReq) and originlessLocationcases toTestCrossOriginRedirectClassification.
Nits
internal/fsregion/client.go:174&internal/fsregion/fsregion.go:200: PassingrequestintoreadCatalogPagesoCrossOriginRedirect(response, request)receives the fallback request matchesinternal/apiandinternal/db/sqlhttp; and oncetransport.OriginchecksOpaque == "" && Hostname() != "",describeRejectedOrigincan callapitransport.Origin(parsed)directly instead of repeating the allowlist condition.
Recommendation
Comment. All credential-redirect protections and prior round fixes hold on 4968670 with no merge blockers; tightening transport.CrossOriginRedirect for relative fallbackReq and originless Location headers is recommended above.
…TTP clients
`fsregion.Client.httpClient()` built `&http.Client{Transport, Timeout}` with a nil
`CheckRedirect`, so net/http followed up to ten redirects to any scheme and any
host. That request is Digest-authenticated with the organization API key pair, and
the digest transport answers whatever 401 challenge it receives, so a redirect to
an attacker-chosen origin made ti compute and send a Digest response for that
host - the exact credential exposure this hardening closes. The mutation check in
the new test shows it: with the policy removed, the second origin's 401 challenge
is answered (the fake attacker returns `auth.invalid_credentials`), and with the
policy in place the second origin receives no request at all.
- Move the existing same-origin redirect policy out of `internal/api` into
`internal/api/transport` (`SameOriginRedirect`, `SameOrigin`, `SameOriginThen`,
`MaxRedirects`, `ErrTooManyRedirects`, nil-safe for direct callers) so the
credential-bearing clients cannot drift.
- A caller-supplied `CheckRedirect` is composed through `SameOriginThen`: it runs
after the mandatory same-origin rule, so a caller can narrow redirects (refuse
all of them) but can never re-enable a cross-origin hop. `internal/api` and
`internal/fsregion` both use it, closing the seam on each client.
- Extend the rule to the Basic-authenticated SQL HTTPS transport
(`internal/db/sqlhttp`): net/http still copies `Authorization` across same-host
port changes, subdomain redirects, and https->http downgrades.
- Classify redirects through one shared helper (`transport.CrossOriginRedirect`,
which resolves the Location header against the request URL - including when the
response carries no request - reduces both sides to `scheme://host`, and refuses
to report an originless target): a same-origin redirect refused by a stricter
caller policy falls through to normal status handling instead of being reported
as an origin change that never happened. A refused cross-origin
redirect reports `db.sql_http_redirect_refused`; a same-origin loop reports
`db.sql_http_redirect_loop`, and the operation log records that same code
instead of contradicting the command error with `db.sql_http_network`.
- A refused catalog redirect reports `api.fs_regions_redirect_refused` naming both
origins instead of a generic catalog failure.
- Share one origin validator (`parseSecureOrigin`) between the catalog endpoint and
published service addresses: absolute, host name required, no embedded
credentials, query (including a bare "?"), or fragment, and https except for a
loopback test server. Rejected origins are described through
`describeRejectedOrigin`, which formats an explicit `scheme://host` allowlist, so
neither a password in userinfo/query nor a secret carried by an Opaque or Path
value can reach stderr. A scheme-relative `//host` input is reported as missing
a scheme and host.
Tests: transport `TestSameOriginRedirectKeepsCredentialsOnTheSameOrigin` and
`TestSameOriginThenKeepsCallerRestrictionsWithoutWidening`; fsregion
`TestFetchRefusesCrossOriginRedirect` (zero requests at the second origin),
`TestFetchAppliesRedirectPolicyToCallerClient`,
`TestFetchEnforcesSameOriginUnderCallerRedirectPolicy`,
`TestFetchHonorsStricterCallerRedirectPolicy`,
`TestFetchFollowsSameOriginRedirect`, `TestFetchRejectsInsecureCatalogEndpoint`
(per-case messages), and `TestRejectedOriginsNeverEchoSecrets`; sqlhttp
`TestExecuteHTTPRefusesCrossOriginRedirect` (plus the caller-policy variant),
`TestExecuteHTTPFollowsSameOriginRedirect`, and
`TestExecuteHTTPReportsRedirectLoop`. internal/api pins the no-widening rule on
its caller-client seam.
Verification: gofmt, `go vet ./...` on linux/darwin/windows, `go test -count=1
./...`, `make e2e`.
4968670 to
3e8a42f
Compare
|
Third round addressed on head
Nits. Verification at |
mornyx
left a comment
There was a problem hiding this comment.
Review summary
Re-reviewing 3e8a42f confirms that every item from the previous rounds is cleanly resolved: transport.CrossOriginRedirect now falls back whenever res.Request == nil || res.Request.URL == nil, resolves Location directly against req.URL, and rejects originless targets via Origin and SameOrigin, while fsregion passes the request fallback into readCatalogPage and reuses transport.Origin directly in describeRejectedOrigin. Across internal/api/transport, internal/api, internal/fsregion, and internal/db/sqlhttp, credential-bearing redirect enforcement, cross-origin classification, and redacted endpoint validation sit cleanly in their canonical layers with no remaining correctness, security, or maintainability issues.
What looks good
internal/api/transportprovides one cohesive, non-widening boundary (SameOriginRedirect,SameOriginThen,CrossOriginRedirect,Origin,SameOrigin) shared across Digest, Bearer, and Basic-auth clients without mutating caller*http.Clientinstances.parseSecureOriginanddescribeRejectedOrigin(backed bytransport.Origin) enforce identical HTTPS/loopback rules across catalog endpoints and published service addresses while ensuring malformed, opaque, or credential-bearing inputs never echo secrets tostderr.- Behavioral and negative tests cover zero-attacker-hit guarantees across all three clients,
307POSTbody andBasicAuthpreservation, stricter caller-policy fallthrough,oplogloop error-code alignment, and relative/originlessLocationmatrices.
Recommendation
Approve. All credential-redirect protections, error-redaction guarantees, and structural cleanups are verified on 3e8a42f with no remaining issues.


The Filesystem region catalog client built its HTTP client as
&http.Client{Transport: digestTransport, Timeout: catalogTimeout}with a nilCheckRedirect, so Go's default policy followed up to ten redirects to any host and any scheme.That request is the one place
tipresents the organization API key pair to a non-user-chosen URL, and it does so throughinternal/api/transport.NewDigest. A Digest transport answers whatever 401 challenge it receives, so a redirect to an attacker's origin makesticompute and send a Digest response for that origin — the credentials leak exactly as reported. (net/httpstripsAuthorizationon cross-host redirects for plain header-based clients, but that protection does not apply to a transport that recomputes the header.)Fix
internal/apimoved intointernal/api/transport(SameOriginRedirect,SameOrigin,MaxRedirects,ErrTooManyRedirects). Both credential-bearing clients now use it:internal/apikeeps mapping a same-origin redirect loop toapi.redirect_loop, andinternal/fsregionapplies the same policy to its Digest client, including the caller-supplied-client seam the resolver uses.api.fs_regions_redirect_refusednaming both origins, instead of collapsing into a generic catalog failure.transport.SameOriginThen(caller)runs the mandatory same-origin rule first and then the caller's policy, so a caller can narrow redirects (refuse all of them) but never re-enable a cross-origin hop. Bothinternal/fsregionandinternal/apicompose their caller-client seam through it;internal/apihad the same widening hole.FetchandNormalizeServiceAddressshareparseSecureOrigin: absolute, host name required, no embedded credentials, query (including a bare?), or fragment, andhttpsexcept for a loopback test server — checked before any round trip, because this request spends the organization API key pair.describeRejectedOriginstrips userinfo/query/fragment and parse errors never echo the raw string, so a password or token in the URL cannot reach stderr.transport.CrossOriginRedirectreduces both origins toscheme://hostand reports false for a same-origin redirect, aLocation-less3xx, and a non-redirect, so a same-origin redirect refused by a stricter caller policy falls through to normal status handling (instead of a self-contradictory "from X to X"). The SQL operation log recordsdb.sql_http_redirect_looprather than contradicting the command error withdb.sql_http_network.internal/db/sqlhttp(Basic-authenticated SQL HTTPS requests) now composestransport.SameOriginThentoo and reportsdb.sql_http_redirect_refused/db.sql_http_redirect_loop; net/http still copiesAuthorizationacross same-host port changes, subdomain redirects, and https→http downgrades, so it needed the same treatment.Verification
internal/api/transport:TestSameOriginRedirectKeepsCredentialsOnTheSameOrigin— same-origin path and case-folded host followed; other host and other scheme refused withhttp.ErrUseLastResponse; the redirect chain stops atMaxRedirects.internal/fsregion:TestFetchRefusesCrossOriginRedirect(error code plus zero requests reaching the second origin),TestFetchAppliesRedirectPolicyToCallerClient,TestFetchEnforcesSameOriginUnderCallerRedirectPolicy(a permissive caller policy cannot widen it),TestFetchHonorsStricterCallerRedirectPolicy(a caller that refuses all redirects still narrows),TestFetchFollowsSameOriginRedirect(ordinary same-origin redirects still work),TestFetchRejectsInsecureCatalogEndpoint(http://non-loopback,ftp://, userinfo, query, fragment, and scheme-less values, with the expected message per case; loopbackhttpstill reaches the server).internal/apipins the no-widening rule on its own caller-client seam.internal/api/transport:TestSameOriginThenKeepsCallerRestrictionsWithoutWidening.internal/fsregion:TestRejectedOriginsNeverEchoSecrets(no password or query token in either error path, including opaque URLs and a pasted token as the path).internal/api/transport:TestCrossOriginRedirectClassificationandTestSameOriginRedirectFailsClosedOnMissingInput(also covers the same-host port change).internal/db/sqlhttp:TestExecuteHTTPRefusesCrossOriginRedirect(attacker origin receives zero requests), the permissive-caller-policy variant,TestExecuteHTTPFollowsSameOriginRedirect(307keeps the authenticatedPOSTand body),TestExecuteHTTPSameOriginRedirectRefusedByCallerFallsThrough,TestExecuteHTTPRecordsRedirectLoopEvent, andTestExecuteHTTPReportsRedirectLoop(mutation-checked: without the composition the attacker receives the Basic-auth request).CheckRedirectremoved, the cross-origin test fails because the attacker's 401 challenge is answered (auth.invalid_credentialsfrom the attacker's realm). With the policy in place the attacker receives no request.gofmtclean;go vet ./...clean on linux,GOOS=windows,GOOS=darwin;go test -count=1 ./...passes;make e2epasses.README.mdandAGENTS.mddocument the rule: a credential-bearing client must never be built with a nilCheckRedirect.