In May 2025, AWS disclosed a critical remote code execution (RCE) vulnerability, CVE-2025-4318, in the @aws-amplify/codegen-ui package—a core dependency for AWS Amplify Studio’s UI code generation pipeline.
The flaw, rated 9.5 on the CVSS scale, stemmed from improper input validation in the expression-binding logic that processes user-defined JavaScript expressions within UI component schemas.
AWS Amplify Studio enables developers to visually build UI components and export them as React code.
These components often include dynamic properties, such as labels, placeholders, or values—expressed as JavaScript snippets stored in JSON schemas.
The vulnerable versions (≤2.20.2) evaluated these expressions using unsafe techniques like eval(), new Function(), or vm.runInNewContext(), without any input sanitization or sandboxing.
Below is a simplified code snippet illustrating the vulnerable logic:
javascript// Vulnerable code in evaluateExpression.ts (pre-patch)
export function evaluateExpression(expression: string): any {
return eval(expression); // ⚠️ UNSAFE
}
This approach allowed any string from the component schema to be executed as JavaScript, giving attackers the ability to run arbitrary code if they could inject malicious expressions into component JSON files.
A typical attack involved crafting a malicious component schema, such as:
json{
"componentType": "TextField",
"name": "MaliciousRCEComponent",
"properties": {
"label": { "value": "Exploitable Field" },
"placeholder": { "value": "require('child_process').execSync('touch /tmp/rce-success')" }
}
}
When the vulnerable Amplify codegen process parsed and evaluated this, it would execute the shell command on the server, demonstrating full RCE.
AWS patched the vulnerability in version 2.20.3 by replacing unsafe evaluation with a sandboxed, filtered approach.
The new logic uses a safeEval wrapper that:
javascript// Patched code in evaluateExpression.ts (v2.20.3+)
import { safeEval } from './sandbox';
export function evaluateExpression(expression: string): any {
return safeEval(expression); // Safe wrapper
}
// sandbox.ts
export function safeEval(expr: string): any {
if (!isValidExpression(expr)) {
throw new Error("Unsafe expression detected.");
}
return Function('"use strict"; return (' + expr + ')')();
}
function isValidExpression(expr: string): boolean {
const blacklist = ['require', 'process', 'child_process', 'global', 'Function', 'eval'];
return !blacklist.some(word => expr.includes(word));
}
This incident underscores the critical importance of input validation and sandboxing in low-code platforms, where user-supplied expressions can become high-impact attack vectors if mishandled.
AWS Amplify Studio users should act swiftly to secure their environments and adopt best practices for ongoing code safety.
To Upgrade Your Cybersecurity Skills, Take Diamond Membership With 150+ Practical Cybersecurity Courses Online – Enroll Here
Attackers abused compromised ConnectWise Cloud Backup credentials to access Microsoft 365 customer environments, prompting ConnectWise…
Anthropic says an internal Claude research model reconstructed how the National Security Agency generated seeds…
Two WordPress Core vulnerabilities can be chained to execute remote code without authentication, according to…
A newly disclosed OpenBSD kernel exploitation chain combines a shared memory accounting flaw with a…
GhostAction attackers have expanded their GitHub credential theft campaign with a second stage that disguises…
Indian authorities have warned that SideCopy hackers are targeting Indian organizations, including academic institutions, with…