Summary
qnabot-on-aws versions 7.2.4 and earlier use the static-eval npm package in a way that allows crafted conditional chaining expressions to escape the intended sandbox through JavaScript prototype manipulation.
An authenticated administrator can abuse this behavior via the Content Designer interface to execute arbitrary code in the fulfillment Lambda runtime, potentially accessing backend resources not normally exposed through the UI.
Affected context
This vulnerability appears in qnabot-on-aws deployments that:
- Use versions 7.2.4 or earlier of the solution,
- Allow administrators to author or edit expressions/content via the Content Designer UI, and
- Evaluate those expressions server-side using static-eval within the Lambda-based fulfillment logic.
It becomes particularly relevant where the Lambda execution role has access to sensitive backend resources such as OpenSearch indices, S3 buckets, DynamoDB tables, or sensitive environment variables.
Exploit preconditions
- Attack surface: Administrative web interface (Content Designer) of qnabot-on-aws.
- Required access: Authenticated access with permissions equivalent to an administrator or any role that can define or modify conditional/expressive content evaluated by static-eval.
- Trigger point: Evaluation of crafted conditional chaining expressions or similar dynamic expressions during fulfillment execution in the Lambda function.
- Why exploitation is possible: The evaluation mechanism trusts user-supplied expressions and relies on static-eval for sandboxing. Through JavaScript prototype manipulation and crafted expression chains, an attacker can escape the evaluation sandbox and invoke arbitrary code in the Lambda context.
Why this happens
The core issue is the evaluation of user-controlled expressions as executable logic within the Lambda runtime.
qnabot-on-aws uses static-eval as a sandbox to interpret expressions supplied via the Content Designer, assuming that this confines execution to a safe subset of JavaScript.
However, the expression evaluator does not fully isolate or freeze the JavaScript object graph; prototype chains and internal objects remain reachable.
By crafting a conditional chaining expression that manipulates JavaScript prototypes, an attacker can pivot from benign expression evaluation to arbitrary function invocation, aligning with CWE-94: Improper Control of Generation of Code ('Code Injection').
The abstract pattern is: user-provided "configuration" or "business logic" is treated as code and evaluated in a privileged context without robust isolation, allowing expansion of "data" into "executable behavior."
Potential impact
- Execution of arbitrary JavaScript code within the fulfillment Lambda function.
- Reading sensitive Lambda environment variables (API keys, secrets, connection strings).
- Unauthorized access to OpenSearch indices, including search, read, or modification of indexed data.
- Unauthorized reading or modification of S3 objects accessible to the Lambda role.
- Unauthorized reading, modification, or deletion of DynamoDB table entries.
- Use of the Lambda's IAM role to pivot to other AWS services or resources within the same account, depending on granted permissions.
General mitigation guidance
Effective mitigation focuses on eliminating or strictly constraining dynamic code evaluation paths:
- Replace generic expression evaluators that interpret "JavaScript-like" syntax with declarative, non-Turing-complete configuration formats (e.g., whitelisted operators and fields mapped to explicit functions).
- Avoid executing user-supplied expressions as code; instead, implement explicit, server-side logic for supported conditions and business rules.
- Where an expression language is required, use interpreters designed with strong isolation guarantees and minimal feature sets, avoiding access to prototypes, constructors, or global objects.
- Enforce strict validation and normalization of expressions before evaluation, disallowing access to prototypes, constructors, or reflection-like features.
- Apply the principle of least privilege to the Lambda execution role so that, even if expression handling is abused, access to backend resources is minimized.
- Separate high-privilege operations into dedicated components or services that are never driven directly by user-supplied expressions.
How teams detect issues like this
Detection can blend code-centric and runtime-centric approaches:
- Static analysis and code review:
- Search for use of static-eval, eval, new Function, or similar dynamic evaluation APIs in the codebase.
- Flag any path where user-controlled or administrator-supplied fields from the Content Designer are passed into expression evaluators without strict sanitization and whitelisting.
- Review how expression evaluators are configured, checking for access to Object.prototype, Function constructors, or global objects.
- Configuration and policy checks:
- Establish internal policies prohibiting direct evaluation of user-supplied JavaScript or expressions in production code.
- Use automated security scanners or SAST tools tuned to detect dynamic evaluation patterns and sandbox escapes.
- Runtime and logging:
- Instrument Lambda functions to log unusual expression content or evaluation errors involving unexpected object types or prototype access.
- Monitor for anomalous resource access patterns originating from the fulfillment Lambda role (e.g., unusual S3, DynamoDB, or OpenSearch activity).

