Skip to content
Heist/ feed
Back to feed
HighFix available

Shell expansion in custom commands

Type: advisorySources: OSV

## 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 t

Products
starship
Affected versions
Not specified
Fixed versions
1.20.0
CVEs
CVE-2024-41815
Confirmed fixed CVEs
Not specified
Updated in this feed
30 Oct 2026, 08:44 UTC · Revision 1

Source evidence

Shell expansion in custom commands

core-osv · Original source

Published 26 Jul 2024, 12:00 UTC

## 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 t

osv:RUSTSEC-2024-0446

starship

Fixed versions: 1.20.0

Complete source record
{
  "id": "b1acb12a0a281c668719df87078acf9eabe200e30ef2a22fcf59bb3b44e21cd7",
  "url": "https://osv.dev/vulnerability/RUSTSEC-2024-0446",
  "method": "structured",
  "payload": {
    "kind": "advisory",
    "title": "Shell expansion in custom commands",
    "summary": "## 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 t",
    "evidence": "osv:RUSTSEC-2024-0446",
    "products": [
      {
        "name": {
          "value": "starship",
          "evidence": "/affected/0/package/name"
        },
        "prerequisites": [],
        "fixed_versions": [
          {
            "value": "1.20.0",
            "evidence": "/affected/0/ranges"
          }
        ],
        "affected_versions": []
      }
    ],
    "severity": "high",
    "structured": {
      "id": "RUSTSEC-2024-0446",
      "aliases": [
        "CVE-2024-41815",
        "GHSA-vx24-x4mv-vwr5",
        "RUSTSEC-2024-0446"
      ],
      "metrics": [
        {
          "type": "CVSS_V3",
          "score": "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H"
        }
      ],
      "affected": [
        {
          "ranges": [
            {
              "type": "SEMVER",
              "events": [
                {
                  "introduced": "1.0.1-0"
                },
                {
                  "fixed": "1.20.0"
                }
              ]
            }
          ],
          "package": {
            "name": "starship",
            "purl": "pkg:cargo/starship",
            "ecosystem": "crates.io"
          },
          "database_specific": {
            "cvss": "CVSS:3.1/AV:L/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H",
            "source": "https://github.com/rustsec/advisory-db/blob/osv/crates/RUSTSEC-2024-0446.json",
            "categories": [
              "code-execution"
            ],
            "informational": null
          },
          "ecosystem_specific": {
            "affects": {
              "os": [],
              "arch": [],
              "functions": []
            },
            "affected_functions": null
          }
        }
      ],
      "modified": "2026-10-12T18:00:11.506829501Z",
      "provider": "osv",
      "references": [
        "https://crates.io/crates/starship",
        "https://rustsec.org/advisories/RUSTSEC-2024-0446.html",
        "https://github.com/starship/starship/commit/cfc58161e0ec595db90af686ad77a73df6d44d74"
      ],
      "provider_metadata": {
        "license": "CC-BY-4.0"
      }
    },
    "related_cves": [
      {
        "value": "CVE-2024-41815",
        "evidence": "/aliases"
      }
    ],
    "security_relevant": true,
    "severity_evidence": "/severity/0/score"
  },
  "source_id": "core-osv",
  "document_id": 306421,
  "published_at": "2024-07-26T12:00:00+00:00"
}