fix(kernel): require env:write for Shared-scope env mutations by joshuajbouw · Pull Request #1644 · astrid-runtime/astrid · GitHub
Skip to content

fix(kernel): require env:write for Shared-scope env mutations - #1644

Open
joshuajbouw wants to merge 1 commit into
mainfrom
cursor/shared-scope-env-write-6131
Open

fix(kernel): require env:write for Shared-scope env mutations#1644
joshuajbouw wants to merge 1 commit into
mainfrom
cursor/shared-scope-env-write-6131

Conversation

@joshuajbouw

Copy link
Copy Markdown
Member

Linked Issue

Closes #1544

This lands one public-runtime hardening item from the adversarial audit: Shared-scope env/secret mutations must require global env:write. Remaining #1544 sub-issues are tracked separately (#1545#1552).

Summary

Host-wide EnvStorageScope::Shared namespaces are not principal-private storage. The kernel previously treated EnvSet/EnvDelete as self-scoped whenever the caller named themselves, so a builtin self:* agent could write system:control:* secrets that every principal's capsule resolution falls back to.

This change gates Shared-scope env mutations on global env:write. Agent-scoped self writes stay on self:env:write.

Changes

  • Resolve EnvSet/EnvDelete with EnvStorageScope::Shared as AuthorityScope::Global, even when principal == caller.
  • Keep Agent-scoped env writes self-scoped when the caller targets themselves.
  • Add a regression test that builtin agent profiles cannot authorize Shared writes and still can authorize self:env:write.
  • Changelog fragment: changes/1544.security.md.

Verification

  • cargo fmt --all -- --check
  • cargo test -p astrid-kernel --lib shared_env_mutations --locked
  • cargo clippy -p astrid-kernel --locked --all-targets -- -D warnings

AI / Tool Assistance

Assisted-by: Cursor Grok 4.6

Cursor drafted the Shared-scope authority gate, the regression test, rustfmt/clippy cleanups, and this PR template. I reviewed that Shared writes require env:write, Agent-scoped self writes remain self:env:write, and the previous dedicated Shared match arm is gone so clippy::match_same_arms does not fire.

Checklist

  • Linked to an issue
  • Changelog fragment added under changes/1544.security.md
  • I understand every change in this PR and can explain its design, risks, and validation.
  • I reviewed and tested any meaningful tool-generated output included in this PR.
  • Every non-bot, non-merge commit has a matching Signed-off-by trailer.
Open in Web Open in Cursor 

Host-wide Shared env/secret namespaces are not principal-private storage.
Gate Shared EnvSet/EnvDelete on global env:write even when the caller
names themselves, so self:* agents cannot write system:control:* scopes.

Co-authored-by: Joshua J. Bouw <dev@joshuajbouw.com>
Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Copilot AI balanced review requested due to automatic review settings August 25, 2026 20:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@joshuajbouw joshuajbouw added area/kernel astrid-kernel: kernel router, event bus, socket newcomer-approved Maintainer has approved this new contributor's PR security Security issue or hardening labels Aug 25, 2026 — with Cursor
@joshuajbouw
joshuajbouw marked this pull request as ready for review August 25, 2026 20:18
@joshuajbouw joshuajbouw removed the newcomer-approved Maintainer has approved this new contributor's PR label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/kernel astrid-kernel: kernel router, event bus, socket security Security issue or hardening

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Adversarial hardening audit: public runtime fixes

3 participants