config: reject unknown top-level keys in SandboxRuntimeConfigSchema - #517
Open
PranshulSoni wants to merge 1 commit into
Open
config: reject unknown top-level keys in SandboxRuntimeConfigSchema#517PranshulSoni wants to merge 1 commit into
PranshulSoni wants to merge 1 commit into
Conversation
The top-level schema was the only non-strict one in sandbox-config.ts. A typo like 'denyWriteTypo' loaded without warning and was silently stripped, so an operator could believe a policy was enforced when no restriction existed (issue anthropics#434). Apply .strict() for parity with the sub-schemas, which already reject unknown keys for exactly this reason (see the credentials.injectHosts comment). loadConfig's existing error rendering prints each issue, so the operator now sees the unrecognized key name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #434
Problem
SandboxRuntimeConfigSchemais the only non-.strict()schema insandbox-config.ts. A config file with a typo'd key like"denyWriteTypo": ["/Users/me"]loads without any warning, the unknown key is silently stripped, and the command runs — so an operator can believe a filesystem policy is enforced when nothing is.Solution
Add
.strict()to the top-level object, placed before.superRefine()(zod effects don't expose.strict()). This brings the top level in line with the sub-schemas —awsPairs,sigv4, andcredentialsalready reject unknown keys; thecredentialsone documents the exact reasoning:loadConfigalready renders every zod issue with its path (config-loader.ts), so a typo now surfaces as a named, actionable error instead of a silent no-op.Testing
test/config-validation.test.ts: unknown key rejected with the key name present in the issue message, and a valid config with an extra key (allowEverything: true) rejected..strict().test/config-validation.test.ts+test/cli-config-loading.test.ts: 122 pass. Full typecheck and lint clean.bun testhas 144 pre-existing failures in environment-dependent integration tests (missing bwrap/seccomp deps); identical count with and without this change, all outside the config-validation surface.