feat(relay): refuse to boot on unexpected Linux capabilities (#79)#83
Merged
Conversation
…st (#79) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…allowlist (#79) Adds a Linux-only boot-time check that parses /proc/self/status's CapEff hex mask and aborts if any bit outside an explicit allowlist (CAP_NET_BIND_SERVICE only) is set. On non-Linux platforms the check is a no-op that logs a single skip line at startup. Build-tag split via the new _linux.go / _other.go convention. Wired into cmd/pyrycode-relay/main.go after flag-parse, before any listener starts; exit code 2 matches existing boot-time configuration refusals. No production-mode gating — stray capabilities are never legitimate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Author
Code Review: #79Decision: PASS FindingsNo MUST FIX, no SHOULD FIX.
SummarySpec-compliant implementation of the Linux capability allowlist boot check:
Security-sensitive checks (label present on #79)
CI: |
Adds feature doc for the boot-time CapEff check, ADR-0009 capturing the new _<goos>.go / _other.go build-tag convention, and a per-ticket codebase note. Co-Authored-By: Claude Opus 4.7 <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.
What
Adds a Linux-only boot-time check that parses
/proc/self/status'sCapEff:hex mask and refuses to start the relay if any capability bit outside an explicit allowlist (CAP_NET_BIND_SERVICEonly) is set. On non-Linux platforms the check is a no-op that emits a single startup-log line. Establishes the_linux.go/_other.gobuild-tag convention for the repo.Issue
Closes #79. Split from #42. Sibling of #77.
Testing
internal/relay/caps_test.go— cross-platform, table-driven tests forparseCapEff(value matrix, malformed inputs) andcheckCapEffMask(allowlist matrix, sentinel branchability, message content). Covers AC (a)–(d).internal/relay/caps_linux_test.go— Linux-only seam test forcheckCapabilitiesWithReaderwith injectedreadStatusclosures (allowed mask → nil, disallowed → sentinel, missing CapEff → wrapped parse error, read error → propagated).go test -race ./...clean,go vet ./...clean on bothGOOS=darwinandGOOS=linux(cross-compile).go test -c -o /dev/null ./internal/relay/underGOOS=linuxconfirms the Linux test file compiles.Architecture compliance
caps.go(sentinel, allowlist, parser, mask checker),caps_linux.go(Linux entry + read seam),caps_other.go(non-Linux no-op, explicit//go:build !linux), plus the two test files.CAP_NET_BIND_SERVICEonly (justified in code comment per Dockerfile + fly.toml — autocert binds:80/:443from uid 65532).ErrUnexpectedCapability, branchable viaerrors.Is; wrapped with all offending bit names + the allowlist + operator-fix string. All unexpected bits reported in one error (not first-only).readStatus func() (string, error)boundary, so AC case (d) (malformed/proc/self/statuscontent) exercisesparseCapEffend-to-end.main.gowiring is one block immediately afterCheckInsecureListenInProduction, beforestartedAt. Exit code 2, same as other boot-time refusals. No production-mode gating.allowedLogKeysallowlist for a startup-only diagnostic.err+ fixedfixstring only — no rawcap_effhex value field.🤖 Generated with Claude Code