Skip to content

fix(sandbox): keep the network grant current; check fd handoffs structurally - #336

Merged
jkyberneees merged 4 commits into
mainfrom
fix/residual-minors-2026-10-25
Oct 25, 2026
Merged

jkyberneees merged 4 commits into
mainfrom
fix/residual-minors-2026-10-25

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

Summary

Two small follow-ups to the sandbox-network hardening released in v2.36.1.

Changes

The project network grant follows the latest approval

  • The in-process record of approved project network IDs is now written on every successful approval path.
  • An approval that requests no networks drops any earlier grant for the directory. That covers an override without network fields, a Dockerfile.odek-only approval, and a run with nothing to approve.
  • Before, such approvals left an earlier grant in place.

The fd-handoff guard checks structure, not one line

  • The guard against handing an owned descriptor to the key or frame fd reader (the cause of the old unlinkat: bad file descriptor flake) used to match only .Fd() on the same line as t.Setenv.
  • It now parses the test files. In any test function that sets the key or frame fd env var, every .Fd() call must sit inside syscall.Dup or dupFD.
  • A self-test feeds it raw handoffs (direct, through a variable, inside a closure) and dup handoffs, so it can't quietly stop flagging.
  • The malformed-value loop in TestRED_RtOps_KeyFDStrictParse now hands over a dup too, and closes it when the reader rejects the value.

Testing

  • New tests: TestRED_ProjectNetworkGrant_LaterApprovalWithoutNetworksClearsIt and TestRED_ProjectNetworkGrant_ApprovalWithoutOverrideClearsIt, both revert-checked to fail without the fix. TestRED_FDHandoffChecker_FlagsRawAndAcceptsDup covers the checker.
  • Suites: go test -count=1 ./cmd/odek and go test -race ./cmd/odek pass.
  • Lint: golangci-lint reports 0 issues and gofmt is clean.
  • Review: an adversarial review (Sonnet) found no blocking issues. Its two cheap suggestions, covering the remaining approval paths and the checker self-test, are included.

🤖 Generated with Claude Code

jkyberneees and others added 4 commits October 25, 2026 15:15
…o networks

recordProjectNetworkGrant returned early for an approved override
without network fields, leaving an earlier grant for the same directory
in place. The record now always matches the latest approval.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fd-handoff guard only matched .Fd() on the same line as t.Setenv, so
a descriptor read into a variable first slipped past. Parse the test
files instead: in any test that sets the key or frame fd env var, every
.Fd() call must sit inside syscall.Dup or dupFD. The malformed-value loop
of the key-fd parse test now hands over a dup as well and closes it when
the reader rejects the value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…proval

A Dockerfile-only approval, or a run with nothing to approve, left an
earlier network grant for the directory in place. Every approval path
now records the grant for its own override, which drops it when the
project requests no networks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Feed the checker raw handoffs (direct, through a variable, inside a
closure) and dup handoffs, so it cannot quietly stop flagging anything.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
odek b197d26 Commit Preview URL

Branch Preview URL
Oct 25 2026, 02:32 PM

@jkyberneees
jkyberneees merged commit 92963ab into main Oct 25, 2026
10 checks passed
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