Skip to content

Commit cac0539

Browse files
authored
fix(security): stop credentials reaching logs, stdout and structured errors (#1181)
* fix(security): stop credentials reaching logs, stdout and structured errors (#1158) A default `mcpproxy serve` at DEBUG published an argv secret 12 times and a URL-query secret 8 times in a 20-second startup, with no trace mode enabled. Verified on a live instance: 24 cleartext occurrences across main.log, server-<name>.log and the terminal, now 0. Four classes, four rules, all routed through seams the #1148/#1157 sweep already built rather than a new matcher. 1. Spawn argv. Every spawn log site used shellwrap.RedactDockerArgs alone - a STRUCTURAL rule that masks the value half of `-e KEY=VALUE` and is blind to `--api-key sk-live-...`. New oauth.Redaction.SpawnArgv / SpawnCommandString compose it with the SEMANTIC flag-name + value-shape rule (Redaction.Argv) and reach inside the single `-c "<whole command line>"` element the login-shell wrap produces - the form that actually leaked, since every non-docker stdio server on macOS spawns that way. Redaction.Argv itself is untouched: it backs the read doors and CheckArgvMaskEcho on the write doors, so the spawn rule has to be additive and log-only. There is deliberately no "already masked, skip" guard between the two stages - the bullet marker carries no character in secretPattern's value class, so stage 2 is provably a no-op on a stage-1 rendering, and a whole-token guard would silence stage 2 for an entire command string as soon as one benign `-e` put a marker in it. 2. The OAuth authorization URL - the largest leak, and one the site list missed. autoDetectResource returns the configured server URL verbatim on every fallback branch, that becomes extraParams["resource"], and all THREE authorize-URL emission paths splice it into the query and then log it at INFO and print it with fmt.Printf. Both sinks on all three paths now go through logSafeAuthURL, and the per-value extra-param Debug lines through Redaction.ExtraParamValue. The credential arrives percent-encoded one level down, where neither the sensitive-parameter name rule nor secretPattern can see it, so URLValueDeep decodes one nesting level. maskExtraParams no longer treats `resource` as a public endpoint. 3. URL log fields inside internal/oauth (~75 sites across discovery.go, config.go, transport_wrapper.go, persistent_token_store.go), plus the configured-URL field in runtime.go and the registry-source URLs in internal/server. They use the AUDIT rendering, not the name-rule-only RedactURLQueryParams the issue names, because a credential under an unrecognised parameter name still reached the log otherwise. url.URL.Redacted() is not used anywhere - it masks the userinfo password and leaves `?token=` intact. 4. The structured OAuth error is scrubbed where it is BUILT (createMetadataError and the seven contracts.OAuthErrorDetails literals), not where it is serialized: the encoder sees an opaque struct and cannot know which leaves are URLs, and every future consumer inherits the fix. Also: the trace transport's stdout Printf copies and zap fields (URL, headers, request/response bodies, SSE frames) - both sinks or neither; logSafeErrorField upgraded to ScrubUpstreamText; the launcher's startup banner takes an injected Spec.RedactArgs whose nil default OMITS argv, so a future caller that forgets it loses a diagnostic rather than a secret. Diagnostics are preserved throughout: flag names, env KEY names, and each URL's scheme/host/path survive; only values are replaced. Two AST guard tests derive the rule from the source across BOTH internal/oauth and internal/upstream/core, so the next URL log field or a re-raw'd authorize-URL Printf fails CI rather than shipping. Behaviour change to note: log lines, `mcpproxy upstream logs`, the `upstream_servers tail_log` MCP tool, `mcpproxy auth status/login` output and the 400 body of POST /api/v1/servers/{id}/login now render masked values where they previously showed cleartext. No config, storage, contract or frontend change. * fix(security): close the OAuth code, error-text and quoting gaps the first pass left Round-2 cross-review of #1158. Seven blocking/major findings, three confirmed minors, three judged-then-fixed, and one design comment that was simply wrong. The sharpest was pre-existing on main rather than introduced here: the OAuth CALLBACK handler logged the authorization CODE at Info, plus the whole raw callback query, on every single login. The code is a single-use credential redeemable at the token endpoint, and it sat in ~/.mcpproxy/logs/main.log for the window before mcpproxy spent it — forever, for a flow that never completed. `state` (the CSRF nonce that pairs with it) was on five more lines and inside two operator-visible error messages; it is now a truncated SHA-256, which is all the log lines ever used it for. The rest is one theme: masking a FIELD does not mask the STATEMENT. - A *url.Error renders the request URL inside its own text, so fourteen `zap.Error(err)` calls in discovery.go published, on the identical line, the credential their masked `metadata_url` sibling was written to hide. New logSafeErrorField/LogSafeErrorText in internal/oauth; internal/transport's twin, which had drifted back to the name-rule-only scrubber, rejoins it. - `url_tried` survived raw four lines below a line this branch fixed, along with every `auth_server*` field in discovery.go — because the AST guard's regex was written from the sites already fixed. It now matches `_tried$` and the four auth-server names, and a second guard fails any log statement that carries a URL field and a raw zap.Error together. - contracts.OAuthFlowError was scrubbed field-by-field at seven construction sites, and one got it half right: emptyClientIDFlowError masked Details.ServerURL and set Details.DCRStatus.Error raw on the same struct, which is JSON-encoded straight to the REST caller. One scrubbedFlowError at construction now walks the whole struct, and a third guard requires every literal to go through it. - Client.logSafeURL, managed.Client.logSafeURL, the transport config, the CLI client and the four registry routes rendered with RedactURLQueryParams — the NAME rule only — while this branch's own new renderer deliberately does not, and says why. One exported oauth.LogSafeURL now backs all of them. Two spawn-rule corrections pull in opposite directions and both matter: - The command-string tokenizer split on whitespace only, while the string it is fed comes from Shellescape — so a credential containing a space arrived single-quoted, was split into four tokens, and had exactly its first fragment masked. On the `-c "<whole command line>"` form the original commit calls "the form that actually leaked". The split is now shell-aware (including the `'"'"'` idiom), falling back to whitespace-only when quotes do not balance, because swallowing the rest of a line into one token would be a new leak rather than a safe degradation. - The other direction: IsSensitiveKeyName matches SUBSTRINGS, so applying it to a spawn argv blanked `--max-tokens 4096` and `--public-key-path /etc/x`. The property that makes this redaction acceptable to an operator is that flag names, hosts and ordinary values survive, so the log-only rule now subtracts a short list of qualifier segments (max/min/num/public/…). It keeps the substring match rather than switching to segment EQUALITY, which would have silently un-masked `--apikey` and `--clientsecret`. Three findings were investigated rather than reflexively fixed; all three were genuine and all three are closed. The PRM's own authorization_servers list left createMetadataError unscrubbed beside siblings that were scrubbed. The token endpoint's non-200 BODY was embedded verbatim in the refresh error — provider free text that echoes request parameters, unbounded, logged and returned over REST. And the launched child's stdout/stderr went into the per-server log raw, which matters more than it looks: GET /api/v1/servers/{id}/logs serves that file, so an upstream echoing its own startup banner puts a credential mcpproxy handed it onto an HTTP surface. Finally, the design comment claiming the two-stage spawn composition is provably idempotent was false, and the pinning test used the one fixture that hid it: RedactSensitiveData's sensitiveParams sweep matches `[^&\s]+`, which DOES match the bullet marker, so `SLACK_TOKEN=••••` becomes `SLACK_TOKEN=***REDACTED***` while `API_KEY=••••` does not. The composition is disclosure-safe, not byte-idempotent; the comment now says so and both spellings are pinned. Diagnostics preserved throughout: flag names, env KEY names, hosts, paths, OAuth error codes, DCR status codes and `code_present` all survive. * fix(security): close the two leaks the live check found, at the seams that feed every sink The round-2 live run — a stdio server carrying an argv secret and printing a token on startup, plus an http server with `?token=` and `?opaque=ghp_…` in its URL — still put two credentials in the log after every fix above had landed. Both were the same shape as finding B3 one level further out. `sk-live-…` appeared 8 times because the stdio stderr PUMP (core/monitoring.go) is a different code path from the launcher's loggerWriter. It feeds THREE sinks from one string: main.log, the per-server log that GET /api/v1/servers/{id}/logs serves, and the recent-stderr ring buffer that connectStdio splices into the "did not respond to MCP initialize" error — which is itself logged and returned to REST callers. Scrubbing the line once at the top of the loop covers all three. `ghp_…` appeared 15 times because redactURLCredentialsInError — the ONE seam where a transport error enters mcpproxy, and whose own doc comment says "redacting once, where the transport error enters mcpproxy, is what keeps a future log site from re-leaking it" — ran the NAME rule only. `opaque` is not a recognised parameter name, so the token walked through it and then through managed.Client, upstream.Manager, the supervisor and the runtime, each of which zap.Errors the string it is handed and none of which can be fixed from its own file. ScrubUpstreamText there fixes all four. Also registers the three new exported renderings with the fail-closed net's discovery gate: LogSafeURL and LogSafeCallbackQuery are bound and probed; StateFingerprint is recorded as not-a-rendering, with the reason — it keeps no byte of its input, no read door publishes it and no write door consumes it, so putting a per-value hash into MaskMarkers would be meaningless. Live re-run across seven sinks (three log files, stdout, GET /api/v1/servers and both GET /api/v1/servers/{id}/logs payloads): 0 occurrences of all five planted secrets, while `--api-key`, `--max-tokens 4096`, `--public-key-path /etc/ssl/pub.pem`, the SLACK_TOKEN key name, the upstream host and "connection refused" all survive. * test(security): make the spawn-redaction tests host-independent Both failures were POSIX assumptions in tests added by the #1158 round-2 work, and both are Windows-only. internal/oauth: the -c command-line fixtures were built with shellwrap.Shellescape, which switches on runtime.GOOS and emits cmd.exe double-quoting on Windows - so the sanity assertions looked for a POSIX quote and the ' idiom that were never going to be there. The tokenizer under test handles the POSIX form WrapWithUserShell produces, and a Windows core still reads per-server logs and configs a POSIX host wrote, so the fixture must be POSIX-quoted on every host. Added posixShellescape plus TestPosixShellescape_MatchesProduction, which pins it against the real Shellescape on POSIX - keeping the drift protection that building the fixture from production code was there to provide. internal/upstream/launcher: the banner tests spawned /bin/echo, which does not exist on Windows. Argv redaction in the banner is platform-independent, so rather than skipping the way this package's POSIX signal-semantics tests do, the interpreter is chosen per host and the expected command path travels with it. Verified: both packages pass on darwin, and GOOS=windows go vet is clean.
1 parent 07ea246 commit cac0539

46 files changed

Lines changed: 3204 additions & 293 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎internal/appctx/adapters.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (d *DockerIsolationManagerImpl) StartIsolatedCommand(_ context.Context, com
128128
// For now, this is a placeholder that returns the concept
129129
d.logger.Info("Starting isolated command",
130130
zap.String("command", command),
131-
zap.Strings("args", args),
131+
zap.Strings("args", oauth.AuditRedaction.SpawnArgv(args)),
132132
zap.String("working_dir", workingDir))
133133

134134
return nil, fmt.Errorf("not implemented - would use isolation manager")
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
package oauth
2+
3+
import (
4+
"net/url"
5+
"reflect"
6+
"strings"
7+
"testing"
8+
9+
"github.com/stretchr/testify/assert"
10+
"github.com/stretchr/testify/require"
11+
)
12+
13+
// TestURLValueDeep_MasksTheNestedResourceURL is the guard for the biggest leak
14+
// in #1158.
15+
//
16+
// autoDetectResource returns the CONFIGURED upstream URL verbatim on every
17+
// fallback branch, that value becomes extraParams["resource"], and every
18+
// authorize-URL builder splices each extra param into the query — so the
19+
// authorize URL that is logged at INFO and printed to stdout on every login
20+
// attempt carries `resource=<percent-encoded configured URL with its ?token=>`.
21+
//
22+
// The percent-encoding is what makes this its own rule: neither the
23+
// sensitive-query-parameter NAME rule (which sees one opaque value under the
24+
// name `resource`) nor secretPattern (which needs a literal `=` after `token`,
25+
// not `%3D`) can see the credential at that nesting level.
26+
func TestURLValueDeep_MasksTheNestedResourceURL(t *testing.T) {
27+
const secret = "SUPERSECRETALPHAQUERYVALUE"
28+
upstream := "https://host.example.com/mcp?token=" + secret
29+
authURL := "https://auth.example.com/authorize?client_id=abc123&resource=" +
30+
url.QueryEscape(upstream) + "&state=xyz"
31+
32+
// The rule the design originally proposed is NOT sufficient — pin that, so
33+
// nobody "simplifies" URLValueDeep back to it.
34+
assert.Contains(t, RedactURLQueryParams(authURL), secret,
35+
"sanity: the name-rule-only helper cannot see a credential nested inside a "+
36+
"percent-encoded parameter value; if it can, this test is no longer testing anything")
37+
38+
got := AuditRedaction.URLValueDeep(authURL)
39+
assert.NotContains(t, got, secret, "the nested upstream credential reached the log field")
40+
assert.NotContains(t, got, url.QueryEscape(secret))
41+
42+
// Diagnostics survive: an operator must still see WHICH provider and
43+
// WHICH resource the flow was for.
44+
assert.Contains(t, got, "auth.example.com/authorize")
45+
assert.Contains(t, got, "client_id=abc123")
46+
assert.Contains(t, got, "state=xyz")
47+
assert.Contains(t, got, "host.example.com/mcp",
48+
"the resource endpoint's host and path must survive; only its credential goes")
49+
}
50+
51+
// TestURLValueDeep_MasksTheTopLevelQueryToo — the nesting rule must not replace
52+
// the ordinary one.
53+
func TestURLValueDeep_MasksTheTopLevelQueryToo(t *testing.T) {
54+
const secret = "SUPERSECRETALPHAQUERYVALUE"
55+
got := AuditRedaction.URLValueDeep("https://host.example.com/mcp?token=" + secret)
56+
assert.NotContains(t, got, secret)
57+
assert.Contains(t, got, "host.example.com/mcp")
58+
}
59+
60+
// TestExtraParamValue_MasksResourceCredentials guards the sibling Debug line:
61+
// the authorize-URL builders log every extra parameter's VALUE, and
62+
// maskExtraParams deliberately showed `resource` in full because it was
63+
// documented as "a public endpoint". It is not — it is the configured URL.
64+
func TestExtraParamValue_MasksResourceCredentials(t *testing.T) {
65+
const secret = "SUPERSECRETALPHAQUERYVALUE"
66+
upstream := "https://host.example.com/mcp?token=" + secret
67+
68+
got := AuditRedaction.ExtraParamValue("resource", upstream)
69+
assert.NotContains(t, got, secret)
70+
assert.Contains(t, got, "host.example.com/mcp")
71+
72+
masked := maskExtraParams(map[string]string{"resource": upstream})
73+
assert.NotContains(t, masked["resource"], secret,
74+
"maskExtraParams showed `resource` in full; it carries the configured URL")
75+
}
76+
77+
// TestCreateMetadataError_ScrubsEveryURLLeaf reflect-walks the built error so a
78+
// string field added later is covered without editing this test.
79+
func TestCreateMetadataError_ScrubsEveryURLLeaf(t *testing.T) {
80+
const secret = "SUPERSECRETALPHAQUERYVALUE"
81+
serverURL := "https://host.example.com/mcp?token=" + secret
82+
prmURL := "https://host.example.com/.well-known/oauth-protected-resource?token=" + secret
83+
asURL := "https://host.example.com/.well-known/oauth-authorization-server?token=" + secret
84+
85+
err := createMetadataError("alpha", serverURL, &OAuthMetadataValidationResult{
86+
ProtectedResourceMetadataURL: prmURL,
87+
ProtectedResourceError: &urlBearingError{msg: `Get "` + prmURL + `": 404`},
88+
AuthorizationServerMetadataURL: asURL,
89+
AuthorizationServerMetadataURLsTried: []string{asURL, prmURL},
90+
AuthorizationServerError: &urlBearingError{msg: `Get "` + asURL + `": 404`},
91+
})
92+
require.Error(t, err)
93+
94+
var leaves []string
95+
collectStrings(reflect.ValueOf(err), &leaves)
96+
require.NotEmpty(t, leaves)
97+
98+
sawEndpoint := false
99+
for _, leaf := range leaves {
100+
assert.NotContains(t, leaf, secret,
101+
"a URL-derived leaf of the structured OAuth error is JSON-encoded straight to the client")
102+
if strings.Contains(leaf, "host.example.com") {
103+
sawEndpoint = true
104+
}
105+
}
106+
assert.True(t, sawEndpoint,
107+
"positive control: the endpoint host must SURVIVE. A blanked field would pass the "+
108+
"leak assertion above while destroying the operator's ability to see which URL failed")
109+
}
110+
111+
type urlBearingError struct{ msg string }
112+
113+
func (e *urlBearingError) Error() string { return e.msg }
114+
115+
// collectStrings walks every reachable string leaf of v.
116+
func collectStrings(v reflect.Value, out *[]string) {
117+
switch v.Kind() {
118+
case reflect.String:
119+
if v.String() != "" {
120+
*out = append(*out, v.String())
121+
}
122+
case reflect.Ptr, reflect.Interface:
123+
if !v.IsNil() {
124+
collectStrings(v.Elem(), out)
125+
}
126+
case reflect.Slice, reflect.Array:
127+
for i := 0; i < v.Len(); i++ {
128+
collectStrings(v.Index(i), out)
129+
}
130+
case reflect.Map:
131+
for _, k := range v.MapKeys() {
132+
collectStrings(v.MapIndex(k), out)
133+
}
134+
case reflect.Struct:
135+
for i := 0; i < v.NumField(); i++ {
136+
f := v.Field(i)
137+
if !f.CanInterface() {
138+
continue
139+
}
140+
collectStrings(f, out)
141+
}
142+
default:
143+
}
144+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
package oauth
2+
3+
import (
4+
"fmt"
5+
"net/http"
6+
"net/http/httptest"
7+
"strings"
8+
"testing"
9+
10+
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
12+
"go.uber.org/zap"
13+
"go.uber.org/zap/zaptest/observer"
14+
)
15+
16+
// Issue #1158, review round 2, finding B1.
17+
//
18+
// The OAuth CALLBACK handler logged, at Info, on every single login:
19+
//
20+
// zap.String("query", r.URL.RawQuery) // the whole callback query
21+
// zap.String("code", params["code"]) // the authorization code itself
22+
//
23+
// The authorization code is a single-use credential: presented at the token
24+
// endpoint with the PKCE verifier it yields an access token. It landed in
25+
// ~/.mcpproxy/logs/main.log — a file that outlives the process, is readable by
26+
// anything with disk access, and is served over REST for stdio servers — on
27+
// every OAuth login, with no debug flag involved.
28+
//
29+
// The oracle is the one this issue keeps needing: no RUN of the secret's bytes
30+
// may appear anywhere in the rendered line. A whole-string containment check
31+
// passes against a half-mask.
32+
func assertNoRun(t *testing.T, rendered, secret string, minRun int) {
33+
t.Helper()
34+
for i := 0; i+minRun <= len(secret); i++ {
35+
assert.NotContains(t, rendered, secret[i:i+minRun],
36+
"a %d-byte run of the credential survived into %q", minRun, rendered)
37+
}
38+
}
39+
40+
// newObservedCallbackServer builds a CallbackServer wired to an in-memory log
41+
// sink, with one flow parked on `state` so the delivery path is exercised.
42+
func newObservedCallbackServer(t *testing.T, state string) (*CallbackServer, *observer.ObservedLogs) {
43+
t.Helper()
44+
core, logs := observer.New(zap.DebugLevel)
45+
cs := &CallbackServer{
46+
ServerName: "alpha",
47+
logger: zap.New(core),
48+
waiters: make(map[string]chan map[string]string),
49+
}
50+
if state != "" {
51+
cs.RegisterState(state)
52+
}
53+
return cs, logs
54+
}
55+
56+
func renderedLines(logs *observer.ObservedLogs) string {
57+
var b strings.Builder
58+
for _, entry := range logs.All() {
59+
b.WriteString(entry.Message)
60+
for k, v := range entry.ContextMap() {
61+
fmt.Fprintf(&b, " %s=%v", k, v)
62+
}
63+
b.WriteString("\n")
64+
}
65+
return b.String()
66+
}
67+
68+
func TestCallbackHandlerNeverLogsTheAuthorizationCode(t *testing.T) {
69+
const code = "AUTHCODEwqYnFsUD0Rk4pQ3v7XcJ2m"
70+
const state = "STATENONCE9fbc41aa7d2e"
71+
72+
cs, logs := newObservedCallbackServer(t, state)
73+
74+
req := httptest.NewRequest(http.MethodGet, DefaultRedirectPath+
75+
"?code="+code+"&state="+state+"&scope=read%20write", nil)
76+
rec := httptest.NewRecorder()
77+
cs.handleCallback(rec, req)
78+
79+
out := renderedLines(logs)
80+
require.NotEmpty(t, out, "the handler must still log — a fix that deletes the line is not the fix")
81+
82+
assertNoRun(t, out, code, 6)
83+
assertNoRun(t, out, state, 6)
84+
85+
// The diagnostics the lines exist for must survive.
86+
assert.Contains(t, out, "code_present=true",
87+
"an operator still needs to know whether the provider returned a code at all")
88+
assert.Contains(t, out, "scope=read write",
89+
"non-credential callback parameters must stay readable")
90+
assert.Contains(t, out, StateFingerprint(state),
91+
"the state fingerprint is what correlates the callback with the flow that minted it")
92+
}
93+
94+
// A callback that carries no code (the provider reported an error instead) must
95+
// still be diagnosable, and the provider's own free text must be scrubbed.
96+
func TestCallbackHandlerScrubsProviderErrorText(t *testing.T) {
97+
cs, logs := newObservedCallbackServer(t, "S-unknown-flow")
98+
99+
req := httptest.NewRequest(http.MethodGet, DefaultRedirectPath+
100+
"?error=invalid_request&error_description=bad+redirect+for+token%3Dghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789&state=S-unknown-flow", nil)
101+
rec := httptest.NewRecorder()
102+
cs.handleCallback(rec, req)
103+
104+
out := renderedLines(logs)
105+
assert.NotContains(t, out, "ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789",
106+
"provider-authored error text is upstream free text and gets the free-text rule")
107+
assert.Contains(t, out, "invalid_request",
108+
"the provider's error CODE is the diagnostic and must survive")
109+
}
110+
111+
// The unknown-state path builds an operator-visible error message. It quoted
112+
// the raw state, and that message is stored and surfaced by
113+
// RecordOAuthFailure.
114+
func TestUnknownStateCallbackMessageCarriesNoNonce(t *testing.T) {
115+
const state = "STATENONCEbb17c9d4ef05"
116+
cs, logs := newObservedCallbackServer(t, "") // nobody waiting
117+
118+
req := httptest.NewRequest(http.MethodGet, DefaultRedirectPath+"?code=X&state="+state, nil)
119+
rec := httptest.NewRecorder()
120+
cs.handleCallback(rec, req)
121+
122+
out := renderedLines(logs)
123+
assertNoRun(t, out, state, 6)
124+
assert.Equal(t, http.StatusBadRequest, rec.Code)
125+
}
126+
127+
func TestLogSafeCallbackQuery(t *testing.T) {
128+
const code = "AUTHCODEqq81mVzZlPd0"
129+
got := LogSafeCallbackQuery("code=" + code + "&state=abc123def456&scope=read&error_description=nope")
130+
131+
assertNoRun(t, got, code, 6)
132+
assert.Contains(t, got, "scope=read", "a benign parameter stays readable")
133+
assert.Contains(t, got, "code=", "the parameter NAME survives; only the value goes")
134+
assert.NotContains(t, got, "state=abc123def456")
135+
136+
// A query mcpproxy cannot parse still must not be published verbatim.
137+
assert.NotContains(t, LogSafeCallbackQuery("%zz&access_token=ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789"),
138+
"ghp_aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789")
139+
140+
assert.Equal(t, "", LogSafeCallbackQuery(""))
141+
}
142+
143+
func TestStateFingerprintCorrelatesWithoutDisclosing(t *testing.T) {
144+
const state = "STATENONCE-3f7a91cc"
145+
fp := StateFingerprint(state)
146+
147+
assertNoRun(t, fp, state, 4)
148+
assert.Equal(t, fp, StateFingerprint(state), "the same flow must render the same handle on every line")
149+
assert.NotEqual(t, fp, StateFingerprint(state+"x"), "two live flows must stay distinguishable")
150+
assert.Equal(t, "(none)", StateFingerprint(""))
151+
}

0 commit comments

Comments
 (0)