Skip to content

Username Enumeration via API Responses in ZimaOS

Moderate
LinkLeong published GHSA-3f6g-8r88-3mx5 Oct 24, 2024

Package

https://github.com/IceWhaleTech/ZimaOS/

Affected versions

≤v1.2.4

Patched versions

1.2.5

Description

Summary

The API endpoint http://<Server-IP>/v1/users/login in ZimaOS returns distinct responses based on whether a username exists or the password is incorrect. This behavior can be exploited for username enumeration, allowing attackers to determine whether a user exists in the system or not. Attackers can leverage this information in further attacks, such as credential stuffing or targeted password brute-forcing.

Details

The vulnerability arises due to differing error messages returned by the API when invalid usernames and incorrect passwords are provided. Attackers can use this discrepancy to enumerate valid usernames by comparing the responses for existing and non-existing usernames.

PoC

  1. Send a POST request to the login endpoint with a valid username but an incorrect password:
POST http://<Server-IP>/v1/users/login
Request:
{
  "username": "validuser",
  "password": "wrongpassword"
}

Response:

{
  "Success": 10013,
  "message": "User does not exist or password is invalid"
}

  1. Send another POST request with a non-existent username:
Request:
{
  "username": "invaliduser",
  "password": "somepassword"
}

Response:

{
  "Success": 10006,
  "message": "User does not exist"
}

The differing error messages allow an attacker to determine whether a username exists in the system by comparing the two responses.

YouTube Video PoC

Unlisted YouTube PoC Link

Impact

  1. User Enumeration: Attackers can collect valid usernames for use in future attacks, such as password brute-forcing or credential stuffing.
  2. Targeted Attacks: With knowledge of valid usernames, attackers can focus their efforts on known users, increasing the success rate of other attacks, including phishing or account takeover.

Recommendation

  1. Generic Error Message: Return a generic error message for both incorrect usernames and passwords, such as "Invalid username or password," regardless of the actual error.

Possible Fix Code:

Before:

if user_does_not_exist:
    return {
        "Success": 10006,
        "message": "User does not exist"
    }
elif password_incorrect:
    return {
        "Success": 10013,
        "message": "User does not exist or password is invalid"
    }

After:

if user_does_not_exist or password_incorrect:
    return {
        "Success": 10013,
        "message": "Invalid username or password"
    }

Logging and Monitoring

Log failed login attempts and generate alerts for suspicious activity, such as a high volume of failed logins.

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N

CVE ID

CVE-2024-49358

Weaknesses

Credits