Summary
rust-iot-platform exposes an unauthenticated endpoint that accepts and stores arbitrary scripts as calculation rules. When a malicious rule is triggered, the server evaluates the script without sandboxing, allowing an attacker to execute arbitrary JavaScript within the server process.
Affected context
The vulnerability occurs in deployments where the calc-rule creation route is reachable without authentication and accepts a caller-controlled script field. Stored rules are later evaluated by the calculation runtime through a JavaScript engine without an effective sandbox or equivalent execution boundary.
Exploit preconditions
- Attack surface: HTTP API endpoint for creating calculation rules
- Required access: Network access to the endpoint; authentication is not required by the affected route
- Trigger point: Execution of a stored calculation rule by the server
- Why exploitation is possible: User-controlled script content is passed to an unsandboxed JavaScript evaluator and runs in the server process
Why this happens
The underlying flaw is a failure to treat submitted calculation logic as untrusted code. The application accepts arbitrary script content, does not consistently enforce its authentication guard on the creation route, and later evaluates that content using quick_js::Context::eval() without a sufficient sandbox. This behavior maps to CWE-94: Improper Control of Generation of Code, because externally controlled input is treated as executable program logic.
Potential impact
- An unauthenticated attacker may execute arbitrary JavaScript in the server process
- The attacker could access application data or runtime capabilities exposed to the JavaScript context
- Application availability and integrity may be affected
- Server-side compromise could enable further access depending on process privileges and deployment isolation
General mitigation guidance
Mitigation generally focuses on removing unauthenticated access to rule-management functions and eliminating the execution of unrestricted user-supplied code.
Common defensive patterns include:
- Enforcing authentication and authorization consistently on all calculation-rule routes
- Replacing arbitrary scripts with a constrained expression language or predefined operations
- Applying strict allowlists, schemas, and length limits to rule definitions
- Using a capability-limited execution environment with explicit resource and API restrictions when dynamic evaluation is unavoidable
- Running the service with least privilege and isolating calculation workers from sensitive systems
- Treating stored rules as untrusted data throughout their lifecycle
How teams detect issues like this
Organizations can detect similar issues through:
- Static analysis rules identifying dynamic evaluation APIs such as
evaland embedded scripting engines - Code review checks for request handlers that accept executable content
- Route and middleware analysis to identify endpoints missing authentication or authorization guards
- API inventory tests that verify protected operations reject unauthenticated requests
- Runtime monitoring for unexpected rule creation, script execution, and unusual calculation activity
- Policy enforcement that prohibits unrestricted code execution from externally controlled input
Automated code review and security scanning tools may help identify dynamic execution and missing access-control patterns early.

