Race condition
Description
The system presents unexpected behavior when the inputs of a specific functionality do not arrive in the expected order.
Impact
- Overwrite, delete or read arbitrary files from the system.
- Cause unexpected behaviour in the application.
Recommendation
Ensure that the verification and use of inputs must be realized at the same time or in an atomic way.
Threat
Anonymous attacker in the system.
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: L
- Attack complexity: L
- Privileges required: N
- User interaction: N
- Scope: U
- Confidentiality: L
- Integrity: L
- Availability: N
Temporal
- Exploit code madurity: P
- Remediation level: X
- Report confidence: R
Result
- Vector string: CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N/E:P/RL:X/RC:R
- Score:
- Base: 5.1
- Temporal: 4.7
- Severity:
- Base: Medium
- Temporal: Medium
Code Examples
Compliant code
The application uses inputs under a proper method to avoid issues
public static void main(String[] args) {
Scanner input = new UserInput(*args);
String username = input.userId;
String password = input.password;
try {
if(username.equals(username) && password.equals(password)){
ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
users check = new users(username, password);
signIn(user, check);
}
} catch (InterruptedException e) {
//Code to catch exception when log in is not successful
}
}
Non compliant code
If the input comes in an unexpected order, the application can not fulfill the requirements
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
String username = input.next();
String password = input.next();
try {
if(username.equals(username) && password.equals(password)){
ScheduledExecutorService executor = Executors.newScheduledThreadPool(2);
users check = new users(username, password);
signIn(user, check);
}
} catch (InterruptedException e) {
//Code that could be executed even when the data is right, if for some reason, the client side sends it in a wrong order
}
}
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.