7.4high
Starship vulnerable to shell injection via undocumented, unpredictable shell expansion in custom commands
- Severity
- 7.4high CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.46% (higher than 41% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-vx24-x4mv-vwr5RUSTSEC-2024-0446
Description
Starship is a cross-shell prompt. Starting in version 1.0.0 and prior to version 1.20.0, undocumented and unpredictable shell expansion and/or quoting rules make it easily to accidentally cause shell injection when using custom commands with starship in bash. This issue only affects users with custom commands, so the scope is limited, and without knowledge of others' commands, it could be hard to successfully target someone. Version 1.20.0 fixes the vulnerability.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| starship starship | >= 1.0.0, < 1.20.0, from 1.0.0 before 1.20.0 | CVE List, NVD |
| starship (crates.io) | from 1.0.0 before 1.20.0, from 1.0.1-0 before 1.20.0 | GitHub Advisory Database, RustSec Advisory Database |
All scores
| GitHub_M | 7.4high CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | 7.4high CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| RustSec Advisory Database | 7.4high CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H |
| NVD | 7.0high CVSS:3.1 | CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:H/I:H/A:H |
Classification
What each source says
CVE List
Starship is a cross-shell prompt. Starting in version 1.0.0 and prior to version 1.20.0, undocumented and unpredictable shell expansion and/or quoting rules make it easily to accidentally cause shell injection when using custom commands with starship in bash. This issue only affects users with custom commands, so the scope is limited, and without knowledge of others' commands, it could be hard to successfully target someone. Version 1.20.0 fixes the vulnerability.
GitHub Advisory Database
Description
Starship is a cross-shell prompt. Starting in version 1.0.0 and prior to version 1.20.0, undocumented and unpredictable shell expansion and/or quoting rules make it easily to accidentally cause shell injection when using custom commands with starship in bash. Version 1.20.0 fixes the vulnerability.
PoC
Have some custom command which prints out information from a potentially untrusted/unverified source.
[custom.git_commit_name]
command = 'git show -s --format="%<(25,mtrunc)%s"'
style = "italic"
when = true
Impact
This issue only affects users with custom commands, so the scope is limited, and without knowledge of others' commands, it could be hard to successfully target someone.
RustSec Advisory Database
Summary
Undocumented and unpredictable shell expansion and/or quoting rules make it easily to accidentally cause shell injection when using custom commands with starship in bash.
Details
I wanted to show the git commit name in my prompt (I use bash), so I added a command:
[custom.git_commit_name]
command = 'git show -s --format="%<(25,mtrunc)%s"'
style = "italic"
when = true
To my surprise, when I had a commit with backticks in it, the backticks were expanded. e.g.:
touch foo
git add foo
git commit -m '`ls`'
Thankfully I noticed it on my own commit before checking out someone's code whose commit message was
rm -rf /important/stuff
The documentation says:
Command output is printed unescaped to the prompt
Whatever output the command generates is printed unmodified in the prompt.
This means if the output contains special sequences that are interpreted
by your shell they will be expanded when displayed. These special
sequences are shell specific, e.g. you can write a command module that
writes bash sequences, e.g. \h, but this module will not work in a fish
or zsh shell.
Format strings can also contain shell specific prompt sequences, e.g. Bash, Zsh.
However, it doesn't specifically mention shell injection with $() and backticks; it just mentions the prompt escape sequences, and the link doesn't suggest any shell injection possibilities either.
Furthermore, I can't even figure out how to properly escape things, because simply changing the command to
command = 'printf %q "$(git show -s --format="%<(25,mtrunc)%s")"'
doesn't work, as it's also adding a backslash before spaces. I also
tried use_stdin=false
I'm not 100% sure this qualifies as a vulnerability, but I feel it is not documented well enough to warn unsuspecting users, and it certainly is not documented how to properly quote things, because after 15-30 minutes of trying, I can't figure it out.
I see some past commits about fixing shell injection with $, and it does seem like the problem doesn't exist in build-in modules like git branch.
PoC
Have some custom command which prints out information from a potentially untrusted/unverified source.
[custom.git_commit_name]
command = 'git show -s --format="%<(25,mtrunc)%s"'
style = "italic"
when = true
Impact
People with custom commands, so the scope is limited, and without knowledge of people's commands, it could be hard to target people. The only one I saw in the example custom commands that may be vulnerable is the playerctl one.
NVD (es)
Starship es un aviso entre capas. A partir de la versión 1.0.0 y antes de la versión 1.20.0, las reglas de citación y/o expansión de shell impredecibles y no documentadas hacen que sea fácil provocar accidentalmente una inyección de shell cuando se usan comandos personalizados con starship en bash. Este problema solo afecta a los usuarios con comandos personalizados, por lo que el alcance es limitado y, sin el conocimiento de los comandos de otros, podría ser difícil apuntar a alguien con éxito. La versión 1.20.0 corrige la vulnerabilidad.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-41815 changed 2024-08-02 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-vx24-x4mv-vwr5 changed 2025-12-22 | CC-BY-4.0 |
| RustSec Advisory Database | RUSTSEC-2024-0446 changed 2026-10-12 | CC0-1.0 |
| NVD | CVE-2024-41815 changed 2026-06-17 | Public domain |