Skip to content

fix(xtask): validate the workspace root at its source (CodeQL path-injection alert) - #21

Merged
MatejGomboc merged 1 commit into
mainfrom
fix/codeql-path-taint
Aug 5, 2026
Merged

fix(xtask): validate the workspace root at its source (CodeQL path-injection alert)#21
MatejGomboc merged 1 commit into
mainfrom
fix/codeql-path-taint

Conversation

@MatejGomboc

Copy link
Copy Markdown
Member

Summary

Addresses the repository's one open GitHub security alert: CodeQL rust/path-injection (high) at xtask/src/main.rs:244, where CARGO_MANIFEST_DIR flows into the constructed kernel-image path. No Dependabot or secret-scanning alerts exist.

Explanation for the maintainer

The alert is a genuine taint flow but a false positive as a risk: cargo itself sets CARGO_MANIFEST_DIR, every joined component after the root is a fixed string, and xtask runs with the invoker's own authority β€” whoever controls that environment already runs arbitrary code as that user. Rather than dismissing, this makes the validation real: workspace_root() canonicalises the path and verifies it holds the workspace Cargo.toml (a mangled environment now fails at the source with a message naming the problem), and build() asserts the image path's containment under the root β€” the guard shape CodeQL documents for this query β€” rather than assuming it. The trust model is stated in a doc comment so the next reader does not re-litigate it.

CodeQL runs on this PR, so whether this shape clears the alert is answered empirically. If the alert survives, the remaining step is dismissing it with the trust-model rationale β€” that is alert triage on GitHub, so it is yours, not mine. Behavioural note: canonicalisation on Windows yields a \?\-prefixed path; harmless for cargo and the CRT, visible only in printed paths on a Windows host.

Which pillar does this serve?

Toil (tooling hygiene), with the fail-closed instinct the rest of the tree follows.

Borrow Ledger

  • I checked the Borrow Ledger (CONSTITUTION.md Β§4) for this subsystem
  • The verdict for this subsystem is: write ourselves (build tooling)
  • Vendored code retains its original licence notices; new files carry an SPDX header (no files added)

unsafe register

  • New unsafe blocks: None
  • Every new unsafe block carries a // SAFETY: comment (n/a)
  • Every unsafe block is inside a module CLAUDE.md designates for it (n/a)
  • I have listed them in the session summary / PR description above

Checklist

  • Builds for both Tier-1 targets β€” kernel untouched; CI re-proves it
  • Clippy passes for every package, exactly as CI runs it (xtask clean under -D warnings; others untouched)
  • Formatted (cargo fmt --all --check)
  • Toolchain pins agree
  • British spelling
  • Markdown is lint-clean (CHANGELOG entry)
  • Boots in QEMU where applicable β€” CI's boot jobs gate it
  • CHANGELOG.md updated under [Unreleased]
  • Commit messages follow Conventional Commits
  • Commit GPG-signed

Related

GitHub code-scanning alert #1.

πŸ€– Generated with Claude Code

CodeQL's rust/path-injection alert flags the kernel image path as
depending on a user-provided value: CARGO_MANIFEST_DIR flows into
workspace_root() and from there into every constructed path. There is
no privilege boundary here β€” cargo sets the variable and xtask runs
with the invoker's own authority β€” but the honest response is to make
the validation real rather than argue with the scanner: the root is
now canonicalised and checked to hold the workspace manifest, failing
closed with a message that names the actual problem, and build()
asserts the image path's containment under the root rather than
assuming it. A mangled environment now dies at the source instead of
surfacing as a confusing downstream failure. One new test pins the
canonical-and-carries-the-manifest behaviour.

If the alert survives this shape, the remaining step is a dismissal
with the trust-model rationale β€” the maintainer's call, not code's.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@MatejGomboc
MatejGomboc merged commit 3867818 into main Aug 5, 2026
6 checks passed
@MatejGomboc
MatejGomboc deleted the fix/codeql-path-taint branch August 5, 2026 04:40
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