Skip to content

fix: close the security audit findings across scanner, proxy, sandbox, steward and CI - #84

Merged
tonibergholm-codento merged 97 commits into
mainfrom
fix/security-audit-hardening
Nov 20, 2026
Merged

tonibergholm-codento merged 97 commits into
mainfrom
fix/security-audit-hardening

Conversation

@tonibergholm-codento

@tonibergholm-codento tonibergholm-codento commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

A security audit of Sentinel found ways for a package author, a lockfile, an HTTP client or a sandboxed install script to get past the checks Sentinel promises: malware the scanner never saw, scripts escaping the sandbox, claims granted to the wrong domain, and CI jobs running third-party code while holding publish rights. This PR fixes all of them. ADR-0056 records each decision and what it supersedes.

What changes, by area:

  • Scanner. Tar entries are read the way npm installs them (type-7 files, npm path normalization, both readings of \, PAX paths, trailing separators). A second or hidden root package.json now raises a critical manifest-confusion finding. JS that starts with a magic-byte label is still scanned. Nested compression counts against the unpack cap. One malformed field no longer disables a rule, quadratic regexes on the request path are linear, and install scripts resolve the files they actually run.
  • Trust inputs. Trusted-publisher repository and ref come from the Fulcio certificate, not the signer-written predicate. An unmatched signature keyid counts as unsigned. Lockfile entries from git, URLs or with no integrity pin gate audit-tree instead of borrowing a registry verdict, and every SRI token is verified.
  • Proxy. SENTINEL_POLICY is validated. The compat routes no longer forward client credentials upstream and their bodies are capped. In open mode, import and retraction need a publish token. Stale cached verdicts are invalidated through an audit revision.
  • Sandbox. The Seatbelt profile is passed inline instead of through a temp file that a script could rewrite. bwrap gets pid and session isolation and masks local IPC sockets. launchctl, open, systemd-run and similar tools are carved out. Enforced installs bind each dependency script to its audited integrity and to SENTINEL_ROOT.
  • Steward. Tier 1 needs a homepage or repository host under the claimed domain. Challenges expire and are single-use, disputes survive freezes, and transfer signatures bind the current proof.
  • Action, CLI, CI. The Action escapes workflow commands and Markdown, the CLI strips terminal escapes, and the release workflow installs third-party code only in a job with no token.

Breaking changes (pre-1.0):

  • The proxy and steward bind 127.0.0.1 unless SENTINEL_HOST / SENTINEL_STEWARD_HOST is set.
  • SENTINEL_POLICY must be exactly observe or block.
  • Open-mode import and retraction need SENTINEL_PUBLISH_TOKENS.
  • --enforce needs npm 7+ for dependency scripts.
  • Lockfile entries without an integrity pin gate audit-tree.
  • ClaimSteward.approve is async, and transfer signing takes the current challenge id.

Left as documented trade-offs: steward rate limiting before auth, retraction-window download inflation, open-mode reads.

Proof: every fix has a test that failed before it and passes after it. npm run build is clean. npm test on macOS: 1401 tests, 0 failures, 4 Linux-only skips. The sandbox suite also passes on Linux (Debian, Node 22 and 24, bwrap) in a local container. npm audit --omit=dev reports 0 vulnerabilities. The bwrap and Landlock effects are verified by this PR's ubuntu CI. Reviewed with sol-loop: 5 rounds with gpt-6.2-sol (budget reached; every finding fixed), plus two Mythos 5.2 security reviews, two Opus contract audits and the Codex review on this PR.

Created with Claude Opus 5.5 in Claude Code (T3 Code). Sonnet 5.5 subagents wrote most of the code; Mythos 5.2 ran the audit.

…cio certificate

sourceRepository and ref came from the SLSA predicate, which any Sigstore
signer writes; only the certificate SAN is bound to the OIDC token. Read
Fulcio extensions 1.3.6.1.4.1.57264.1.12 (source repository URI) and .14
(source repository ref) from the leaf certificate with a small DER walker.
No predicate fallback: a certificate without the extension yields null.

trustedPublisherAuthorized now requires an entry to constrain repository
or workflowRef, so a signer-written builder (or the issuer alone) never
authorizes.
The SBPL profile was written to <tmpdir>/sentinel-sb-*/profile.sb, inside the
write floor, so a lingering sandboxed process could rewrite the next run's
profile. Pass it with -p and drop the temp file code for run and runArgv.
…urrent proof, bind to loopback

- F12: Tier-1 corroboration now requires a homepage/repository host at or under
  the claimed domain; a same-named GitHub/GitLab org no longer counts (Tier 2).
- F15a: transfers need an active claim with no pending change; a transfer is not
  materialized while the claim is disputed.
- F15b: renewal refuses disputed claims and needs a challenge verified after the
  claim's current proof.
- F15c: challenges expire 30 days after issuance for verify/approve/transfer/
  renew/ruling; approve re-runs the upstream lookup and recomputes the tier
  (approve is now async).
- F15d: evidenceRef must be a non-empty string; request bodies are type-checked
  in the server; issueChallenge copies known fields only, so a body-supplied
  verifiedAt can no longer skip the DNS proof.
- Transfer signatures cover the claim's current challenge id, so they cannot be
  replayed after a renewal or transfer.
- New SENTINEL_STEWARD_HOST (default 127.0.0.1) replaces the all-interfaces bind.

Tests flipped on purpose: grandfathering fixture (org label no longer
corroborates), the renewal test (a fresh challenge is now required), and
steward.test.ts awaits the now-async approve.
… F9)

F8: add --unshare-pid, --die-with-parent and --new-session so the sandbox no
longer sees the host /proc, cannot outlive its parent, and cannot inject
keystrokes into the controlling terminal.

F9: with no network approval, --unshare-net left pathname unix sockets
reachable through the read-only root bind. Mask the docker sockets with
/dev/null and mount a tmpfs over /run/user/<uid>, each only when the path
exists. Also stop a projectRoot of "/" from being re-bound inside the emptied
$HOME (bwrap side).
…tbelt (F10)

Each hands work to a process outside the sandbox (launchd job, app launch,
Shortcuts or Automator workflow). Add them to SENSITIVE_EXECUTABLES so the
exec carve-out denies them unless a process: Grant lifts it.
…input

F4: a non-string lifecycle hook, a 20k-deep `exports` object, or an
expression that overflows the AST walker no longer disables a whole rule;
the walker overflow maps to the existing parseFailed path.

F5: remove quadratic regexes and rescans on the sync path
(install-scripts referencedFiles, obfuscation dynamic-require and decoded
Function patterns, native-payload-loader decode fallback, loader-chain
lineOf/snip). Base64 `Buffer.from(...)` detection stays unbounded in
literal length via the linear `headsWithTail` helper.

Also resolve extension-less and non-JS command tokens (`node setup`,
`sh build.sh`) against retained package files in install-scripts, and
accept template-literal `require(\`fs\`)` in the loader-chain detector.
…scape workflow commands and Markdown

- action.yml: reuse an existing comment only when it carries the marker AND was
  written by github-actions[bot] (user.type Bot), so a pasted marker cannot
  redirect the update or hijack the report.
- run.ts: escape %, CR and LF in ::error::/::warning:: data (as @actions/core),
  so a finding cannot start a second workflow command.
- report.ts: neutralize backticks, <, [, ] and @ (zero-width space) in table
  cells, besides the existing backslash, pipe and newline handling.

report.test.ts changes on purpose: the escaped coordinate now carries the
zero-width space after "@".
…igned

A signature list whose keyids match no trusted key returned "unknown"
(weight 0), so an attacker-chosen keyid beat having no signature. With a
non-empty trusted set it now returns "unsigned". An empty trusted set stays
"unknown". Key expiry is deliberately not checked (no wall clock in scoring).
matchPackage compiled a*b*c into ^a.*b.*c$, which backtracks catastrophically
on a hostile package name. Replace it with an iterative two-pointer wildcard
match with the same semantics (* is the only metacharacter).
…stry

The npm parser only skipped file:/link: entries, so git, github shorthand
and arbitrary tarball resolutions were audited as the registry package of
the same name and version. Coordinate gains nonRegistry (the raw resolved
spec), set when the entry is not an http(s) /-/<file>.tgz registry tarball.
The yarn v1, yarn berry and pnpm parsers set it from their own resolution
fields; local sources (workspace, patch, link, portal, file, directory) are
skipped. The flag is sticky when duplicate name@version entries merge.
…store

- F19: audit-tree turns a coordinate with a string nonRegistry into a block
  row without fetching anything. The dedupe and re-expansion keys include
  the non-registry marker, so a git row never shares a registry row's
  verdict. A non-string nonRegistry is a 400.
- F17: compatibility routes no longer forward authorization, cookie or
  npm-otp upstream, except POST /-/v1/login (npm's own web login).
- F20: compatibility request bodies are capped at 8 MiB (was 128 MiB) and
  the routes sit behind rateGate.
- F18: with SENTINEL_AUTH_PUBKEY unset, POST /-/registry/import and
  POST /-/retractions require a publish token (always 401 when none are
  configured). New SENTINEL_HOST, default 127.0.0.1, sets the bind address.
- F16: SENTINEL_POLICY must be exactly observe or block, else FATAL.
- AuditStore keeps at most 20000 entries and evicts the oldest.

Existing tests that pinned the old open-mode and credential-forwarding
behavior in retraction-e2e and compatibility-e2e are updated.
~/.node-gyp and ~/.cache/node-gyp were in the write floor, so one package could
plant headers a later build trusts. Drop them from the floor (they stay
readable). When the approved capabilities include network, point node-gyp at a
fresh per-run devdir under tmpdir via npm_config_devdir so a cold-cache build
can still download headers. Updates the existing floor tests that pinned the
old list.
…the profile

A projectRoot of "/" slipped through the strictly-under-$HOME filter in the
Seatbelt read re-allow and was added verbatim to the exec floor, which made
every path executable (also on the Landlock side). Filter "/" out of the read
allow and the exec floor. The sandbox entry points now normalize cwd and
projectRoot with path.resolve (projectRoot "/" falls back to cwd) so "." or
".." cannot expand to $HOME or an ancestor.
…s in violations

scrubEnv screened names only, so npm_config_https_proxy=http://user:pass@host
reached the lifecycle script. Drop any npm_config_* whose value matches
://user@; an explicit env: approval still re-admits a named variable.

A package controls its stderr, so a violation target could carry escape
sequences into a terminal, the proxy store or an MCP client. Attribution still
runs on the raw text; target, deniedResource and the stderr excerpt are
stripped of C0, C1 and DEL characters before they are returned.
… path

- format.ts: one sanitizeTerminal() strips ESC sequences (CSI, OSC, DCS/SOS/PM/APC,
  7-bit and C1 forms), C0 controls except \n and \t, DEL and C1 controls. Every
  formatter deep-sanitizes its payload (package names, findings, evidence,
  violation targets, proxy answers) before formatting.
- index.ts: apply it to the other places that print package-, proxy- or
  signer-controlled text (lifecycle commands, un-approved atoms, exec violation
  target, fail() messages, attestation/token/policy output).
- run-scripts: pass path.resolve(dir), so the sandbox profile and cwd no longer
  depend on how the path was spelled (a relative dir under $HOME denied the
  script its own directory).
Non-breaking lockfile bumps: body-parser 2.3.0 to 2.4.0 (high),
hono 4.13.7 to 4.13.19, @hono/node-server 2.1.0 to 2.1.9, fast-uri 3.1.8
to 3.1.9, qs 6.16.0 to 6.17.1, plus their transitive patch releases.

zod (high, GHSA-mrhx-c7xc-m3w5) remains: it is a direct dependency of
@git-agentic/sentinel-mcp at ^3.23.8 and the fix is zod 4.6.7, a major bump.
…st confusion, nested compression)

- F1: node-tar reports typeflag 7 as ContiguousFile; npm installs it as a
  regular file. Treat any *File entry type as a file.
- F2: a text-extension file whose bytes start with binary magic (`MZ:` and
  `BZh:` are valid JS labels) is still reported as content-mismatch, but is
  also retained for the rules when it is valid UTF-8 with no NUL byte.
- F3: normalize entry paths like npm (drop the first segment whatever it is,
  collapse ./ and //, reject ..). Count root package.json entries
  case-insensitively on every path; more than one, a case-variant spelling, or
  a root manifest over the 2 MiB retain cap raises a critical
  `manifest-confusion` finding (category metadata), which blocks under the
  default policy.
- F6: refuse a compressed signature (gzip/zstd/xz/bzip2) as the first bytes
  the tar parser would see, in both the gunzip and raw branches, so nested
  compression cannot decompress past maxUnpacked. Reported as resource-abuse.
- Retain extension-less text files up to 2 MiB (no NUL, text magic) so script
  hooks like `node setup` can be resolved by rules.
An untrusted signature keyid now scores like unsigned, so the clean fixture
needs the fixture signing keys to keep its score of 100.
… SENTINEL_ROOT (F11)

The wrapper looked up a dependency's approvals by npm_package_name and
npm_package_version, which a git, URL or file dependency declares itself, and
decided "root script" from INIT_CWD, which a nested npm (git dependency
prepare) resets to the dependency's own directory.

- Dependency scripts now require npm_package_integrity to equal the manifest's
  meta.integrity, compared per algorithm; missing, mismatched or
  not-comparable integrity fails closed with EnforceError.
- sentinel install --enforce pins SENTINEL_ROOT to realpath(cwd) in
  enforceNpmEnv. isRootScript and resolveProjectRoot use it; a missing or
  relative SENTINEL_ROOT means "not root".
- The per-run node-gyp devdir (network approvals only) is wired into the
  wrapper.

Updates enforce.test.ts, which pinned the old "no INIT_CWD means root" rule.
The release publish job installed the just-published packages with no
lockfile while holding id-token: write and contents: write, so a
compromised transitive dependency could mint an npm OIDC token or push.
The clean-install check now runs in its own job with permissions: {},
and the GitHub prerelease is created in a later job that needs it. The
publish job keeps only contents: read and id-token: write, and checkouts
no longer persist credentials. ci.yml gets a read-only default token.
…proved

A network approval means the network, not local IPC. With it, the session bus
under /run/user/<uid> and the container runtime sockets stayed reachable, and
systemd-run --user or docker is a full escape. Apply the masks always, lifted
only by an explicit filesystem grant covering the path:

- tmpfs over /run/user/<uid>
- /dev/null over the docker, containerd, podman, crio and system bus sockets
- tmpfs over /tmp/.X11-unix and every /tmp/ssh-* directory, placed after the
  rw /tmp bind (skipped when it would hide the cwd, project root or $HOME)

Every mount is existence-guarded. Also add systemd-run, busctl, dbus-send and
gdbus to SENSITIVE_EXECUTABLES. Flips the F9 test that pinned "no masks with
network".
…aviour

The per-run devdir was created under tmpdir, which is in every sandbox's write
floor, so a process left over from an earlier run could poison headers. Create
it under <home>/.cache/sentinel-gyp (mode 0700, outside every write floor) and
grant read-write on that one directory for the run through an ordinary
filesystem grant, so it works the same under Seatbelt and bwrap. The runner and
the script shell pass the grant to the sandbox.

Probed a copied /usr/bin/open and /bin/launchctl under real Seatbelt: the
kernel SIGKILLs the copy (exit 137) before it can reach LaunchServices, so no
mach-lookup rule is added; an effect test pins the behaviour.
The non-registry check used substring tests: a resolution URL that
contained "@npm:" counted as a registry entry, one that contained
"@file:" was skipped as local, and the package name was cut at the
first "@npm:" anywhere in the key. Parse name@protocol:rest instead and
treat only npm:<plain version> as registry.
…mask

Skipping an IPC mask because the cwd or project root is under it silently left
that directory open. Throw the "bubblewrap enforcement unavailable" error
instead so the script does not run; an absent directory or an explicit
filesystem grant still lifts the mask.

Also pin that scrubEnv already drops DISPLAY, WAYLAND_DISPLAY,
DBUS_SESSION_BUS_ADDRESS, SSH_AUTH_SOCK and XDG_RUNTIME_DIR (no env.ts change).
Audit an entry under the name in its resolution (what yarn fetches), so
an alias key is not looked up under the wrong name. An entry whose key
or resolution does not parse, or that lacks a version, is emitted as a
non-registry coordinate instead of being skipped.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5b0f3586a6

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/sandbox/src/bwrap.ts Resolved
Comment thread packages/core/src/lockfile.ts Resolved
On a host where /var/run is a symlink to /run, a filesystem grant on
/run/docker.sock lifted the /run/docker.sock candidate but not the
/var/run/docker.sock alias, which resolves to the same node and was masked
anyway, so the approved socket stayed unusable. liftedByGrant now also compares
the resolved grants against the resolved candidate, as the executable-mask loop
does. The same closure serves the /run/user/<uid> and /tmp masks.
- install-scripts: resolve with a mode. A bare command word (`echo`,
  `node-gyp`, `npm`) matches only an exact package file; a command word
  written with `/` (`./setup`) may use the suffix trie; an executed
  operand (interpreter script or code-extension word) keeps the `.js`,
  `/index.js` and suffix fallbacks. A shell never appends `.js` to a
  command word. `-r`/`--require`/`--import`/`--loader` values resolve
  only when relative or absolute, since a bare specifier is a
  node_modules module.
- install-scripts: an unrecognized `--flag=value` whose value is a code
  file (`--test-reporter=./reporter.js`) is resolved under the same
  relative-or-absolute rule.
- native-payload-loader: the overflow decode signal matches whole
  identifiers (`inflateSync`, `gunzip`, ...), not words like "inflated".
…ead of flagging a conflict

Two entries for the same name@version pinned as sha1 and sha512 of the same
bytes were compared as strings and marked nonRegistry, blocking a valid tree.
Tokens are now grouped by algorithm: a different digest in the same algorithm
is still a conflict (nonRegistry), while different algorithms merge into one
space-separated, deduped SRI. audit-tree already checks every token against
the served bytes, so a wrong token still blocks.
…grants

Symlink-resolving grants let a grant on a package-writable symlink (a
link to /run in the cwd) lift every IPC mask. Map only the /var/run to
/run alias, and only for safe grant targets.
The backtick case is linear (about 150 ms per MiB locally) but crossed the
1000 ms bound on a loaded CI runner. The test guards against quadratic
work, which takes minutes at this size, so a 5 s bound still catches it.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dd15d37f7c

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

`node <setup.js` feeds setup.js to node on stdin. The base regex caught
it; the word splitter kept `<setup.js` as one token, so the script went
unscanned. Split words on `<` and `>` as well.
A `<file` target is scanned (an interpreter reads it as its script) but no
longer takes the script operand slot, so `node <README.md setup` still
scans setup. `>file` targets are outputs and are not scanned.
…runs

PR_SET_PDEATHSIG is tied to the forking thread, not the process. Enforced
runs on Node 22 intermittently died before the script ran (no output,
exit 1 from a signal). --unshare-pid already ends every orphan with the
command, so the flag added nothing. The positive-control effect test now
reports bwrap stderr on failure.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 404da33b85

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…fixes

`NODE_OPTIONS=--require=./hook.js node -v` runs hook.js. The base regex
caught it; the new parser skipped assignment words entirely.
`cc -o dist/landlock-exec` rewrote the helper in place. build-native.test
runs the script during the test run, so a concurrent bwrap run sometimes
executed a half-written file: "execvp .../landlock-exec: Permission
denied", the Node 22 CI flake on this branch. Compile to a temp name and
rename it into place. Hammer on Linux (60 rebuilds, 3000 concurrent execs):
133 exec failures before, 0 after.
@tonibergholm-codento
tonibergholm-codento merged commit deacd61 into main Nov 20, 2026
10 checks passed
@tonibergholm-codento
tonibergholm-codento deleted the fix/security-audit-hardening branch November 20, 2026 10:53
tonibergholm-codento added a commit that referenced this pull request Nov 20, 2026
Bump all seven workspaces, the exact internal pins, ENGINE_VERSION and the
CLI/MCP versions to 0.1.0-alpha.3, and add the release notes. The release
carries the security audit hardening (#84) and the install-script
detection-gap fixes (#89, #90, #91, #92).
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