WhoDB is an open source database management tool. While the application only displays Sqlite3 databases present in the directory `/db`,…
GitHub_M·CWE-22·Published 2025-02-06
WhoDB is an open source database management tool. While the application only displays Sqlite3 databases present in the directory `/db`, there is no path traversal prevention in place. This allows an unauthenticated attacker to open any Sqlite3 database present on the host machine that the application is running on. Affected versions of WhoDB allow users to connect to Sqlite3 databases. By default, the databases must be present in `/db/` (or alternatively `./tmp/` if development mode is enabled). If no databases are present in the default directory, the UI indicates that the user is unable to open any databases. The database file is an user-controlled value. This value is used in `.Join()` with the default directory, in order to get the full path of the database file to open. No checks are performed whether the database file that is eventually opened actually resides in the default directory `/db`. This allows an attacker to use path traversal (`../../`) in order to open any Sqlite3 database present on the system. This issue has been addressed in version 0.45.0 and all users are advised to upgrade. There are no known workarounds for this vulnerability.
WhoDB is an open source database management tool. While the application only displays Sqlite3 databases present in the directory `/db`, there is no path traversal prevention in place. This allows an unauthenticated attacker to open any Sqlite3 database present on the host machine that the application is running on. Affected versions of WhoDB allow users to connect to Sqlite3 databases. By default, the databases must be present in `/db/` (or alternatively `./tmp/` if development mode is enabled). If no databases are present in the default directory, the UI indicates that the user is unable to open any databases. The database file is an user-controlled value. This value is used in `.Join()` with the default directory, in order to get the full path of the database file to open. No checks are performed whether the database file that is eventually opened actually resides in the default directory `/db`. This allows an attacker to use path traversal (`../../`) in order to open any Sqlite3 database present on the system. This issue has been addressed in version 0.45.0 and all users are advised to upgrade. There are no known workarounds for this vulnerability.
WhoDB has a path traversal opening Sqlite3 database in github.com/clidey/whodb/core
### Summary While the application only displays Sqlite3 databases present in the directory `/db`, there is no path traversal prevention in place. This allows an unauthenticated attacker to open any Sqlite3 database present on the host machine that the application is running on. ### Details WhoDB allows users to connect to Sqlite3 databases. By default, the databases must be present in `/db/` (or alternatively `./tmp/` if development mode is enabled). Source: https://github.com/clidey/whodb/blob/ba6eb81d0ca40baead74bca58b2567166999d6a6/core/src/plugins/sqlite3/db.go#L14-L20 If no databases are present in the default directory, the UI indicates that the user is unable to open any databases:  The database file is an user-controlled value. This value is used in `.Join()` with the default directory, in order to get the full path of the database file to open. Source: https://github.com/clidey/whodb/blob/ba6eb81d0ca40baead74bca58b2567166999d6a6/core/src/plugins/sqlite3/db.go#L26 No checks are performed whether the database file that is eventually opened actually resides in the default directory `/db`. This allows an attacker to use path traversal (`../../`) in order to open any Sqlite3 database present on the system. ### PoC Before running the container, an example Sqlite3 database with dummy "secret" data was created: ```sh DB_FILE=$(mktemp) echo "CREATE TABLE secret_table (data TEXT); INSERT INTO secret_table VALUES ('secret data')" | sqlite3 "$DB_FILE" ``` The container was then created with nothing mounted into `/db`, and the dummy database mounted into `/etc/secret.db`: ```sh podman run -d -p 8080:8080 -v "$DB_FILE":/etc/secret.db docker.io/clidey/whodb ``` The attacker sends a HTTP request to determine whether the `secret.db` is accessible by setting the `Database` value to `../etc/secret.db`: ```http POST /api/query HTTP/1.1 Host: localhost:8080 content-type: application/json ... {"operationName":"Login","variables":{"credentials":{"Type":"Sqlite3","Hostname":"","Database":"../etc/secret.db","Username":"","Password":"","Advanced":[]}},"query":"mutation Login($credentials: LoginCredentials!) {\n Login(credentials: $credentials) {\n Status\n __typename\n }\n}"} ``` The server response indicates that the database was successfully opened: ```http HTTP/1.1 200 OK Content-Type: application/json Set-Cookie: Token=eyJUeXBlIjoiU3FsaXRlMyIsIkhvc3RuYW1lIjoiIiwiVXNlcm5hbWUiOiIiLCJQYXNzd29yZCI6IiIsIkRhdGFiYXNlIjoiLi4vZXRjL3NlY3JldC5kYiJ9; Path=/; Expires=Thu, 23 Jan 2025 10:35:43 GMT; HttpOnly ... {"data":{"Login":{"Status":true,"__typename":"StatusResponse"}}} ``` The `Set-Cookie` `Token` value is simply a Base64-encoded string with a JSON payload containing the connection details: ```json { "Type": "Sqlite3", "Hostname": "", "Username": "", "Password": "", "Database": "../etc/secret.db" } ``` The attacker may set this cookie in the browser manually (alongside corresponding profiles in Local Storage) in order to open this database in the WhoDB application graphically. An easy way to perform this is by using a HTTP proxy such as Burp Suite, intercepting the login request and swapping the `Database` value to `../etc/secret.db`. Doing so, the attacker can then browse the database, its tables and the data within:  The attacker may also insert or modify data using either the buttons presented in the UI or the _Scratchpad_ functionality. In this proof-of-concept, the attacker inserts a new row using the _Add Row_ button:  ### Impact Allows an unauthenticated attacker to open and read any Sqlite3 databases present on the system WhoDB is running on. If WhoDB has write permissions for the database file, the attacker is also able to modify the opened database. The attacker is unable to create new databases; however, files which already exist but have no content (0-length files) may be opened and modified as fresh databases. ### Recommendations Before attempting to open the database, resolve and normalize the path to the database and check whether it is in the default directory. If not, present the user with an error.
WhoDB es una herramienta de administración de bases de datos de código abierto. Si bien la aplicación solo muestra las bases de datos Sqlite3 presentes en el directorio `/db`, no hay ninguna prevención de path traversa implementada. Esto permite que un atacante no autenticado abra cualquier base de datos Sqlite3 presente en la máquina host en la que se ejecuta la aplicación. Las versiones afectadas de WhoDB permiten a los usuarios conectarse a bases de datos Sqlite3. De manera predeterminada, las bases de datos deben estar presentes en `/db/` (o alternativamente `./tmp/` si el modo de desarrollo está habilitado). Si no hay bases de datos presentes en el directorio predeterminado, la interfaz de usuario indica que el usuario no puede abrir ninguna base de datos. El archivo de base de datos es un valor controlado por el usuario. Este valor se utiliza en `.Join()` con el directorio predeterminado, para obtener la ruta completa del archivo de base de datos que se abrirá. No se realizan comprobaciones de si el archivo de base de datos que finalmente se abre reside realmente en el directorio predeterminado `/db`. Esto permite que un atacante utilice el path traversa (`../../`) para abrir cualquier base de datos SQLite3 presente en el sistema. Este problema se ha solucionado en la versión 0.45.0 y se recomienda a todos los usuarios que actualicen la versión. No se conocen workarounds para esta vulnerabilidad.
| Version | Type | Source | Base | Exp | Impact | Vector |
|---|---|---|---|---|---|---|
| 3.1 | Primary | cve.org | 10.0 | — | — | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N |
| 3.1 | Primary | cve.org | 10.0 | — | — | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N |
| 3.1 | Primary | NVD | 9.1 | 3.9 | 5.2 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N |
| 3.1 | Secondary | NVD | 10.0 | 3.9 | 5.8 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N |
| 3.1 | Secondary | GHSA | 10.0 | — | — | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N |