Skip to content

WhoDB allows parameter injection in DB connection URIs leading to local file inclusion

High severity GitHub Reviewed Published Feb 6, 2025 in clidey/whodb • Updated Feb 6, 2025

Package

gomod github.com/clidey/whodb/core (Go)

Affected versions

< 0.0.0-20250127202645-8d67b767e005

Patched versions

0.0.0-20250127202645-8d67b767e005

Description

Summary

The application is vulnerable to parameter injection in database connection strings, which allows an attacker to read local files on the machine the application is running on.

Details

The application uses string concatenation to build database connection URIs which are then passed to corresponding libraries responsible for setting up the database connections.

This string concatenation is done unsafely and without escaping or encoding the user input. This allows an user, in many cases, to inject arbitrary parameters into the URI string. These parameters can be potentially dangerous depending on the libraries used.

One of these dangerous parameters is allowAllFiles in the library github.com/go-sql-driver/mysql. Should this be set to true, the library enables running the LOAD DATA LOCAL INFILE query on any file on the host machine (in this case, the machine that WhoDB is running on). Source: https://github.com/go-sql-driver/mysql/blob/7403860363ca112af503b4612568c3096fecb466/infile.go#L128

By injecting &allowAllFiles=true into the connection URI and connecting to any MySQL server (such as an attacker-controlled one), the attacker is able to read local files.

PoC

As this vulnerability does not require sending requests manually and can all be done using the WhoDB UI, screenshots are provided instead of HTTP requests.

For this proof-of-concept, a clean instance of WhoDB and MySQL were set up using podman (docker is a suitable alternative):

podman network create whodb-poc
podman run -d -p 8080:8080 --network whodb-poc docker.io/clidey/whodb
podman run -d --name mysql -e MYSQL_ROOT_PASSWORD=password --network whodb-poc docker.io/mysql:9

The attacker connects to the database via WhoDB. Note that in the Loc field, the string &allowAllFiles=true is inserted:

2025-01-21-13-28-08

After connecting, the attacker navigates to the scratchpad in /scratchpad.

The attacker first creates a demo table:

CREATE TABLE poc (
    line TEXT
);

The attacker then enables loading files from the server side. For the sake of clarity, do note that while this is required, the file is not being read from the remote server where MySQL is running, but the local machine that WhoDB is running on.

SET GLOBAL local_infile=1;

The attacker then uses the LOAD DATA LOCAL INFILE statement to read the contents of /etc/passwd (in this case from inside the container where WhoDB is running) into the previously created table:

LOAD DATA LOCAL INFILE '/etc/passwd'
INTO TABLE poc
FIELDS TERMINATED BY '\0'
LINES TERMINATED BY '\n';

The attacker then navigates to the poc table in the Tables view and observes that the file has been read successfully:

2025-01-21-14-04-47

Impact

While this proof-of-concept demonstrates local file inclusion, the root cause of the issue is the unsafe construction of database connection URIs from user input. Not all database connector libraries used in WhoDB were inspected; there may be libraries which allow for even more impactful parameters.

The attack requires no user authentication to WhoDB (only authentication to any database server, such as an attacker-controlled one) and no special configuration - the default configuration of the application is vulnerable.

References

@hkdeman hkdeman published to clidey/whodb Feb 6, 2025
Published to the GitHub Advisory Database Feb 6, 2025
Reviewed Feb 6, 2025
Last updated Feb 6, 2025

Severity

High

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
Changed
Confidentiality
High
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:C/C:H/I:N/A:N

EPSS score

Weaknesses

CVE ID

CVE-2025-24787

GHSA ID

GHSA-c7w4-9wv8-7x7c

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.