Repository navigation
fix(security): redact custom credential header names - #1057
github-actions[bot] merged 2 commits into
Conversation
|
Thanks for this — the segment-matching idea is exactly right, and the There is one blocker before this can land, though: widening
func maskedHeaderValue(key, value string) string {
if sensitiveHeaders[strings.ToLower(key)] { // <- not isSensitiveHeaderKey
return MaskValue(value)
}
return RedactSensitiveData(value)
}So for a header that is newly caught by the segment matcher, the read path emits func TestMaskRoundTrip(t *testing.T) {
stored := map[string]string{"X-Custom-Secret": "supersecretvalue"}
read := RedactStringHeaders(stored) // "••••ue (16 chars)"
incoming := map[string]string{"X-Custom-Secret": read["X-Custom-Secret"]}
out := oauth.UnmaskHeaders(incoming, stored)
// got "••••ue (16 chars)", want "supersecretvalue"
assert.Equal(t, stored["X-Custom-Secret"], out["X-Custom-Secret"])
}That path is live in two places — The fix should be a one-liner — switch Two non-blocking notes while you're in here:
Happy to re-review as soon as the unmask side is updated. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…so UnmaskHeaders round-trips
RedactStringHeaders now masks custom credential headers via
isSensitiveHeaderKey, but maskedHeaderValue still consulted the narrow
8-entry sensitiveHeaders map. maskedHeaderValue is the write-path inverse
used by UnmaskHeaders to recognise an echoed-back mask, and the contract in
unmaskMapValues is that rendered(key, storedValue) must reproduce exactly
what the read path emitted for that pair.
For a newly-caught header the read path emitted a mask the write path did
not recognise, so an unedited echo fell through as a genuine edit and
persisted the mask over the real credential. Live on both write paths:
PATCH /api/v1/servers/{id} (internal/httpapi/server.go) and the
upstream_servers patch (internal/server/mcp.go).
Point maskedHeaderValue at isSensitiveHeaderKey, mirroring the env side
where maskedEnvValue already defers to isSensitiveEnvKey. Adds a
round-trip regression test covering X-Custom-Secret, X-Client-Credential
and access_token; it fails with this one-line change reverted.
|
Pushed a maintainer commit (7a7407c) landing the round-trip fix from the review above — everything else is untouched, and the redaction scope stays exactly as you designed it. The one-line change: Also added a round-trip regression test ( |
|
Verified Local verification passed:
The PR Build rerun and the remaining CI checks are green as well. I am keeping the plural/digit variants and the broader |
4d30624
into
smart-mcp-proxy:main
|
Merged — thank you for this: custom credential headers like |
|
Really glad to see this merged — the round-trip review made the fix stronger. I appreciated the thoughtful collaboration and look forward to contributing again! |
Pull Request
Description
Known credential headers such as
AuthorizationandX-API-Keyare redacted in server listings and logs, but custom names such asaccess_token,X-Custom-Secret, andX-Client-Credentialcan currently expose an opaque value unchanged. The fallback value scanner cannot identify a secret when the value itself has no recognizabletoken=orsecret=prefix.This change centralizes header-name classification in
isSensitiveHeaderKey, preserves the existing exact-name list, and additionally recognizes delimiter-separated credential segments. The same classifier is used by bothRedactHeadersandRedactStringHeaders.Negative regression coverage keeps non-sensitive names such as
X-Author-IDandX-Monkey-IDreadable, avoiding the false positives introduced by raw substring matching.Related context: #872 and #875.
Testing
Behavioral verification:
access_token,X-Custom-Secret, andX-Client-Credential.X-Author-IDandX-Monkey-ID.