Cornucopia (C2)
Lee peut contourner les contrôles applicatifs car des fonctions à risque ont été utilisées à la place d'alternatives plus sûres, ou il y a des erreurs de conversion de type, ou car l'application n'est pas fiable lorsqu'une ressource externe est indisponible, ou il y a des situations d'accès concurrent, des problèmes d'initialisation, de fuite ou d'allocation de ressources, ou des débordements peuvent survenir
The key concept behind this card is that insecure coding practices and implementation flaws—such as risky functions, race conditions, and overflows—can allow attackers to bypass application controls and tamper with system behavior.
Scenario: Lee's Bypassing of Application Controls
Imagine a scenario where Lee bypasses application controls due to various coding and implementation vulnerabilities. This situation arises from:
- Use of Risky Programming Functions: The application utilizes dangerous functions in its code instead of safer alternatives.
- Type Conversion Errors: Inaccurate or improper type conversions lead to vulnerabilities.
- Dependency on External Resources: The application’s reliability is compromised when external resources are unavailable.
- Race Conditions: Concurrent processes lead to conditions where the application’s behavior is unpredictable.
- Resource Initialization or Allocation Issues: Problems in initializing or allocating resources create vulnerabilities.
- Potential for Overflows: The application is susceptible to overflows, such as buffer overflows, due to inadequate handling.
Example
Lee discovers that a web application uses risky functions that are known to be vulnerable to injection attacks. He exploits these functions to manipulate the application’s behavior. Additionally, Lee takes advantage of type conversion errors to cause unexpected behaviors in the application. He also notices that the application fails to handle scenarios where an external API is down, using this to trigger a denial of service. Furthermore, Lee exploits a race condition by initiating simultaneous processes that alter the application’s intended flow, and he triggers a buffer overflow to execute arbitrary code.
Threat Modeling
STRIDE
The applicable STRIDE category here is primarily Tampering, with potential secondary impacts depending on the specific exploitation.
Lee is altering or influencing the application’s behavior through exploitation of unsafe code patterns, type conversion errors, race conditions, and overflows. Tampering in STRIDE covers unauthorized modification of data or code or causing the application to behave differently than intended, which is what occurs here. Exploiting buffer overflows or unsafe functions to inject malicious code directly falls under Tampering.
What can go wrong?
Such vulnerabilities can lead to a range of issues, from unauthorized access and data breaches to complete system compromise.
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?
- Replace risky and vulnerable functions with safer alternatives and follow secure coding practices. Use non-executable stacks when available.
- Use checksums or hashes to verify the integrity of interpreted code, libraries, executables, and configuration files.
- Implement thorough error handling and validation for type conversions. Make no assumptions about availability of other resources, and handle all exceptions.
- Design the application to handle unavailability or failures of external resources gracefully.
- Address potential race conditions through proper synchronization and concurrency controls.
- Ensure robust initialization and allocation of resources, variables and other data stores, do not rely on garbage collection for performance sensitive operations, free allocated memory and resources when possible, rigorously check for potential overflows and verify that buffer sizes are large enough.
- Regularly audit and test the application for these vulnerabilities, and update practices as needed.
- Utilize locking to prevent multiple simultaneous requests and synchronization mechanism to prevent race conditions and protect shared variables and resources from inappropriate concurrent access.
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
STRIDE: Tampering
OWASP ASVS: 1.4.1,1.4.2,1.4.3,3.7.1,11.2.4,11.2.5,11.3.1,15.1.1,15.1.2,15.1.3,15.1.4,15.2.4,15.1.5,15.2.1,15.2.2,15.2.5,15.4.1,15.4.2,15.4.3,15.4.4,16.5.2,16.5.3
CAPEC: 25,26,77,100,124,125,128,129,130,131,446
OWASP DevGuide: SFL8,SFL10,ACM9,MM1,MM2,MM3,MM4,MM5,MM6,MM8,MM9
SAFECode: 3,5,6,7,9,22,25,26,34
CAPEC™ Map
| Code | Title | ASVS |
|---|---|---|
| 25 | Forced Deadlock | 1.4.1,1.4.2,15.4.3,15.4.4,16.5.2,16.5.3 |
| 26 | Leveraging Race Conditions | 15.4.1,15.4.2,16.5.3 |
| 77 | Manipulating User-Controlled Variables | 16.5.3 |
| 100 | Overflow Buffers | 16.5.2,16.5.3 |
| 124 | Shared Resource Manipulation | 15.4.3,15.4.4,16.5.2,16.5.3 |
| 125 | Flooding | 15.1.3,15.2.2,16.5.2,16.5.3 |
| 128 | Integer Attacks | 1.4.1,1.4.2,16.5.3 |
| 129 | Pointer Manipulation | 1.4.1,1.4.2,1.4.3,16.5.2,16.5.3 |
| 130 | Excessive Allocation | 1.4.1,1.4.2,1.4.3,15.1.3,15.2.2,16.5.2,16.5.3 |
| 131 | Resource Leak Exposure | 1.4.1,1.4.2,1.4.3,15.4.1,16.5.2,16.5.3 |
| 446 | Malicious Logic Insertion into Product via Inclusion of Third-Party Component | 3.7.1,15.1.1,15.1.2,15.1.4,15.1.5,15.2.1,15.2.4,15.2.5 |
| 463 | Padding Oracle Crypto Attack | 11.2.4,11.2.5,11.3.1,16.3.3 |