criticalCVE-2025-4318Jul 30, 2026

CVE-2025-4318: @aws-amplify/codegen-ui-react Eval Injection (RCE)

Pranav Khune
Penetration Testing Team Lead, SecureLayer7

A missing input-validation check in AWS Amplify Studio's code generator lets any authenticated user drop arbitrary JavaScript into a component schema property and have it executed on the build server.

Package@aws-amplify/codegen-ui-react
Ecosystemnpm
Affected<= 2.20.2
Fixed in2.20.3
CVE-2025-4318: @aws-amplify/codegen-ui-react Eval Injection (RCE)

The problem

The expression-binding function in @aws-amplify/codegen-ui-react (versions <= 2.20.2) converts component schema properties directly into JavaScript expressions without any sanitization.

An authenticated user who can call the create-component API or AWS CLI command can craft a malicious component JSON, inject arbitrary Node.js code into a property value, and have it run during the code-generation or preview step. The build server, not the browser, is the execution target, so the impact reaches CI/CD infrastructure and any secrets available to the build process.

Proof of concept

A working proof-of-concept for CVE-2025-4318 in @aws-amplify/codegen-ui-react, with the exact payload below.

json
{
  "componentType": "TextField",
  "name": "MaliciousRCEComponent",
  "properties": {
    "label": {
      "value": "Exploitable Field"
    },
    "placeholder": {
      "value": "require('child_process').execSync('touch /tmp/rce-success')"
    }
  }
}

The vulnerable code treated every string in a component property's value field as trusted JavaScript, evaluating it with unsafe runtime execution functions (eval, new Function, or vm.runInNewContext) before any validation.

Because Node's require is in scope at build time, placing require('child_process').execSync(...) in any evaluated property field is enough to pop a shell. The patch in commit ca98c38 (PR #1174) added sanitization to the binding-expression path, blocking dangerous identifiers such as require and process before the expression is evaluated.

A follow-up fix in 2.20.4 (PR #1196) addressed residual cases.

Root cause: CWE-95, Improper Neutralization of Directives in Dynamically Evaluated Code.

The fix

Upgrade to @aws-amplify/codegen-ui-react >= 2.20.4 (2.20.3 is a partial fix only). There is no workaround; the package must be updated. Review any forked or vendored copies of the library and back-port the sanitization from commit ca98c38 and PR #1196. Audit existing component schemas for suspicious expression values, and restrict component-creation permissions to trusted users only.

Reported by ray the bounty hunter.

References: [1][2][3][4][5][6]

Related research