CVE-2024-22261: Github.com/goharbor/harbor SQL Injection Vulnerability
LOWCVE-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
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).
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.
Upgrade github.com/goharbor/harbor to 2.8.6
Upgrade github.com/goharbor/harbor to 2.9.4
Upgrade github.com/goharbor/harbor to 2.10.2
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
CVE-2024-22261 Affected Github.com/goharbor/harbor Versions
3 component(s)| 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?
Which Github.com/goharbor/harbor versions are affected?
What version fixes CVE-2024-22261?
Is github.com/goharbor/harbor affected?
What is the CVSS score of CVE-2024-22261?
What CWE is associated with CVE-2024-22261?
How can I check Go dependencies for CVE-2024-22261?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}