-
Notifications
You must be signed in to change notification settings - Fork 7
Cancellation flag race condition with Relaxed ordering in Node.js bindings #992
Copy link
Copy link
Open
Labels
securitySecurity vulnerability or hardeningSecurity vulnerability or hardening
Description
Summary
Both Bash::execute_sync and BashTool::execute_sync reset the cancellation flag at the start using Ordering::Relaxed. If two threads call execute_sync and cancel() concurrently, the relaxed ordering provides no happens-before guarantee. A cancel() call could be swallowed by a concurrent execute_sync that resets the flag. The async execute() method does NOT reset the flag, creating inconsistent behavior.
Severity: Low
Category: Race Condition / Concurrency
Affected Files
crates/bashkit-js/src/lib.rslines 275-276, 584-585
Code
self.state.cancelled.store(false, Ordering::Relaxed);Steps to Reproduce
// Thread 1:
bash.cancel();
// Thread 2 (concurrent):
bash.executeSync("sleep 10"); // Resets cancelled flag, swallowing the cancelImpact
Cancellation requests silently lost in concurrent usage. Scripts continue running when they should have been cancelled.
Acceptance Criteria
- Use
Ordering::SeqCstorRelease/Acquirepairs for the cancelled flag - Or: use a generation counter so cancellation targets a specific execution
- Make
execute_syncandexecuteconsistent in their reset behavior - Test: Concurrent cancel + execute doesn't lose the cancellation
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
securitySecurity vulnerability or hardeningSecurity vulnerability or hardening