Summary
ai-scanner, an AI model safety scanner built on NVIDIA garak, contains a critical remote code execution vulnerability in the BrowserAutomation::PlaywrightService component.
Between versions 1.0.0 and 1.4.0, attacker-controlled JavaScript can be injected and executed within the browser automation layer, potentially leading to arbitrary code execution on the host running ai-scanner under certain deployment configurations.
Affected context
The vulnerability appears in ai-scanner deployments that use the BrowserAutomation::PlaywrightService for interacting with web content or model evaluation workflows.
It is relevant when:
- User or external data influences JavaScript or browser-automation scripts,
- The service constructs or evaluates JavaScript dynamically, and
- That JavaScript is executed in an environment with access to local resources, process capabilities, or sensitive evaluation outputs.
The risk is higher when the ai-scanner process runs with elevated privileges or on shared infrastructure used for broader AI evaluation or pipeline orchestration.
Exploit preconditions
- Attack surface: The interface(s) that feed data into
BrowserAutomation::PlaywrightService(e.g., model prompts, web inputs, task definitions, or configuration driving browser behavior). - Required access: Ability to supply or influence content that is ultimately turned into JavaScript or browser actions (e.g., remote user of an AI safety portal, integrated system, or pipeline that forwards external inputs to ai-scanner).
- Trigger point: Execution of browser automation tasks where the service evaluates or injects JavaScript, such as page scripts, evaluation probes, or dynamic hooks.
- Why exploitation is possible: The service performs dynamic JavaScript evaluation or command construction using input that is not fully constrained or safely encoded, enabling injection of attacker-controlled code that can be executed by the automation engine and, by extension, may pivot into executing arbitrary code on the underlying host.
Why this happens
This issue stems from a classic code injection pattern as described by CWE-94: Improper Control of Generation of Code ('Code Injection').
The BrowserAutomation::PlaywrightService likely constructs or evaluates JavaScript strings based on runtime data (such as user-supplied content, prompts, or configuration) without enforcing strict separation between data and code.
When such dynamically built scripts are passed to the Playwright engine or related execution APIs, an attacker can craft input that breaks out of the intended context and injects new JavaScript statements.
If those statements can trigger operations with side effects beyond the browser context—such as interacting with the filesystem via automation hooks, invoking system utilities, or leveraging bindings exposed to the page—this can escalate to remote code execution on the ai-scanner host.
Potential impact
- Execution of arbitrary code on the system running ai-scanner, depending on the integration between Playwright and the host environment.
- Compromise of AI evaluation workflows, including manipulation of test results and safety findings.
- Theft or modification of sensitive data handled during scanning (e.g., prompts, model outputs, evaluation artifacts).
- Lateral movement to other systems or services reachable from the compromised host.
- Abuse of the scanning environment as a launchpad for further attacks (e.g., running arbitrary scripts, probing internal networks).
General mitigation guidance
Mitigation should focus on preventing untrusted data from becoming executable code within browser automation and related scripting mechanisms.
Common defensive patterns include:
- Eliminate dynamic code generation: Avoid building JavaScript strings from external input; use fixed, parameterized scripts where user data is treated solely as data, not code.
- Constrain input to safe formats: Where dynamic behavior is necessary, represent actions as structured data (e.g., JSON commands, enumerated actions, whitelists of options) instead of free-form script text.
- Apply strict encoding and validation: Ensure any data inserted into scripts is properly encoded for its context (e.g., as string literals) and constrained using allowlists rather than pattern-based filters.
- Reduce execution privileges: Run ai-scanner and browser automation components under least-privilege accounts, isolating them via containers, sandboxes, or VM boundaries so that a compromise has limited blast radius.
- Isolate browser automation environments: Use hardened, disposable environments for Playwright sessions, minimizing host integrations and disabling unnecessary APIs or bridges between browser and host code.
- Separate configuration from executable logic: Treat configuration files, prompts, and test definitions as declarative data and avoid feeding them directly into eval-like mechanisms or script generators.
How teams detect issues like this
Detection efforts can focus on both code-level and runtime indicators:
Static and code-review strategies
- Search for dynamic JavaScript construction and evaluation patterns in the browser automation service (e.g., use of
eval-like constructs, script injection APIs, or string concatenation to form code). - Flag any locations where untrusted or loosely validated input flows into script-building or browser execution APIs.
- Introduce secure coding guidelines that prohibit arbitrary script generation and mandate structured, parameterized automation patterns.
- Use static analysis rules or linters tailored to detect dynamic code execution and tainted data flows into automation APIs.
Runtime and policy-based strategies
- Instrument browser automation runs with logging that records script sources and high-risk operations, enabling anomaly detection for unexpected or unusually complex scripts.
- Apply host- and container-level monitoring for suspicious child processes, file modifications, or network activity initiated from browser automation components.
- Enforce policy in CI/CD that blocks deployments when high-risk patterns (e.g., new eval-like calls, unsanitized script building) are introduced into the codebase.

