/

CVE-2026-18245

Severity:

CRITICAL RISK

(9.0)

Code Injection (CWE-94) in AWS Amplify UI Codegen

CVE-2026-18245

Analyzed

Vulnerability type

Category:

Code Injection in Code Generation

CWE:

CWE-94

Impact:

Arbitrary Code Execution Across Multiple Environments

Severity:

CRITICAL RISK

(9.0)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Improper control of code generation in Amazon @aws-amplify/codegen-ui-react allows crafted Studio component or theme schema values to be turned into executable JavaScript in generated output.

An authenticated attacker who can supply malicious schema data might cause arbitrary code execution in end-user browsers, developer machines, CI/CD pipelines, or server-side rendering environments when the generated code is built or run.

Improper control of code generation in Amazon @aws-amplify/codegen-ui-react allows crafted Studio component or theme schema values to be turned into executable JavaScript in generated output.

An authenticated attacker who can supply malicious schema data might cause arbitrary code execution in end-user browsers, developer machines, CI/CD pipelines, or server-side rendering environments when the generated code is built or run.

Affected context

This vulnerability appears in projects that rely on AWS Amplify Studio and @aws-amplify/codegen-ui-react to generate React components or themes from declarative schemas.

It is most relevant where:

  • Studio component or theme schemas are treated as trusted input
  • Generated code is automatically committed, built, or deployed without manual review
  • The same generated artifacts are used in multiple execution contexts (browser, Node.js tooling, CI/CD, server-side rendering)

The risk increases in collaborative environments where multiple authenticated users can create or modify schemas feeding the code generator.

This vulnerability appears in projects that rely on AWS Amplify Studio and @aws-amplify/codegen-ui-react to generate React components or themes from declarative schemas.

It is most relevant where:

  • Studio component or theme schemas are treated as trusted input
  • Generated code is automatically committed, built, or deployed without manual review
  • The same generated artifacts are used in multiple execution contexts (browser, Node.js tooling, CI/CD, server-side rendering)

The risk increases in collaborative environments where multiple authenticated users can create or modify schemas feeding the code generator.

Exploit preconditions

  • Attack surface: Amplify Studio component and theme schema inputs consumed by @aws-amplify/codegen-ui-react.
  • Required access: Authenticated ability to create or modify Studio schemas or otherwise influence the data fed into the code generator.
  • Trigger point: Running the code generation process and subsequently building, bundling, or executing the generated React code in any environment.
  • Why exploitation is possible: Insufficient input validation and sanitization allow untrusted schema values to be embedded directly into generated source files, effectively granting the attacker control over portions of the emitted JavaScript and enabling arbitrary code execution.
  • Attack surface: Amplify Studio component and theme schema inputs consumed by @aws-amplify/codegen-ui-react.
  • Required access: Authenticated ability to create or modify Studio schemas or otherwise influence the data fed into the code generator.
  • Trigger point: Running the code generation process and subsequently building, bundling, or executing the generated React code in any environment.
  • Why exploitation is possible: Insufficient input validation and sanitization allow untrusted schema values to be embedded directly into generated source files, effectively granting the attacker control over portions of the emitted JavaScript and enabling arbitrary code execution.

Why this happens

The underlying bug is an instance of CWE-94: Improper Control of Generation of Code (Code Injection) in a code generation pipeline.

The generator takes structured schema data from AWS Amplify Studio and emits React components and themes, but it does not adequately constrain or scrub dynamic values before interpolating them into executable code.

As a result, an attacker-controlled field in the schema can be transformed into syntactically valid JavaScript, bypassing the intent of prior validation added for CVE-2025-4318.

Abstractly, this reflects a pattern where configuration or design-time metadata is treated as harmless, yet is later converted into source code without enforcing strict, safe templates or escaping rules.

The underlying bug is an instance of CWE-94: Improper Control of Generation of Code (Code Injection) in a code generation pipeline.

The generator takes structured schema data from AWS Amplify Studio and emits React components and themes, but it does not adequately constrain or scrub dynamic values before interpolating them into executable code.

As a result, an attacker-controlled field in the schema can be transformed into syntactically valid JavaScript, bypassing the intent of prior validation added for CVE-2025-4318.

Abstractly, this reflects a pattern where configuration or design-time metadata is treated as harmless, yet is later converted into source code without enforcing strict, safe templates or escaping rules.

Potential impact

  • Arbitrary JavaScript execution in end-user browsers when they load the affected application.
  • Execution of malicious code on developer machines during local builds, tests, or tooling runs.
  • Compromise of CI/CD pipelines that build or lint the generated code, potentially enabling supply-chain attacks.
  • Code execution in server-side rendering environments, allowing data theft or further lateral movement.
  • Injection of backdoors or data exfiltration logic into production applications using the generated components.
  • Arbitrary JavaScript execution in end-user browsers when they load the affected application.
  • Execution of malicious code on developer machines during local builds, tests, or tooling runs.
  • Compromise of CI/CD pipelines that build or lint the generated code, potentially enabling supply-chain attacks.
  • Code execution in server-side rendering environments, allowing data theft or further lateral movement.
  • Injection of backdoors or data exfiltration logic into production applications using the generated components.

General mitigation guidance

Effective mitigation focuses on strictly constraining what user-provided schema values can influence in generated code and reducing trust in design-time metadata.

Recommended defensive patterns include:

  • Designing code generation templates so that untrusted values are treated purely as data, never as executable code or code fragments.
  • Applying rigorous validation and normalization of schema inputs, allowing only expected types, formats, and characters, and rejecting or neutralizing anything that could alter control flow.
  • Introducing escaping or encoding whenever schema values are embedded into strings, JSX props, or expressions, ensuring they cannot break out into arbitrary JavaScript.
  • Separating trusted configuration from user-editable metadata and enforcing least-privilege around who can modify schemas used for generation.
  • Incorporating security review gates for code generation processes, so generated artifacts are subject to the same scrutiny as hand-written source.

Effective mitigation focuses on strictly constraining what user-provided schema values can influence in generated code and reducing trust in design-time metadata.

Recommended defensive patterns include:

  • Designing code generation templates so that untrusted values are treated purely as data, never as executable code or code fragments.
  • Applying rigorous validation and normalization of schema inputs, allowing only expected types, formats, and characters, and rejecting or neutralizing anything that could alter control flow.
  • Introducing escaping or encoding whenever schema values are embedded into strings, JSX props, or expressions, ensuring they cannot break out into arbitrary JavaScript.
  • Separating trusted configuration from user-editable metadata and enforcing least-privilege around who can modify schemas used for generation.
  • Incorporating security review gates for code generation processes, so generated artifacts are subject to the same scrutiny as hand-written source.

How teams detect issues like this

Organizations can detect this class of vulnerability by focusing on the code generation flow and its outputs:

  • Use static analysis to flag patterns where untrusted configuration or schema data is concatenated, interpolated, or templated directly into source code, particularly around eval-like constructs, dynamic expressions, or template string insertion.
  • During code review, examine codegen templates and emitted files for suspicious patterns such as unescaped placeholders, raw insertion of user-controlled strings into JSX, or dynamic property access based on external data.
  • Establish policies requiring automated scans of generated code for common injection signatures, including malformed literals, unexpected control structures, or references that should not originate from schema inputs.
  • Employ automated security tools or linters tailored to JavaScript/TypeScript that can run as part of CI to detect dangerous code constructs in generated artifacts.

Organizations can detect this class of vulnerability by focusing on the code generation flow and its outputs:

  • Use static analysis to flag patterns where untrusted configuration or schema data is concatenated, interpolated, or templated directly into source code, particularly around eval-like constructs, dynamic expressions, or template string insertion.
  • During code review, examine codegen templates and emitted files for suspicious patterns such as unescaped placeholders, raw insertion of user-controlled strings into JSX, or dynamic property access based on external data.
  • Establish policies requiring automated scans of generated code for common injection signatures, including malformed literals, unexpected control structures, or references that should not originate from schema inputs.
  • Employ automated security tools or linters tailored to JavaScript/TypeScript that can run as part of CI to detect dangerous code constructs in generated artifacts.

Sources

SourceLink
aws.amazon.comaws.amazon.com/security/security-bulletins/2026-066-aws/
github.comgithub.com/aws-amplify/amplify-codegen-ui/releases/tag/v2.20.6
github.comgithub.com/aws-amplify/amplify-codegen-ui/security/advisories/GHSA-74xx-rjgf-m69j

Frequently asked

questions

Exploitation typically begins with an authenticated user manipulating Studio schemas, which may occur over the internet in multi-user environments.

Once malicious schemas influence generated code, the resulting arbitrary code execution can occur in browsers, local development setups, CI/CD pipelines, or server-side runtimes.

The attacker generally needs authenticated access to create or modify the schemas consumed by @aws-amplify/codegen-ui-react, or any equivalent ability to inject crafted values into the codegen input.

The safest approach is to ensure that schema or configuration values are never treated as executable code.

Implement strict validation, treat all such inputs as data only, escape or encode them appropriately, and design templates so that control flow and logic are fully defined by trusted code, not by user-provided metadata.

Future tools should adopt secure-by-design codegen patterns: define immutable templates, enforce strong typing and validation on inputs, restrict who can provide or modify generation metadata, continuously scan generated outputs, and incorporate security-focused reviews into the development and CI/CD lifecycle for any change that affects the code generation pipeline.

Exploitation typically begins with an authenticated user manipulating Studio schemas, which may occur over the internet in multi-user environments.

Once malicious schemas influence generated code, the resulting arbitrary code execution can occur in browsers, local development setups, CI/CD pipelines, or server-side runtimes.

The attacker generally needs authenticated access to create or modify the schemas consumed by @aws-amplify/codegen-ui-react, or any equivalent ability to inject crafted values into the codegen input.

The safest approach is to ensure that schema or configuration values are never treated as executable code.

Implement strict validation, treat all such inputs as data only, escape or encode them appropriately, and design templates so that control flow and logic are fully defined by trusted code, not by user-provided metadata.

Future tools should adopt secure-by-design codegen patterns: define immutable templates, enforce strong typing and validation on inputs, restrict who can provide or modify generation metadata, continuously scan generated outputs, and incorporate security-focused reviews into the development and CI/CD lifecycle for any change that affects the code generation pipeline.

Find out what's already
exploitable in your codebase.