Treat wildcard module exposure as a trust boundary decision, not a convenience feature. If untrusted code can load host built-ins, assume it can read host state or mutate host process behavior. Limit allowed modules to the smallest verified set, review proxy behavior carefully, and test for actions that persist after execution ends. Upgrade quickly when the sandbox vendor patches denied modules.
Why This Matters for Security Teams
Wildcard exposure of host built-in modules turns a sandbox from a containment mechanism into a policy gap. Once untrusted JavaScript can reach file, network, process, or crypto primitives, the question is no longer whether the code is “sandboxed” but whether the host boundary is still meaningful. That matters for supply chain risk, tenant isolation, and any workflow that executes third-party scripts, plugins, rules, or AI-generated code. NIST’s NIST SP 800-53 Rev 5 Security and Privacy Controls is clear that access control and system boundary protections must be deliberate, not assumed.
Practitioners often get tripped up by the “it is only a few built-ins” mindset. A narrow allowlist can still be enough to inspect secrets, alter runtime behavior, or stage a second step through exposed APIs. The real risk is not just direct abuse. It is the combination of callable host objects, proxy indirection, and runtime side effects that can survive after the sandboxed execution has ended. In practice, many security teams discover the problem only after a benign script has already demonstrated write access, not through intentional boundary testing.
How It Works in Practice
Handling this safely starts with treating module access as a privilege model, then validating that the sandbox enforces it consistently. A wildcard such as “allow all built-ins except a few” often fails when the sandbox resolves module names dynamically, forwards unknown property access through a proxy, or exposes helper objects that can be chained into privileged capabilities. The safest pattern is a strict allowlist of required modules, explicit deny-by-default behavior, and separate test cases for direct import, indirect reference, and reflective access.
Security teams should review three layers: what modules are exposed, what each exposed module can reach, and what survives across execution boundaries. The last point is easy to miss. A script may not need direct filesystem access if it can modify prototype state, cache objects, or logging hooks that later influence host code. Guidance from the OWASP Top 10 for Large Language Model Applications is useful here even outside LLMs because it emphasises prompt and tool boundary abuse, which maps closely to sandbox escape patterns.
- Enumerate every built-in module that the sandbox can resolve, including wildcard paths and aliases.
- Test for property traversal, dynamic import, proxy traps, and exception-based leakage.
- Confirm whether exposed modules can spawn processes, access network sockets, or reach environment variables.
- Check for state persistence through shared caches, globals, or host callbacks after the script exits.
- Pin sandbox and runtime versions so denied-module fixes are not delayed by dependency drift.
Where this guidance breaks down is in highly dynamic plugin platforms with shared runtimes and third-party extensions, because module resolution and object lifetimes are often coupled to application logic rather than the sandbox alone.
Common Variations and Edge Cases
Tighter module allowlisting often increases operational overhead, requiring organisations to balance developer convenience against a much lower blast radius. That tradeoff is especially sharp when teams rely on rapid plugin onboarding or user-authored automation. Best practice is evolving, but there is no universal standard for trusting wildcard exposure as “safe” just because the sandbox blocks obvious imports. A runtime that blocks one path may still leak capability through a helper object, error message, or wrapper function.
Edge cases deserve explicit testing. Some sandboxes isolate code execution but not resource access. Others isolate modules but share memory, event loops, or logging pipelines with the host. If the sandbox is used for agentic workflows, the boundary should also cover tool calls, not just JavaScript modules, because an agent with execution authority can chain a harmless-looking built-in into a high-impact action. The CISA Secure by Design guidance is relevant because it pushes teams to remove dangerous defaults rather than relying on post hoc monitoring.
For regulated or multi-tenant environments, the safest assumption is that wildcard exposure is unacceptable unless the host can prove the absence of privileged side effects under abuse testing. That makes regression testing, version pinning, and explicit module contracts part of the security control, not optional engineering hygiene.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP Agentic AI Top 10, MITRE ATLAS and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| NIST CSF 2.0 | PR.AC-4 | Wildcard module exposure is an access control and least-privilege problem. |
| OWASP Agentic AI Top 10 | Sandboxed code with tool access mirrors agentic boundary abuse patterns. | |
| NIST AI RMF | AI RMF helps frame sandbox trust decisions as governance and risk controls. | |
| MITRE ATLAS | AML.TA0001 | Abuse of exposed capabilities fits adversarial manipulation of runtime behaviour. |
| OWASP Non-Human Identity Top 10 | Exposed host modules often include secrets and identity-related credentials. |
Restrict sandbox module access to the minimum verified set and review privilege boundaries regularly.
Related resources from NHI Mgmt Group
- How should security teams handle identity features built inside product engineering teams?
- How should security teams handle AI assistants that can leak user data through rendering features?
- How should security teams handle Snowflake configuration recovery after mistakes or incidents?
- How should security teams handle application admin accounts that can affect the host OS?
Deepen Your Knowledge
Reviewed and updated by the NHIMG editorial team on August 26, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org