Repository navigation
fix(trueforge): match the redaction sentinel exactly and publish less of a secret - #463
Closed
ethanstoner wants to merge 1 commit into
Closed
ethanstoner wants to merge 1 commit into
ethanstoner wants to merge 1 commit into
Conversation
… of a secret Settings secrets are masked on the way out and the mask is sent back on the next PUT to mean "keep what you already have". Two things were wrong with that exchange. The keep test was a substring test. Any real secret containing ***REDACTED*** anywhere in it was read as a mask, so the value the user typed was discarded without an error saying so: the old secret stayed on an update, and a create failed with a message about a missing key. It is now a whole-value test against the shapes the redaction function actually emits. Exact equality with the bare sentinel alone would not do, because that is not the only shape emitted — a long secret masks to the sentinel plus a suffix, and a client round-tripping an unedited form sends that back. Treating it as a real value would store the mask as the secret. Both shapes are recognised, and nothing else is. A value whose entire content is one of those two shapes is still indistinguishable from a mask. Nothing in-band can separate them; only a separate field meaning "keep" could, which is an API change rather than a fix, so it is left alone and the residual case is documented. The mask also published too much. Any secret of ten characters or more came back as its first three and last three characters, so a ten-character key showed six of its ten to every viewer of a settings response, a screen share, or a captured log. It is now the last four characters and only for secrets of at least twelve, so eight remain unknown at the threshold; shorter ones are masked completely. Suffix-only matches what other providers publish. Two existing cases asserted the substring behaviour deliberately, one for MCP header auth and one for the sandbox provider api_key, each sending a redacted-looking value that was not the stored secret's mask and expecting the stored secret to survive. Those pinned the defect, so they now assert the opposite: a value that merely contains the sentinel is stored like any other rotation. The hardcoded wire form in the MCP tests is derived from the redaction function instead of written out, so the mask has one definition and the tests cannot drift from it again. Verified: unit suites for apis/ and utils/ pass, 146 tests across 15 suites. tsc clean for src and for tests/unit. Six failures elsewhere in the package are a Windows host — unix sockets and symlink paths under LocalSandboxProvider — and fail identically on a clean checkout.
ethanstoner
requested review from
bhaveshpatel640,
chiragjn,
debajyoti-truefoundry,
heerambavi1998,
sr07asthana and
thesujai
as code owners
August 27, 2026 00:24
🦋 Changeset detectedLatest commit: 2fe3696 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Member
|
Thank you for contributing but we have decided not to go ahead with this issue. Please see #423 (comment) We would recommend getting maintainer approval on an issue before starting any implementation work. |
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.
Fixes #423.
Both defects, and one correction to the proposed fix
Defect 1 — sentinel matched by substring.
isRedactedSecretValueused.includes(), so any real secret containing***REDACTED***anywhere was read as "keep the stored one". The value the user typed was discarded with nothing saying so: the old secret survived an update, and a create failed with a message about a missing key. It is now a whole-value test.One correction. The issue proposes
value === SECRET_REDACTION, on the grounds that "the redaction function only ever emits that exact standalone string". It does not — that is only the short-secret branch. A secret at or above the threshold masks to the sentinel plus a suffix, and a client round-tripping an unedited form sends that back. Exact-equality-only would classify it as a real value and store the mask as the secret, which is a worse bug than the one being fixed. So the test matches the two shapestoRedactedSecretValueactually emits, anchored to the whole value, and nothing else.A secret whose entire content is exactly one of those two shapes remains indistinguishable from a mask. Nothing in-band can separate them — only a separate
keepfield beside the value could, which is an API change rather than a fix. Left alone, and documented in the module so the next reader does not have to rediscover it.Defect 2 — prefix/suffix leak. Any secret of ten characters or more came back as first three + last three, so a ten-character key published six of its ten to every viewer of a settings response, screen share, or captured log. Now: last four only, and only for secrets of at least twelve, so eight characters stay unknown at the threshold. Shorter secrets are masked completely. Suffix-only matches what other providers publish, as the issue suggests.
Two existing tests asserted the defect
mcpServers.test.tsandsandboxProviders.test.tseach sent a redacted-looking value that was not the stored secret's mask (oth-***REDACTED***-xxx) and asserted the stored secret survived, with the comment:That is defect 1 written down as intended behaviour, so both now assert the opposite: a value that merely contains the sentinel is stored like any other rotation. Flagging it explicitly since inverting an existing assertion deserves a look rather than a skim.
The MCP tests also hardcoded the wire form (
'Bea-***REDACTED***-ken'). That is now derived fromtoRedactedSecretValue, so the mask has one definition and the tests cannot drift from it again.Verified
tests/unit/apis/+tests/unit/utils/— 146 passed, 15 suites, including 11 new cases covering both defects, the round-trip keep, the create-with-mask refusal, and rotation.tsc --noEmitclean forsrcand fortests/unit/tsconfig.json.prettier --checkandeslintclean on the files touched.LocalSandboxProvider,Code Mode UDS) are a Windows host — unix sockets and symlink paths — and fail identically on a clean checkout with this branch stashed, so they are not from this change.Notes
.changeset/secret-redaction-exact-mask.mdadded, per thepackages/trueforgerule inAGENTS.md.packages/trueforge-sdkand the OpenAPI spec are untouched.pnpm --filter @truefoundry/trueforge testcannot run on a Windows host, because the script uses aNODE_OPTIONS='…' node …inline env prefix and cmd.exe has no such syntax. I ran jest directly to get around it. That looks like the same family asnpx @truefoundry/trueforgecommand fails to start the server on Windows Terminal (PS, CMD, and Git Bash) #427 and Feat: add cross platform support #374, so I have not touched it here.Note
Medium Risk
Changes secret persistence and response masking for settings APIs (MCP headers, sandbox/model providers); clients may see a different mask string on GET, but round-trip keep still works for the new shapes.
Overview
Tightens settings secret redaction so GET masks leak less and PUT “keep existing secret” only applies to the exact mask shapes the API returns—not any string that happens to contain
***REDACTED***.Response masking no longer publishes the first three characters. Long secrets (≥12 chars) now appear as
***REDACTED***-plus the last four characters; shorter secrets are fully redacted.Write-back detection in
isRedactedSecretValueswitches from a substring check to whole-value matching: bare sentinel or the fixed suffix-mask form fromtoRedactedSecretValue. Real secrets that embed the sentinel are stored as typed instead of silently keeping the old value. MCP header auth and sandbox provider API tests are inverted accordingly; dedicated unit tests cover masking, recognition, andresolveStoredSecretValue.Reviewed by Cursor Bugbot for commit 2fe3696. Bugbot is set up for automated code reviews on this repo. Configure here.