Objective: Gain Unauthorized Access/Execute Arbitrary Code via Manipulated rc
Configuration
+-----------------------------------------------------+
| Gain Unauthorized Access/Execute Arbitrary Code |
| via Manipulated rc Configuration |
+-----------------------------------------------------+
|
|
+-------------------------+ [HR]
| Manipulate Environment |
| Variables |
+-------------------------+
|
+---------+---------+ [HR]
| Set Malicious |
| Environment |
| Variables |
+---------+---------+
|
+---------+---------+ [HR][CN]
| Override |
| Configuration |
| Values |
+---------+---------+
|
+---------+---------+ [HR][CN]
| Inject |
| Arbitrary |
| Values |
+---------+---------+
|
+---------+---------+ [HR][CN]
| Exploit |
| Application |
| Logic |
+---------+---------+
Attack Tree Path: Manipulate Environment Variables [HR]
- Description: The attacker gains control over the environment in which the application runs, allowing them to set or modify environment variables.
- Sub-Steps:
- Set Malicious Environment Variables [HR]
- Description: The attacker sets environment variables that
rc
will read and use as configuration values. - Methods:
- Compromised CI/CD Pipeline: The attacker gains access to the Continuous Integration/Continuous Deployment system and modifies environment variables used during the build or deployment process.
- Compromised Container: The attacker gains access to the container (e.g., Docker) in which the application is running and sets environment variables within the container.
- Shared Hosting (Less Common, but Possible): In poorly configured shared hosting environments, an attacker might be able to influence the environment of other applications running on the same server.
- Vulnerable Application/Service: An attacker exploits a vulnerability in another application or service running on the same system to modify the environment of the target application.
- Description: The attacker sets environment variables that
- Override Configuration Values [HR][CN]
- Description: The attacker sets environment variables with names that match existing configuration keys used by the application.
rc
prioritizes environment variables over configuration files, so these malicious values will override the legitimate ones. - Impact: This is a critical step because it's where the attacker's control over the environment translates into control over the application's configuration.
- Description: The attacker sets environment variables with names that match existing configuration keys used by the application.
- Inject Arbitrary Values [HR][CN]
- Description: The attacker injects values that are designed to be harmful when used by the application.
- Examples:
- Database Credentials: Injecting fake database credentials to redirect the application to a malicious database.
- API Keys: Injecting invalid or compromised API keys to disrupt service or gain unauthorized access to external services.
- Commands: Injecting shell commands that will be executed by the application if it uses configuration values in an unsafe way (e.g., command injection).
- File Paths: Injecting malicious file paths to cause the application to read or write to unintended locations (e.g., path traversal).
- Exploit Application Logic [HR][CN]
- Description: This is the most critical step. The attacker's injected configuration values are used by the application in a way that leads to a security vulnerability being exploited.
- Vulnerabilities:
- SQL Injection: The application uses a configuration value directly in a database query without proper sanitization or parameterization.
- Command Injection: The application uses a configuration value as part of a system command that is executed.
- Path Traversal: The application uses a configuration value as a file path without proper validation, allowing the attacker to access files outside of the intended directory.
- Cross-Site Scripting (XSS): While less direct, if a configuration value is used to render HTML without proper encoding, it could lead to XSS.
- Other Logic Flaws: Any situation where the application uses a configuration value in an unsafe or unexpected way.
- Set Malicious Environment Variables [HR]