Skip to content

fix(security): apply New options so the secret scrub actually runs - #146

Merged
BaaRai merged 1 commit into
mainfrom
fix/apply-new-options
Nov 3, 2026
Merged

BaaRai merged 1 commit into
mainfrom
fix/apply-new-options

Conversation

@BaaRai

@BaaRai BaaRai commented Nov 3, 2026

Copy link
Copy Markdown
Owner

Problem

New takes opts ...Option but never calls them. scrubSecrets therefore stays false in the binary and ScrubSecretEnv() is unreachable, so the protection merged in #136 never engaged: agent shells, MCP stdio servers and custom tools still inherit ARTEX_PG_DSN, ANTHROPIC_API_KEY and OPENAI_API_KEY.

The unit test added in #136 passed because it called ScrubSecretEnv directly and never went through New.

Fix

  • Apply the options in the constructor, right after the Server is built and before initSetupToken.
  • Add TestNewAppliesSecretScrubOption, which builds a server through New(ctx, m, ..., WithSecretScrub()) and asserts the two API keys are gone. Verified it fails when the loop is removed.

Verification

  • go build ./..., go vet ./server: clean
  • go test ./server -run 'Scrub|Auth' against a scratch Postgres: 6 tests pass, including the new one
  • Negative check: with the loop removed, the new test fails
  • Full ./server suite: only the known TestCoreTaskLifecyclePG timing failure in this environment

New accepted opts ...Option but never called them, so scrubSecrets stayed
false in the binary and ScrubSecretEnv was unreachable: the protection merged
in #136 never engaged. The unit test passed because it called the scrub
function directly instead of going through New.

Apply the options in the constructor and add a test that builds a Server
through New with WithSecretScrub and asserts the secrets are gone. Verified to
fail without the loop.
@BaaRai
BaaRai merged commit 90e7b3e into main Nov 3, 2026
3 checks passed
@BaaRai BaaRai mentioned this pull request Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant