Skip to content

Confine and verify mirror fetches, refuse content symlinks, build with Go 1.27.4 - #9

Merged
edimarlnx merged 3 commits into
mainfrom
fix/fetch-path-and-go
Nov 16, 2026
Merged

edimarlnx merged 3 commits into
mainfrom
fix/fetch-path-and-go

Conversation

@edimarlnx

Copy link
Copy Markdown
Contributor
  • Fetch (KBD_FETCH_URL) treated the mirror as trusted for file names. Fetch now validates the catalog, refuses non-local paths, writes only through an os.Root on the data directory, verifies a staging copy against a clone of the trust store, and only then swaps it into place. A failed fetch leaves nothing behind and keeps the previous copy.
  • kb-review, source.Load and review.Units refuse symbolic links in content instead of following them. The fork workflow also checks out with core.symlinks=false.
  • Build with Go 1.27.4 (go.mod and Dockerfile, exact tag). go.yaml.in/yaml/v3 moves to 3.0.6. CI runs govulncheck on every change and weekly.

Supersedes #7 and #8.

🤖 Generated with Claude Code

edimarlnx and others added 3 commits November 13, 2026 14:41
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>
@edimarlnx
edimarlnx requested a review from a team as a code owner November 13, 2026 17:52
@edimarlnx
edimarlnx merged commit 9412807 into main Nov 16, 2026
1 check passed
@edimarlnx
edimarlnx deleted the fix/fetch-path-and-go branch November 16, 2026 19:28
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