Skip to content

fix(auth): enforce blob and kv token scopes - #86

Closed
bherila wants to merge 6 commits into
mainfrom
codex/fix-permission-checks-for-blob-and-kv-apis
Closed

bherila wants to merge 6 commits into
mainfrom
codex/fix-permission-checks-for-blob-and-kv-apis

Conversation

@bherila

@bherila bherila commented Aug 15, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Resolve a privilege-escalation where project-scoped deployment tokens without storage scopes could access Blob and KV data because data-plane handlers only used project_id() and did not check the newly-introduced Blob*/Kv* permissions.
  • Make deployment-token authorization consistent with the rest of the platform by mapping storage permissions to deployment-token variants and enforcing them on all data-plane operations.

Description

  • Added permission checks using the permission_guard! macro to Blob handlers so writes require BlobWrite, deletes require BlobDelete, and reads/head/download/copy require BlobRead as appropriate (crates/temps-blob/src/handlers/handler.rs).
  • Added permission checks to KV handlers so reads/ttl/keys require KvRead, writes/incr/expire require KvWrite, and deletes require KvDelete (crates/temps-kv/src/handlers/handler.rs).
  • Extended DeploymentTokenPermission with blob:read|write|delete and kv:read|write|delete and mapped standard Permission::Blob*/Permission::Kv* to the new deployment-token variants in AuthContext::has_permission (crates/temps-entities/src/deployment_tokens.rs, crates/temps-auth/src/context.rs).
  • Added a regression unit test that verifies deployment-token storage permissions map to the corresponding standard permissions and updated CHANGELOG.md under ## [Unreleased] to document the security fix (crates/temps-auth tests and CHANGELOG.md).

Testing

  • Ran cargo check --lib -p temps-auth -p temps-blob -p temps-kv which completed successfully and produced no warnings considered blocking by the project's rules.
  • Ran the new unit test cargo test -p temps-auth deployment_token_storage_permissions_map_to_standard_permissions which passed.
  • Verified compilation of the affected crates as part of the workspace build (cargo check / crate checks completed successfully).

Codex Task

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

bherila and others added 6 commits August 15, 2026 07:43
Runs cargo check + lib tests on the tempsdev1 self-hosted runner for
pushes to main/feature/**/fix/** and manual dispatch. Scoped to push
and workflow_dispatch only (never pull_request/pull_request_target) so
fork PRs can never execute on the self-hosted host. Uses a persistent,
isolated CARGO_TARGET_DIR outside the runner work dir so the build
cache survives checkout cleans and is reused across runs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A warm CARGO_TARGET_DIR caches the example plugins' build-script fingerprint,
so after actions/checkout git-cleans the source tree the script is skipped and
include_dir!(".../web/dist") panics on the missing dir. Recreate the debug
placeholder assets up front so the check is independent of build-script cache.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
temps-cli embeds crates/temps-cli/dist via include_dir!; like the example
plugins its build.rs placeholder is skipped on a warm cache, so generalize the
prep step to cover every include_dir! dist target, not just the plugins.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…vy crates

cargo test --lib --workspace pulled in temps-domains' real-Pebble ACME tests,
which need a challenge-responder network this box can't provide. Match the
unit-a/unit-b crate list from rust-tests.yml instead (Docker+networking-heavy
crates run in hosted's dedicated integration jobs, not here).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Its local_provider tests launch a real bundled Chromium against live
example.com/github.com. The hosted ubuntu-latest image ships
google-chrome system-wide so headless_chrome reuses it; this self-hosted
box has no system browser, so headless_chrome auto-downloads one and the
parallel tests race on the binary (Text file busy) and debug ports (no
available ports between 8000 and 9000). It is a live-network browser
integration test, not a unit test, and hosted CI already covers it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bherila
bherila force-pushed the codex/fix-permission-checks-for-blob-and-kv-apis branch from ea6272a to e450000 Compare August 15, 2026 07:43
@github-actions

Copy link
Copy Markdown

📓 Changelog preview

This is what your commits will add to the generated CHANGELOG.md at release time (via git-cliff). Do not edit CHANGELOG.md by hand — it is generated from your Conventional Commit messages.

## [Unreleased]

### CI

- **self-hosted:** Add build/test workflow on push to bherila fork
- **self-hosted:** Recreate example-plugin web/dist before cargo check
- **self-hosted:** Also recreate temps-cli/dist placeholder
- **self-hosted:** Run hosted unit-test crate set, skip integration-heavy crates
- **self-hosted:** Exclude temps-screenshots live-browser tests

### Fixed

- **auth:** Enforce blob and kv token scopes

@bherila

bherila commented Oct 11, 2026

Copy link
Copy Markdown
Owner Author

The functional change was carried into upstream security-hardening PR gotempsh#676 and its merged replacement gotempsh#677. Upstream gotempsh#676 explicitly lists this fork PR in its source coverage.

Fork main has now been fast-forwarded to upstream main at 7250ab59b38d3138014ade7f5d6391c856eaa4f7. Closing this obsolete fork PR as part of the upstream synchronization; its branch history is retained.

@bherila bherila closed this Oct 11, 2026
@bherila
bherila deleted the codex/fix-permission-checks-for-blob-and-kv-apis branch October 11, 2026 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant