Repository navigation
Confine and verify mirror fetches, refuse content symlinks, build with Go 1.27.4 - #9
Merged
Merged
Conversation
Fetch wrote every file it downloaded from KBD_FETCH_URL straight into KBD_DATA and left verification to the later LoadNamespace call. The pack version from the unsigned catalog was part of the file name and was not checked there, so a hostile or compromised mirror could use dot segments in it to write *.json files outside KBD_DATA before any signature check. Fetch now validates the catalog payload (Catalog.Validate checks pack ids, versions and paths) and its namespace, refuses any mirror path that is not a plain relative path, and writes only through an os.Root opened on the data directory. Files go to a random staging directory, are verified there with FollowKeyrings and LoadNamespace against a copy of the trust store (Trust.Clone), and only a verified namespace is renamed into place. The staging directory is always removed, so a failed fetch leaves nothing behind and keeps the previous copy. A symbolic link at the namespace path is replaced, never written through. Tests cover traversal in the version (the old code wrote outside the data directory), absolute and unclean paths, a symbolic link in the data directory and a pack signed by an untrusted key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kb-review runs on fork pull requests in the pull_request_target workflow with model API keys in its environment, and it read content files with os.ReadFile, which follows symbolic links. A fork could add an entry file that links to a file of the runner; validation happened to reject most such targets, but nothing refused the link itself, and the model's answer is posted publicly. source.Load and review.Units now read through ReadNoFollow, which lstats every path component below a trusted base, accepts only regular files and checks that the opened file is the one that was checked. Load also refuses a namespace or entries directory that is a link, and kb-review refuses a content directory that is one. The fork workflow additionally checks out the pull request with core.symlinks=false, so links arrive as plain files. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
go.mod declared go 1.27.0, which CI and the signed release build use through setup-go, and the Dockerfile used the floating golang:1.27 tag. govulncheck reports 11 reachable standard library vulnerabilities at 1.27.0, among them GO-2026-6859 (HTTP/1 server crash, fixed only in 1.27.4), so 1.27.3 is not enough. go.mod and the Dockerfile now name 1.27.4 exactly. go.yaml.in/yaml/v3 moves to 3.0.6 (the pending Dependabot update). CI runs govulncheck on every push and pull request and weekly, so a new advisory fails the build without waiting for a code change. govulncheck reports no vulnerabilities after this change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Supersedes #7 and #8.
🤖 Generated with Claude Code