Improper resource allocation
Description
The system allocates unnecessary resources due to the use of improper programming practices or inefficient algorithms. Alternatively, the allocation can be controlled by an external source (e.g., user input), and hence, requests that consume an enormous amount of resources are processed without any restriction.
Impact
Exhauste the servers resources and thus, prevent other users from accessing the server.
Recommendation
Use stable and optimized libraries to perform functions without a large computational expense.
Threat
Authenticated attacker from the Internet.
Expected Remediation Time
⌚ 30 minutes.
Score
Default score using CVSS 3.1. It may change depending on the context of the vulnerability.
Base
- Attack vector: N
- Attack complexity: L
- Privileges required: N
- User interaction: N
- Scope: U
- Confidentiality: N
- Integrity: N
- Availability: L
Temporal
- Exploit code madurity: X
- Remediation level: X
- Report confidence: X
Result
- Vector string: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:X/RL:X/RC:X
- Score:
- Base: 5.3
- Temporal: 5.3
- Severity:
- Base: Medium
- Temporal: Medium
Code Examples
Compliant code
Efficient algorithms should be used to handle data
public static void bubbleSort(int[] numbers) {
System.out.printf("Unsorted array in Java :%s %n", Arrays.toString(numbers));
for (int i = 0; i < numbers.length; i++) {
for (int j = numbers.length -1; j > i; j--) {
if (numbers[j] < numbers[j - 1]) {
swap(numbers, j, j-1);
}
}
}
System.out.printf("Sorted Array using Bubble sort algorithm :%s %n",
Arrays.toString(numbers));
}
Non compliant code
An improper sorting algorithm is an example of improper resource allocation
public class QuickSortDemo {
public static void main(String args[unsorted]) {
System.out.println("Unsorted array :" + Arrays.toString(unsorted));
QuickSort algorithm = new QuickSort();
algorithm.sort(unsorted);
// printing sorted array
System.out.println("Sorted array :" + Arrays.toString(unsorted));
}
}
Requirements
- 072. Set maximum response time
- 158. Use a secure programming language
- 164. Use optimized structures
- 173. Discard unsafe inputs
Search for vulnerabilities in your apps for free with our automated security testing! Start your 21-day free trial and discover the benefits of our Continuous Hacking Machine Plan. If you prefer a full service that includes the expertise of our ethical hackers, don't hesitate to contact us for our Continuous Hacking Squad Plan.