Authorization (AZQ)
How to play?The key concept for this card is that inadequate input validation and privilege checks.
Scenario: Christopher’s Command Injection with Elevated Privileges
Imagine a situation where Christopher, exploiting system vulnerabilities, injects commands that the application executes at a higher privilege level. This occurs due to:
- Elevated Privilege Execution: The application lacks proper controls to restrict command execution based on the user's privilege level.
- Inadequate Command Filtering: Insufficient validation and filtering of user-submitted commands allow for execution of unauthorized commands.
Example
Christopher targets a web application with a feature that allows users to input commands for data retrieval. He discovers that this feature does not adequately validate or sanitize input, nor does it check the privilege level at which commands are executed. Exploiting this, he injects a command intended for administrative functions. The system, failing to restrict command execution based on user privileges, runs the command at an administrative level, allowing Christopher unauthorized access to sensitive system operations and data.
Threat Modeling
STRIDE
This scenario maps primarily to STRIDE: Elevation of Privilege (EoP).
Elevation of Privilege occurs when an attacker performs actions or executes commands beyond their authorized privileges. Christopher injects a command that the system executes at a higher privilege level than his own user role, gaining unauthorized administrative access. The attack exploits lack of privilege checks combined with command injection, allowing him to perform higher-privilege operations.
What can go wrong?
Such vulnerabilities can lead to unauthorized system access, data breaches, and potential control over critical system functionalities. This can manifest in various forms, including but not limited to:
- Unauthorized command execution with elevated privileges
- Log injection leading to unauthorized access or actions
- SQL injection that allows for unauthorized data manipulation or access
- LDAP injection that can lead to unauthorized access or changes in directory services
- XML injection that can lead to unauthorized access or manipulation of XML data
- OS command injection that allows attackers to execute arbitrary commands on the server with elevated privileges
- Remote code execution (RCE) that allows attackers to run arbitrary code on the server with elevated privileges
- File inclusion vulnerabilities that allow attackers to include and execute files on the server with elevated privileges
- Insecure deserialization that allows attackers to execute arbitrary code or commands with elevated privileges
- XPath injection that allows attackers to manipulate XML data and potentially execute commands with elevated privileges
- Script injection that allows attackers to execute scripts in the context of the application with elevated privileges
- Cross-site scripting (XSS) that allows attackers to execute scripts in the context of the application with elevated privileges
- Parameter pollution that allows attackers to manipulate parameters and potentially execute commands with elevated privileges
- IMAP injection that allows attackers to manipulate email data and potentially execute commands with elevated privileges
- NoSQL injection that allows attackers to manipulate NoSQL databases and potentially execute commands with elevated privileges
For more things that can go wrong, see the Common Attack Patterns related to this card in the table below.
What are we going to do about it?
Firstly apply appropriate input validation and encoding. In cases where the application must run with elevated privileges, raise privileges as late as possible, and drop them as soon as possible.
- Implement strict input validation and sanitization to prevent command injection attacks.
- Ensure that all commands are executed only at the appropriate privilege level, preventing users from executing commands with elevated privileges.
- Regularly review and update security protocols to safeguard against command injections and unauthorized privilege escalation.
- Implement robust logging and monitoring to detect and respond to any unauthorized command execution attempts.
- Conduct regular security testing, including penetration testing and code reviews, to identify and address potential vulnerabilities related to command injection and privilege escalation.
- Implement mitigations such as using secure coding practices, employing least privilege principles, and utilizing security frameworks that provide built-in protections against command injection and privilege escalation.
- Ensure input validation and encoding are applied consistently across all user inputs, especially those that interact with system commands or sensitive operations.
- Consider implementing multiple layers of security, including continuous consumer identity verification, device security posture assessment, and contextual risk analysis when evaluating access to administrative interfaces or critical functions.
- Only use recommended cryptographic functions and libraries for any operations that involve sensitive data or security controls, and ensure they are properly implemented to prevent vulnerabilities that could be exploited for command injection or privilege escalation.
- Regularly audit and update security measures to maintain a high level of protection against evolving threats related to command injection and privilege escalation.
For detailed advice on how to mitigate threats related to the card, see the ASVS and OWASP Developer Guide requirements in the table below.
Mappings
OWASP ASVS (v5.0): 1.1.1,1.1.2,1.2.1,1.2.2,1.2.3,1.2.4,1.2.5,1.2.6,1.2.7,1.2.8,1.2.9,1.2.10,1.3.1,1.3.2,1.3.3,1.3.4,1.3.5,1.3.6,1.3.7,1.3.8,1.3.9,1.3.10,3.1.1,3.4.2,3.4.3,3.4.6,3.4.7,3.4.8,3.5.2,3.5.3,3.5.4,3.5.5,3.5.6,3.5.7,3.5.8,3.6.1,5.1.1,5.2.2,5.3.1,5.3.2,5.4.1,5.4.2,5.4.3,6.7.1,8.3.3,8.4.2,11.6.1,11.6.2,13.3.1,13.3.2,13.3.3,13.4.5,15.2.5,16.3.3,16.4.1
STRIDE: Elevation of Privilege
CAPEC™: 93,122,233,242,248,636
CAPEC Map
| Code | Title | ASVS |
|---|---|---|
| 93 | Log Injection-Tampering-Forging | 1.2.3,1.2.4,16.3.3,16.4.1 |
| 122 | Privilege Abuse | 1.2.3,5.4.3,16.3.3 |
| 233 | Privilege Escalation | 1.2.3,3.1.1,3.4.2,3.4.3,3.4.6,3.4.7,3.4.8,3.5.2,3.5.3,3.5.4,3.5.5,3.5.6,3.5.7,3.5.8,3.6.1,5.4.3,6.7.1,8.3.3,8.4.2,11.6.1,11.6.2,13.3.1,13.3.2,13.3.3,13.4.5,15.2.5,16.3.3 |
| 242 | Code Injection | 1.1.1,1.1.2,1.2.1,1.2.2,1.2.3,1.2.4,1.2.5,1.2.6,1.2.7,1.2.8,1.2.9,1.2.10,1.3.1,1.3.2,1.3.3,1.3.4,1.3.5,1.3.6,1.3.7,1.3.8,1.3.9,1.3.10,1.3.11,1.3.12,1.4.1,1.4.2,1.4.3,1.5.1,1.5.2,1.5.3,3.1.1,3.2.1,3.2.2,3.2.3,3.4.3,3.4.6,3.4.7,3.5.4,3.5.5,3.5.6,3.5.7,3.6.1,3.7.1,3.7.2,3.7.3,3.7.4,3.7.5,5.1.1,5.2.2,5.3.1,5.3.2,5.4.1,5.4.2,5.4.3,10.4.7,15.1.1,15.1.2,15.1.4,15.1.5,15.2.1,15.2.4,15.2.5,16.3.3,16.4.1 |
| 248 | Command Injection | 1.2.4,1.2.5,1.2.6,1.2.7,1.2.8,1.2.9,1.2.10,1.3.2,1.3.3,1.3.6,1.3.8,1.3.10,1.3.11,5.1.1,5.2.2,5.3.1,5.3.2,5.4.1,5.4.2,5.4.3,16.3.3,16.4.1 |
| 636 | Hiding Malicious Data or Code within Files | 1.2.3,5.1.1,5.2.2,5.3.1,5.3.2,5.4.1,5.4.2,5.4.3,16.3.3 |