When .. Costs You Everything: A Path Traversal in Gemini CLI's Sk
A skill name in a SKILL.md file was not properly sanitised, allowing a value of '..' to pass through. When joined with the skills directory, this caused the CLI to recursively delete the entire ~/.gemini directory and then copy attacker-controlled files into it, leading to persistent code execution on the next launch.
Published on medium.com
TL;DR — A single missing character in a sanitizer regex allowed a malicious SKILL.md to recursively delete ~/.gemini and replace it with attacker-controlled files, yielding persistent code execution on the next CLI launch. This post walks the bug from frontmatter to rm -rf, explains why "blocklist the bad characters"…
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 write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The sanitizer only removed Windows-reserved characters and did not reject '.' or '..', so path.join normalised the name to a parent directory, and the code then performed a recursive delete and copy on that path.
Impact
The attacker could delete the user's entire Gemini configuration directory and plant files that execute arbitrary commands on the next CLI launch, or in the link variant, redirect all future credential writes to attacker-controlled storage.
What the attacker needed
Victim installs a malicious skill; user runs the CLI with consent
The fix
The code should validate that the skill name is a single safe path component and verify that the resolved destination path stays within the intended base directory before performing any destructive operation.
How it was found
- Create a directory containing a SKILL.md file whose frontmatter name is '..'.
- Run the Gemini CLI skills install command on that directory with user scope and consent.
- The CLI resolves the destination to the parent of the skills directory and deletes it recursively.
- The CLI then copies the attacker's directory contents into the deleted location.
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 write-up has not been written yet. The Original tab links to the source.
The Gemini CLI lets you install 'skills' from folders. The name of a skill is used to create a folder inside a safe place, but the code that cleans the name forgot to block the special name '..', which means 'go up one folder'. So a malicious skill could make the CLI delete the whole settings folder and put its own files there, which then run automatically the next time you start the CLI.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.