fix(broker): resolve dynamic secrets through the MITM proxy - #269
Conversation
The MITM proxy captures its credential provider in attachMITMIfEnabled, which runs before Start() builds s.infisicalDynamic. The provider therefore snapshotted a nil dynamic resolver and never attempted dynamic-secret resolution, so proxied requests for an Infisical dynamic credential failed with credential_not_found even though the credential showed up in the credentials table (the UI enumerates it live). Bind the resolver through a small lateDynamicResolver adapter that reads s.infisicalDynamic per request instead of snapshotting it, so static and dynamic credentials resolve identically regardless of attach/Start ordering. The adapter satisfies the existing Dynamic interface field, so brokercore needs no new surface and the typed-nil guard goes away.
|
💬 Discussion in Slack: #pr-review-agent-vault-269-fix-broker-resolve-dynamic-secrets-through-the-mitm-pr Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel. |
|
| Filename | Overview |
|---|---|
| internal/server/server.go | Replaces snapshot-at-attach-time infisicalDynamic assignment with a lateDynamicResolver adapter that reads the field per-call; the nil guard is safe because the field is write-once (nil to non-nil in Start()) and the MITM goroutine is only spawned after Start() sets the field. |
| internal/server/server_test.go | Adds TestCredentialProvider_LateBindsDynamicResolver that exercises the pre-bind nil-safe path and the post-bind live-read path; accesses the unexported lateDynamicResolver type directly, which is fine since the test is in the same package. |
Reviews (1): Last reviewed commit: "fix(broker): resolve dynamic secrets thr..." | Re-trigger Greptile
Problem
Proxied requests for an Infisical dynamic credential failed with
credential_not_found(502) even though the credential was visible in the credentials table. Static credentials worked; dynamic ones did not.Root cause is an initialization-ordering bug:
attachMITMIfEnabledcallssrv.CredentialProvider()and bakes the returned provider into the MITM proxy once, at attach time (cmd/server.go).CredentialProvider()only setDynamicifs.infisicalDynamic != nilat that instant.s.infisicalDynamicis built later, insidesrv.Start().So the proxy snapshotted a nil dynamic resolver and skipped dynamic resolution for the whole process lifetime. The UI's enumerate/reveal path reads
s.infisicalDynamiclive, which is why the credential still showed up in the table. That asymmetry was the symptom.Fix
Bind the resolver through a small
lateDynamicResolveradapter that readss.infisicalDynamicper request instead of snapshotting it. Static and dynamic credentials now resolve identically regardless of attach/Startordering.The adapter satisfies the existing
Dynamic DynamicCredentialResolverinterface field, so:brokercoregains no new public surface (it is unchanged).infisicalDynamicinternally).Tests
TestCredentialProvider_LateBindsDynamicResolver: captures the provider whileinfisicalDynamicis nil (the attach-time condition), asserts the adapter is wired to the live*Serverand is nil-safe pre-bind, then assigns the resolver asStart()does and confirms the already-captured provider reaches it.TestInject_DynamicFallback_*brokercore tests continue to cover theDynamicpath unchanged.go build ./...,go vet, andgo test ./...all pass.Scope
Internal bugfix to credential brokering. No agent-facing API, CLI flag, or env var changes, so no doc/skill updates are needed.