GHSL-2025-030_GHSL-2025-032: Path traversal in AWS SAM CLI - CVE-2025-3047, CVE-2025-3048
AWS SAM CLI does not prevent path traversal when building in a container with `sam build -u`, allowing a malicious build script to access files outside the build directory. An attacker could trick a victim into running `sudo sam build -u` on a malicious app to read any file on the host system.
Originally disclosed on GitHub Security Lab
AWS SAM CLI does not prevent path traversal when building in a container with sam build -u, enabling the build script to access files outside of the build directory. Since sam build -u uses docker, it needs to be run with elevated privileges, so this potentially enables the build script to read any file on the host…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The tool scans for symlinks in the build directory and mounts their resolved targets into the container without checking that the targets stay within the source directory.
Impact
This could be used in a supply chain attack to exfiltrate sensitive files from the victim's system, but the attacker must first trick the victim into running `sudo sam build -u` on a malicious app.
What the attacker needed
Victim runs `sudo sam build -u`; malicious SAM app with symlinks or Makefile; attacker can deliver the app to the victim
How it was found
- Create a basic SAM app using `sam init` with default options.
- Create a subdirectory and place symlinks pointing to sensitive files like `/etc/passwd` and `/etc/shadow`.
- Add a Makefile in that subdirectory that cats the symlinked files.
- Edit `template.yaml` to add a function that uses the subdirectory as CodeUri and sets BuildMethod to makefile.
- Run `sudo sam build -u` to build in a container.
- Observe that the contents of the sensitive files are printed to the console.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When you run a build command, it normally only looks at files inside your project folder. Here, a malicious project could include a shortcut (symlink) that points to a sensitive file like the system password file, and the build tool would follow it and show the file's contents. The attacker needs you to run the build with administrator rights, which makes the impact worse.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.