Skip to content

fix(secrets): stop committed secrets from setting LD_PRELOAD, PATH and similar in sc run - #362

Merged
tonibergholm-codento merged 8 commits into
mainfrom
fix/secret-names
Nov 20, 2026
Merged

tonibergholm-codento merged 8 commits into
mainfrom
fix/secret-names

Conversation

@tonibergholm-codento

Copy link
Copy Markdown
Collaborator

The committed-secret registry is repository data, and adding a secret needs no key. A writer could therefore register a secret sealed to someone else's public key under LD_PRELOAD, PATH or NODE_OPTIONS, and that person's next sc run injected it into the child. The registry key was also never compared with the secret's own sealed name, so one value could be served under another name.

This PR gives secret names one rule, [A-Za-z_][A-Za-z0-9_]*, plus a deny list. The list covers variables that change how a process loads code, which program runs, or where it fetches from: loader, shell, interpreter, build-tool, proxy, CA and cloud-config variables. They are matched case-insensitively on every platform, with exceptions for a few well-known credential names such as NODE_AUTH_TOKEN and GEM_HOST_API_KEY.

  • At add: sc secret add refuses a name that fails the rule.
  • Mismatched name: before anything is decrypted, every injection path (sc run, --secrets-fd, sc ws run --with-secrets, sc work --with-secrets) refuses the run when a registry key differs from the sealed secret's name.
  • Failing name: it then skips any entry whose name fails the rule, with a warning, and never opens it. A legacy name such as db-pass therefore no longer injects, but it does not block the run either.
  • Rotate: sc secret rotate without a value refuses a relabeled entry instead of re-sealing it under the wrong name.

The threat model records what stays open. The registry is still unauthenticated, so a writer can replace the value of an allowed name such as DATABASE_URL with one sealed to the victim. Recipient and registry trust come in a separate change.

Proof: the new tests in secrets.rs fail with the checks disabled and pass with them:

  • refusal at add, including lowercase forms such as npm_config_script_shell
  • a planted LD_PRELOAD entry that is never opened or injected
  • a key that differs from the sealed name, also under a skipped key
  • a relabeled rotate

cargo test -p scl-repo -p scl-cli and demo/run_rewrap_demo.sh pass. That demo now uses DB_PASS, since the old db-pass fails the rule.

Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved.

Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.

The secret registry is repository data and secret_add needs no key, so a
writer could register a secret sealed to a victim under LD_PRELOAD, PATH,
NODE_OPTIONS and similar, and sc run would inject it into the child. The
registry key was also never compared with the name the secret was sealed
under, so one value could be served under another name.

One rule in secrets.rs: [A-Za-z_][A-Za-z0-9_]*, minus a deny list of
loader and program-selection variables and the LD_, DYLD_, GIT_CONFIG and
SC_ prefixes. secret_add refuses a failing name. secret_values, which every
injecting path goes through (sc run, --secrets-fd, sc ws run
--with-secrets, sc work --with-secrets), refuses the whole run before
decrypting anything when a key fails the rule or differs from the sealed
name.

THREAT-MODEL records the residual: a writer can still replace the value of
an allowed name. The rewrap tests and demo used db-pass and api-key, which
the rule refuses; they are now DB_PASS and API_KEY.
…, guard rotate

Uppercase the name before every deny check on every platform, since tools
read npm_config_*, http_proxy and similar in any case. Widen the deny list
with compiler, proxy, CA-bundle, cloud and container config variables and
the XDG_, OPENSSL_, DOTNET_, CORECLR_, COR_, GEM_, LUA_, PIP_, UV_ and
YARN_ prefixes, and the _OPTS and ASKPASS suffixes.

Injection now skips a registry entry whose name fails the rule, with a
stderr warning and without opening it, in strict and non-strict mode. A
legacy name such as db-pass or a planted one no longer stops every run.
A key that differs from the sealed name still refuses the run, and
secret rotate without --value refuses it too instead of re-sealing it
under the registry key.
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a32e970b-1cf2-446b-9619-e9327495b08d
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T08:59:13.943016Z c42056d New commits
🔒 Security Review ✅ Completed 2026-11-20T09:00:36.087547Z c42056d New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@tonibergholm tonibergholm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed: sol-loop (3 rounds, approved) plus a Mythos security review, required checks green, Codex review has no findings.

@tonibergholm-codento
tonibergholm-codento merged commit cf82c20 into main Nov 20, 2026
11 checks passed
@tonibergholm-codento
tonibergholm-codento deleted the fix/secret-names branch November 20, 2026 09:18
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.

2 participants