CVE-2024-47062: Github.com/navidrome/navidrome SQL Injection Vulnerability

CRITICAL
Advisory Identifier: GHSA-58vj-cv5w-v4v6
CVSS 8.8
CWE-89
Published
Advisory Summary

CVE-2024-47062 is a CRITICAL (CVSS 8.8) sql injection vulnerability (CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')) affecting Github.com/navidrome/navidrome libraries in the Go ecosystem. The issue involves navidrome has multiple sql injections and orm leak. Remediation is available by upgrading affected packages to version 0.53.0.

CVE-2024-47062 at a Glance

CVE Identifier CVE-2024-47062
GHSA Identifier GHSA-58vj-cv5w-v4v6
Severity CRITICAL
CVSS v3.1 Base Score 8.8
CWE Classification CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Affected Product Github.com/navidrome/navidrome
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 8.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-47062

To remediate this vulnerability, upgrade all affected Github.com/navidrome/navidrome dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/navidrome/navidrome fixed: 0.53.0
Upgrade github.com/navidrome/navidrome to 0.53.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/navidrome/navidrome

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-47062, inspect your project dependencies for Github.com/navidrome/navidrome:

inspect dependencies for github.com/navidrome/navidrome

Analyze the terminal output to locate any version of Github.com/navidrome/navidrome in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.53.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'), where the product constructs all or part of an sql command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended sql command when it is sent to a downstream component. without sufficient removal or quoting of sql syntax in user-controllable inputs, the generated sql query can cause those inputs to be interpreted as sql instead of ordinary user data. In Github.com/navidrome/navidrome, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

# Security Advisory: Multiple Vulnerabilities in Navidrome ## Summary Navidrome automatically adds parameters in the URL to SQL queries. This can be exploited to access information by adding parameters like `password=...` in the URL (ORM Leak). Furthermore, the names of the parameters are not properly escaped, leading to SQL Injections. Finally, the username is used in a `LIKE` statement, allowing people to log in with `%` instead of their username. ## Details ### ORM Leak When adding parameters to the URL, they are automatically included in an SQL `LIKE` statement (depending on the parameter's name). This allows attackers to potentially retrieve arbitrary information. For example, attackers can use the following request to test whether some encrypted passwords start with `AAA`: ``` GET /api/user?_end=36&_order=DESC&password=AAA% ``` This results in an SQL query like `password LIKE 'AAA%'`, allowing attackers to slowly brute-force passwords. (Also, any reason for using encryption instead of hashing?) ### SQL Injections When adding parameters to the URL, they are automatically added to an SQL query. The names of the parameters are not properly escaped. This behavior can be used to inject arbitrary SQL code (SQL Injection), for example: ``` GET /api/album?_end=36&_order=DESC&_sort=recently_added&_start=0&SELECT+*+FROM+USER--=123 HTTP/1.1 ``` This is only an example, but you should see an error message in the logs. ### Authentication Weakness When retrieving the user for authentication, the following code is used: ```go func (r *userRepository) FindByUsername(username string) (model.User, error) { sel := r.newSelect().Columns("").Where(Like{"user_name": username}) var usr model.User err := r.queryOne(sel, &usr) return &usr, err } ``` This relies on a `LIKE` statement and allows users to log in with `%` instead of the legitimate username. ## Proof of Concept (PoC) See above. ## Impact These vulnerabilities can be used to leak information and dump the contents of the database. ## Credit Louis Nyffenegger from PentesterLab

CVE-2024-47062 Affected Github.com/navidrome/navidrome Versions

1 component(s)
Fixed Versions:
0.53.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/navidrome/navidrome
Go
< 0.53.0
0.53.0

References

Frequently Asked Questions

What is CVE-2024-47062?
CVE-2024-47062 is a security vulnerability in Github.com/navidrome/navidrome involving Navidrome has Multiple SQL Injections and ORM Leak under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection').
Which Github.com/navidrome/navidrome versions are affected?
Affected versions include releases prior to 0.53.0 across affected packages: github.com/navidrome/navidrome.
What version fixes CVE-2024-47062?
Upgrading to 0.53.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/navidrome/navidrome affected?
Yes, github.com/navidrome/navidrome is affected in releases prior to 0.53.0. Upgrade your dependency to 0.53.0 or later.
What is the CVSS score of CVE-2024-47062?
CVE-2024-47062 has a CVSS v3.1 base score of 8.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2024-47062?
CVE-2024-47062 is classified under CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection') (The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.).
How can I check Go dependencies for CVE-2024-47062?
Run the dependency tree command: 'inspect dependencies for github.com/navidrome/navidrome'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-58vj-cv5w-v4v6",
  "modified" : "2024-09-20T22:07:50Z",
  "published" : "2024-09-20T14:51:56Z",
  "aliases" : [ "CVE-2024-47062" ],
  "summary" : "Navidrome has Multiple SQL Injections and ORM Leak",
  "details" : "# Security Advisory: Multiple Vulnerabilities in Navidrome\n\n## Summary\n\nNavidrome automatically adds parameters in the URL to SQL queries. This can be exploited to access information by adding parameters like `password=...` in the URL (ORM Leak).\n\nFurthermore, the names of the parameters are not properly escaped, leading to SQL Injections.\n\nFinally, the username is used in a `LIKE` statement, allowing people to log in with `%` instead of their username.\n\n## Details\n\n### ORM Leak\n\nWhen adding parameters to the URL, they are automatically included in an SQL `LIKE` statement (depending on the parameter's name). This allows attackers to potentially retrieve arbitrary information.\n\nFor example, attackers can use the following request to test whether some encrypted passwords start with `AAA`:\n\n```\nGET /api/user?_end=36&_order=DESC&password=AAA%\n```\n\nThis results in an SQL query like `password LIKE 'AAA%'`, allowing attackers to slowly brute-force passwords. (Also, any reason for using encryption instead of hashing?)\n\n### SQL Injections\n\nWhen adding parameters to the URL, they are automatically added to an SQL query. The names of the parameters are not properly escaped.\n\nThis behavior can be used to inject arbitrary SQL code (SQL Injection), for example:\n\n```\nGET /api/album?_end=36&_order=DESC&_sort=recently_added&_start=0&SELECT+*+FROM+USER--=123 HTTP/1.1\n```\n\nThis is only an example, but you should see an error message in the logs.\n\n### Authentication Weakness\n\nWhen retrieving the user for authentication, the following code is used:\n\n```go\nfunc (r *userRepository) FindByUsername(username string) (model.User, error) {\n    sel := r.newSelect().Columns(\"\").Where(Like{\"user_name\": username})\n    var usr model.User\n    err := r.queryOne(sel, &usr)\n    return &usr, err\n}\n```\n\nThis relies on a `LIKE` statement and allows users to log in with `%` instead of the legitimate username.\n\n## Proof of Concept (PoC)\n\nSee above.\n\n## Impact\n\nThese vulnerabilities can be used to leak information and dump the contents of the database.\n\n## Credit\n\nLouis Nyffenegger from PentesterLab",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:L"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/navidrome/navidrome"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.53.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/navidrome/navidrome/security/advisories/GHSA-58vj-cv5w-v4v6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-47062"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/navidrome/navidrome/commit/3107170afd9f557a10f7031f23cb3c9e975a71f9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/navidrome/navidrome"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-89" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-20T14:51:56Z",
    "nvd_published_at" : "2024-09-20T19:15:16Z"
  }
}