Improper control of interaction frequency
Description
The system does not limit the amount of requests (rate limit) that a user can post to the server in a short period of time.
Impact
- Fill the application logs with junk information.
- Saturate the server with multiple requests causing a possible denial of service.
Recommendation
Limit the number of requests that can be made by the same host in defined time slots.
Threat
Anonymous attacker from the Internet.
Expected Remediation Time
⌚ 60 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: L
- 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:L/A:L/E:X/RL:X/RC:X
- Score:
- Base: 6.5
- Temporal: 6.5
- Severity:
- Base: Medium
- Temporal: Medium
Code Examples
Compliant code
Set a reasonable limit to the number of requests allowed for a user
import rateLimit from 'express-rate-limit';
//Middleware that limits the amount of requests
export const rateLimiterUsingThirdParty = rateLimit({
windowMs: 24 * 60 * 60 * 1000,
max: 100,
message: 'You have exceeded the 100 requests in 24 hrs limit!',
headers: true,
});
Non compliant code
The application does not restrict the number of requests performed by a single user
const rateLimit = require("express-rate-limit");
const apiLimiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: None
});
Requirements
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.