Skip to content

fix(interpreter): gate allexport env updates#1821

Merged
chaliy merged 1 commit into
mainfrom
2026-06-02-fix-set-a-environment-variable-vulnerability
Jun 2, 2026
Merged

fix(interpreter): gate allexport env updates#1821
chaliy merged 1 commit into
mainfrom
2026-06-02-fix-set-a-environment-variable-vulnerability

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Jun 2, 2026

Motivation

  • Prevent set -a from persisting rejected assignments into the persistent environment and thereby bypassing the per-instance variable memory limits (TM-DOS-060).
  • Ensure env mirroring only occurs when the interpreter actually accepts the variable insert under the configured MemoryLimits.
  • Also prevent local updates under allexport from mutating env before budget checks succeed.

Description

  • Change insert_variable_checked to return a bool success indicator so callers can know whether the allocation was accepted while preserving silent rejection behavior.
  • In set_variable, run the memory budget check_variable_insert/record_variable_insert for existing local bindings before mutating the local frame or calling insert_env_checked under ALLEXPORT.
  • For global assignments with ALLEXPORT, only call insert_env_checked after insert_variable_checked returns true so rejected global inserts are not mirrored into self.env.
  • Add two regression unit tests test_allexport_rejected_global_update_does_not_mutate_env and test_allexport_rejected_local_update_does_not_mutate_env to ensure rejected inserts leave both shell variables and env unchanged.

Testing

  • Ran cargo test -p bashkit interpreter::tests::test_allexport_rejected --lib and the new regression tests passed.
  • Ran cargo fmt --check && cargo test -p bashkit allexport --lib and the allexport test group passed.
  • All added unit tests (test_allexport_rejected_*) and the existing test_allexport_respects_env_memory_limits passed.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Jun 2, 2026

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 f3dee9c Commit Preview URL Jun 02 2026, 09:24 AM

@chaliy chaliy force-pushed the 2026-06-02-fix-set-a-environment-variable-vulnerability branch from 5c9bee5 to f3dee9c Compare June 2, 2026 09:19
@chaliy chaliy merged commit 6907068 into main Jun 2, 2026
34 checks passed
@chaliy chaliy deleted the 2026-06-02-fix-set-a-environment-variable-vulnerability branch June 2, 2026 13:28
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