CVE-2024-22261: Github.com/goharbor/harbor SQL Injection Vulnerability

LOW
Advisory Identifier: GHSA-vw63-824v-qf2j
CVSS 2.7
CWE-566
Published
Advisory Summary

CVE-2024-22261 is a LOW (CVSS 2.7) sql injection vulnerability (CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key) affecting Github.com/goharbor/harbor libraries in the Go ecosystem. The issue involves sql injection in harbor scan log api. Remediation is available by upgrading affected packages to version 2.8.6, 2.9.4, 2.10.2.

CVE-2024-22261 at a Glance

CVE Identifier CVE-2024-22261
GHSA Identifier GHSA-vw63-824v-qf2j
Severity LOW
CVSS v3.1 Base Score 2.7
CWE Classification CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key
Affected Product Github.com/goharbor/harbor
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 2.7

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

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

How to Fix CVE-2024-22261

To remediate this vulnerability, upgrade all affected Github.com/goharbor/harbor 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/goharbor/harbor fixed: 2.8.6
Upgrade github.com/goharbor/harbor to 2.8.6
github.com/goharbor/harbor fixed: 2.9.4
Upgrade github.com/goharbor/harbor to 2.9.4
github.com/goharbor/harbor fixed: 2.10.2
Upgrade github.com/goharbor/harbor to 2.10.2
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/goharbor/harbor

How to Check if You Are Affected

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

inspect dependencies for github.com/goharbor/harbor

Analyze the terminal output to locate any version of Github.com/goharbor/harbor in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.8.6), 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-566: Authorization Bypass Through User-Controlled SQL Primary Key, where the product uses a database table that includes records that should not be accessible to an actor, but it executes a sql statement with a primary key that can be controlled by that actor. In Github.com/goharbor/harbor, 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

### Impact A user with an administrator, project_admin, or project_maintainer role could utilize and exploit SQL Injection to allow the execution of any Postgres function or the extraction of sensitive information from the database through this API: ``` GET /api/v2.0/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log ``` The SQL injection might happen in the code: https://github.com/goharbor/harbor/blob/9b7c1a2274fbc5ea16e19a484532f86c08926577/src/pkg/task/task.go#L241 Because raw SQL executed in ormer.Raw(Sql).QueryRows() is PrepareStatement. In the driver of Postgres, one PrepareStatement must contain only ONE SQL command, see https://www.postgresql.org/docs/15/libpq-exec.html#LIBPQ-PQPREPARE. The SQL should start with: ``` SELECT * FROM task WHERE extra_attrs::jsonb->'report_uuids' @> ``` Adding a delete/update operation by appending malicious content to the current SQL is impossible. Furthermore, the query result of the task is just an intermediate result, the task ID is used to locate the job log file, and the response only contains the content of the job log file. so this vulnerability can be used to execute SQL functions, but it can't leak any useful information to the response. Harbor >=v2.8.1, >=2.9.0, >=2.10.0 are impacted. ### Patches Harbor v2.8.6, v2.9.4, v2.10.2 fixes this issue. ### Workarounds There is no workaround for this issue. ### Credits Thanks Taisei Inoue ([taisei.inoue@gmo-cybersecurity.com](mailto:taisei.inoue@gmo-cybersecurity.com))

CVE-2024-22261 Affected Github.com/goharbor/harbor Versions

3 component(s)
Fixed Versions:
2.8.62.9.42.10.2
Product / Package Ecosystem Affected Versions Fixed Version
github.com/goharbor/harbor
Go
< 2.8.6
2.8.6
github.com/goharbor/harbor
Go
≥ 2.9.0
< 2.9.4
2.9.4
github.com/goharbor/harbor
Go
≥ 2.10.0
< 2.10.2
2.10.2

References

Frequently Asked Questions

What is CVE-2024-22261?
CVE-2024-22261 is a security vulnerability in Github.com/goharbor/harbor involving SQL Injection in Harbor scan log API under CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key.
Which Github.com/goharbor/harbor versions are affected?
Affected versions include releases prior to 2.8.6, 2.9.4, 2.10.2 across affected packages: github.com/goharbor/harbor.
What version fixes CVE-2024-22261?
Upgrading to 2.8.6, 2.9.4, 2.10.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/goharbor/harbor affected?
Yes, github.com/goharbor/harbor is affected in releases prior to 2.8.6, 2.9.4, 2.10.2. Upgrade your dependency to 2.8.6, 2.9.4, 2.10.2 or later.
What is the CVSS score of CVE-2024-22261?
CVE-2024-22261 has a CVSS v3.1 base score of 2.7 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2024-22261?
CVE-2024-22261 is classified under CWE-566: Authorization Bypass Through User-Controlled SQL Primary Key (The product uses a database table that includes records that should not be accessible to an actor, but it executes a SQL statement with a primary key that can be controlled by that actor.).
How can I check Go dependencies for CVE-2024-22261?
Run the dependency tree command: 'inspect dependencies for github.com/goharbor/harbor'. 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-vw63-824v-qf2j",
  "modified" : "2024-06-17T15:14:41Z",
  "published" : "2024-06-02T22:32:40Z",
  "aliases" : [ "CVE-2024-22261" ],
  "summary" : "SQL Injection in Harbor scan log API",
  "details" : "### Impact\n\nA user with an administrator, project_admin, or project_maintainer role could utilize and exploit SQL Injection to allow the execution of any Postgres function or the extraction of sensitive information from the database through this API:\n```\nGET /api/v2.0/projects/{project_name}/repositories/{repository_name}/artifacts/{reference}/scan/{report_id}/log\n```\nThe SQL injection might happen in the code: \n\nhttps://github.com/goharbor/harbor/blob/9b7c1a2274fbc5ea16e19a484532f86c08926577/src/pkg/task/task.go#L241\n\nBecause raw SQL executed in ormer.Raw(Sql).QueryRows() is PrepareStatement. In the driver of Postgres, one PrepareStatement must contain only ONE SQL command, see https://www.postgresql.org/docs/15/libpq-exec.html#LIBPQ-PQPREPARE.  The SQL should start with:\n```\nSELECT * FROM task WHERE extra_attrs::jsonb->'report_uuids' @>\n```\nAdding a delete/update operation by appending malicious content to the current SQL is impossible. Furthermore, the query result of the task is just an intermediate result, the task ID is used to locate the job log file, and the response only contains the content of the job log file. so this vulnerability can be used to execute SQL functions, but it can't leak any useful information to the response.\n\nHarbor >=v2.8.1, >=2.9.0, >=2.10.0 are impacted.\n\n### Patches\nHarbor v2.8.6, v2.9.4, v2.10.2 fixes this issue.\n\n### Workarounds\nThere is no workaround for this issue.\n\n### Credits\n\nThanks Taisei Inoue ([taisei.inoue@gmo-cybersecurity.com](mailto:taisei.inoue@gmo-cybersecurity.com))",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/goharbor/harbor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.8.6"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/goharbor/harbor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.9.0"
      }, {
        "fixed" : "2.9.4"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/goharbor/harbor"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.10.0"
      }, {
        "fixed" : "2.10.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/goharbor/harbor/security/advisories/GHSA-vw63-824v-qf2j"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-22261"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/goharbor/harbor"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2024-2916"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-566" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-06-02T22:32:40Z",
    "nvd_published_at" : "2024-06-11T00:15:13Z"
  }
}