Skip to content

fix(security): revoke execution-scoped host capabilities - #2264

Merged
chaliy merged 1 commit into
mainfrom
codex/execution-scoped-capabilities
Aug 6, 2026
Merged

chaliy merged 1 commit into
mainfrom
codex/execution-scoped-capabilities

Conversation

@chaliy

@chaliy chaliy commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

What changed

Execution extensions, custom and resolved builtin VFS access, host-call brokers, and tool callback request context now share one revocable capability lease per exec*() call. Completion, timeout, cancellation, or dropped futures revoke retained handles deterministically. Cleanup is bounded and idempotent, with only sanitized status and capped failure counts exposed through ExecResult.

Trusted hosts that intentionally need session-lived raw VFS access must opt in explicitly with BuiltinRegistry::insert_trusted; no compatibility shim preserves implicit unscoped access.

Why

Retained extension values, cloned VFS handles, and owned callback context could outlive the execution that authorized them, enabling late or cross-request access to sensitive facilities.

Before / After

Before: a custom builtin could clone Context.fs, or a callback could retain request context, and keep using it after completion or cancellation.

After: positive in-request access succeeds; completion, cancellation, late-use, and cross-request tests return the stable execution capability revoked error. Cleanup-failure coverage proves poison recovery is bounded, idempotent, and does not expose lock or host internals. Explicit trusted-host registration remains usable across calls.

Proof:

  • just pre-pr
  • cargo test -p bashkit --test integration execution_capability_tests (8 passed)
  • cargo test -p bashkit --test integration host_call_execution_tests (7 passed)
  • cargo bench -p bashkit --bench parallel_execution
  • cargo check --workspace --all-targets
  • just check-okf && just check-doc-links

Risk

  • Medium
  • Extension consumers must access values through ExecutionCapability::try_with/run; retained handles now fail after request completion by design.
  • ToolArgs request-context getters return revocation-aware results.
  • Trusted registry integrations that intentionally retain raw VFS access must use insert_trusted.

Checklist

  • Tests added or updated
  • Backward compatibility considered

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 6, 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
bashkit b515a1d Commit Preview URL

Branch Preview URL
Aug 06 2026, 01:34 AM

@chaliy
chaliy force-pushed the codex/execution-scoped-capabilities branch 4 times, most recently from 4cc7862 to 7bd67c5 Compare August 6, 2026 01:17
@chaliy
chaliy force-pushed the codex/execution-scoped-capabilities branch from 7bd67c5 to b515a1d Compare August 6, 2026 01:33
@chaliy
chaliy merged commit 650e645 into main Aug 6, 2026
46 checks passed
@chaliy
chaliy deleted the codex/execution-scoped-capabilities branch August 6, 2026 01:47
chaliy added a commit that referenced this pull request Aug 6, 2026
#2264 moved `ctx.execution_budget()` behind `ExecutionCapability`, and
#2265 added bzip2 call sites against the old `Option<&ExecutionBudget>`
shape. Each was green against its own base; together they don't compile,
so `main` is broken.

Decompression meters the budget incrementally as it streams, so it needs
the budget itself rather than a consume/lease call. `with_budget` gives
it one for the duration of a closure, alongside the existing
consume/lease helpers, so the borrow stays inside a checked scope and a
revoked execution reports `Cancelled` instead of handing out a live
reference. The stdout lease site folds into the `lease_budget_bytes`
helper that already existed.

Bundled here rather than split out because it blocks this branch's CI.
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