Supply Chain Command Injection in AWS CDK's NodejsFunction — CVE-2026-11417
by Hesham Ashraf (HeshamASH) · 2026-07-05
- Severity
- High
- CVE
- CVE-2026-11417
- Category
- cloud
- Affected product
- aws-cdk-lib (npm package), NodejsFunction L2 construct
- Affected versions
- All versions prior to 2.245.0
- Disclosed
- 2026-07-05
- Patch status
- patched
Archive entry
intelseclab/poc-archiveMetadata
| Field | Value |
|---|---|
| Date Added | 2026-07-05 |
| Last Updated | 2026-06 |
| Author / Researcher | Hesham Ashraf (HeshamASH) |
| CVE / Advisory | CVE-2026-11417 |
| Category | cloud |
| Severity | High |
| CVSS Score | CVSSv3.1: 7.3, CVSSv4: 7.0 |
| Status | PoC |
| Tags | aws, cdk, supply-chain, command-injection, esbuild, nodejs, ci-cd, rce |
| Related | N/A |
Affected Target
| Field | Value |
|---|---|
| Software / System | aws-cdk-lib (npm package), NodejsFunction L2 construct |
| Versions Affected | All versions prior to 2.245.0 |
| Language / Platform | TypeScript/Node.js, runs on any machine executing cdk synth (dev workstations, CI/CD) |
| Authentication Required | No |
| Network Access Required | No (local build-time execution, though impact is typically delivered via a supply-chain vector) |
Summary
The AWS CDK NodejsFunction construct bundles Lambda handlers with esbuild during cdk synth, and prior to 2.245.0 it built the esbuild invocation by directly interpolating several user/construct-controlled properties (externalModules, loader, define, inject, esbuildArgs) into a single shell command string that was then executed via bash -c / cmd /c. Because none of these properties were sanitized for shell metacharacters, a value such as foo & echo PWNED > pwned.txt placed in externalModules would split the command and execute the attacker’s payload as a second, independent shell command. This made it possible for a malicious or compromised third-party CDK construct (published to npm or submitted via PR) to achieve arbitrary command execution on any machine that ran cdk synth, entirely bypassing install-time defenses like npm audit or --ignore-scripts since the injection fires at synthesis time rather than install time. The included PoC is a minimal CDK app that sets a poisoned externalModules entry and confirms RCE by checking for a marker file written by the injected command.
Vulnerability Details
Root Cause
bundling.ts in aws-cdk-lib’s aws-lambda-nodejs module joined an array of esbuild CLI arguments (some built from unsanitized construct properties) into a single string and passed it to bash -c / cmd /c, allowing shell metacharacters (&, ;, |, backticks, $()) in those properties to be interpreted by the shell.
Attack Vector
- Attacker publishes (or contributes via PR) a CDK construct/npm package that wraps
NodejsFunctionand sets anexternalModules/loader/define/inject/esbuildArgsvalue containing shell metacharacters and a payload command. - A developer imports the construct and runs
cdk synth(orcdk deploy, which synths first) locally or in CI/CD. - CDK builds the esbuild bundling command by string concatenation and executes it via a shell, causing the injected payload (e.g. exfiltrating
~/.aws/credentials) to run alongside the legitimate esbuild invocation. - Attacker collects exfiltrated data or achieves further code execution on the build host.
Impact
Arbitrary OS command execution on any developer machine or CI/CD runner performing CDK synthesis, enabling theft of AWS credentials, source code, or further pipeline compromise.
Environment / Lab Setup
Target: aws-cdk-lib 2.244.0 (pre-patch) via a local CDK TypeScript project
Attacker: Node.js 18/20, npm, ts-node, aws-cdk-lib, constructs, esbuild
Proof of Concept
PoC Script
See
poc/app.ts,poc/lambda/handler.ts, andpoc/package.jsonin this folder.
| |
app.ts defines a NodejsFunction whose bundling.externalModules contains foo & echo CVE-2026-11417 PWNED > ../pwned.txt. Running CDK synthesis on the vulnerable aws-cdk-lib version triggers the injected echo command, writing pwned.txt in the parent directory to confirm command execution.
Detection & Indicators of Compromise
Signs of compromise:
- Unexplained files or network callouts appearing during
cdk synth/cdk deployruns - CI/CD logs showing esbuild invocations followed by unrelated shell commands (
curl,cat ~/.aws/credentials, etc.) - Newly introduced or updated third-party CDK constructs with unusual
bundlingconfiguration values
Remediation
| Action | Detail |
|---|---|
| Primary fix | Update to aws-cdk-lib 2.245.0 or later, which replaced shell-based exec with array-based spawnSync (no shell interpretation) |
| Interim mitigation | Audit third-party CDK constructs for unusual bundling property values, pin construct versions in the lockfile, and review PRs that touch bundling configuration with extra scrutiny |
References
Notes
Mirrored from https://github.com/HeshamASH/CVE-2026-11417-AWS-CDK-RCE on 2026-07-05.