# Serious vulnerability in AWS Amplify allows officers to execute codes from afar

## **Overview**

Recently, cybersecurity experts discovered a highly critical security vulnerability in **AWS Amplify Studio**—a **visual user interface (UI) development platform** provided by Amazon Web Services. It helps developers and designers **quickly create, manage, and deploy web/mobile applications.** This vulnerability is identified as **CVE-2025-4318**, with a CVSS score of 9.5/10, allowing attackers to execute remote code (RCE) on a developer's machine or an automated CI/CD system.

## **Description of the Vulnerability**

Identifier: **CVE-2025-4318**

Severity: **Critical** (CVSS 4.0 = 9.5/10)

Disclosure Date: May 5, 2025

Description: A serious **RCE (Remote Code Execution)** vulnerability was discovered in the `@aws-amplify/codegen-ui` package—a component of **AWS Amplify Studio**

Main impacts:

* **Remote Code Execution (RCE)** with system build privileges
    
* Could lead to takeover of the CI/CD pipeline
    
* Affects the **entire software supply chain** if the generated code is widely used
    

## **Why does the vulnerability exist?**

* This vulnerability exists due to the inherent design mechanism in AWS's processing. As we know, the `@aws-amplify/codegen-ui` library allows users to create **UI components** by providing a JSON structure that describes properties (props) like `label`, `placeholder`, `value`, `onChange`, etc. To achieve this, the library allows users to use JavaScript expressions in the form of strings.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749628235475/c2ef16de-739a-4543-82de-c01a24214f9e.png align="center")

* This leads AWS Amplify to **use** `eval()` or `new Function()` to handle dynamic input without filtering, resulting in potential risks that attackers can exploit.
    
* Additionally, the execution of the vulnerability arises from the lack of mechanisms to control dangerous values or content.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749629018197/9f755e92-719a-41b6-8e20-e439cdbd2605.png align="center")

* This allows an attacker to execute RCE if they write a string like this into the `value` field:
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749629254635/a3fcd1cb-f92a-492e-ad59-a7c5ac1dd4b8.png align="center")

\=&gt; It will be executed **immediately in the Node.js environment** of the build machine or CI/CD server.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749630733360/0139ba6a-5ec0-4547-86f3-9923bd868c62.png align="center")

## **How an attacker exploits the vulnerability**

* Initially, the attacker will create a Bash script in the `@aws-amplify/codegen-ui@2.20.2` library.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749630157733/1b3e1b51-e911-4c90-ac43-4444aa11f8da.png align="center")

* When the attacker runs the script, it will cause several consequences:
    
    * A JSON file containing the payload `require('child_process').execSync('touch /tmp/pwned')` will be created.
        
    * Node.js will execute the payload through `new Function(...)`, mimicking the behavior of the old Amplify codegen.
        
    * A `/tmp/pwned` file will be created if the exploit is successful.
        
* Then the attacker continues by creating a file named `run.js` to execute the `eval()` payload from JSON and runs an HTTP server on port 8080 to serve the files if a browser needs to access them.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749630545275/cc683166-2e97-4920-8762-9072125621fa.png align="center")

* `run.js` will take the string from `placeholder.value` and execute it using `eval()`.
    
* `http-server` is used to serve files over HTTP, which can be used to:
    
    * Simulate a victim's machine accessing files from the attacker.
        
    * Demo in a sandbox environment.
        
* Finally, after running the script files and injecting malicious JavaScript code into the `JSON` files defining the interface, it can:
    
    * Execute system commands.
        
    * Access or steal sensitive data.
        
    * Modify files or install malware to maintain unauthorized access.
        

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749631277248/34e7a254-4148-41e8-b728-4055be4b9b3e.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749631284174/0d0cfbe8-4544-4414-b308-8729f8197737.png align="center")

## **Summary**

The vulnerability exists in the `@aws-amplify/codegen-ui` library version `2.20.2` and can affect **CI/CD pipelines**, **Amplify Studio applications**, or **local Node.js environments** if unsafe handling of user-submitted JSON component files occurs.

This vulnerability also demonstrates how a little carelessness in handling user data can lead to comprehensive system attacks, especially in the increasingly popular era of low-code/no-code.

## **Recommendations**

1. **Update to the latest version** of `@aws-amplify/codegen-ui`:
    
    * npm install @aws-amplify/codegen-ui@latest
        
2. **Do not download or use JSON UI component files from unknown sources**.
    
3. **Absolutely avoid using** `eval()`, `Function()`, or `vm.runInNewContext()` to process values from JSON without verification.
    
4. **Regularly check the directories** `/tmp` or `~` if you suspect the system has been compromised (`touch /tmp/pwned` is a sample payload).
    
5. **Use virtual machines or Docker** to test tools related to dynamic code generation (codegen) from the UI.
    

## **References**

1. [CVE-2025-4318 (CVSS 9.5): AWS Amplify RCE Flaw Exposed with PoC – CI/CD Pipelines at Risk](https://securityonline.info/cve-2025-4318-cvss-9-5-aws-amplify-rce-flaw-exposed-with-poc-ci-cd-pipelines-at-risk/)
    
2. [CVE-2025-4318: RCE in AWS Amplify Studio via Unsafe Evaluation](https://blog.securelayer7.net/cve-2025-4318-aws-amplify-rce/?utm_source=chatgpt.com)
