GHSA-vw63-824v-qf2j BIT-harbor-2024-22261 CVE-2024-22261 GO-2024-2916
SQL Injection in Harbor scan log API
- Severity
- 2.7 / 10
- Medium · CVSS 3.1
- Exploit chance (EPSS)
- 0.42%
- Chance of exploitation in the next 30 days. Higher than 36.04% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-566 Authorization Bypass Through User-Controlled SQL Primary Key
- Fix
2.8.6- Upgrade github.com/goharbor/harbor to this version or later
Description
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:
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)
Affected versions
Go
| Package | Vulnerable | Fixed in |
|---|---|---|
| github.com/goharbor/harbor | < 2.8.6 |
2.8.6 |
| github.com/goharbor/harbor | >= 2.9.0, < 2.9.4 |
2.9.4 |
| github.com/goharbor/harbor | >= 2.10.0, < 2.10.2 |
2.10.2 |
| github.com/goharbor/harbor | < 2.8.6+incompatible>= 2.9.0+incompatible, < 2.9.4+incompatible>= 2.10.0+incompatible, < 2.10.2+incompatible |
2.8.6+incompatible2.9.4+incompatible2.10.2+incompatible |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
github.com/goharbor/harbor Go → 2.8.6
- go
go get github.com/goharbor/harbor@v2.8.6 && go mod tidy
Severity breakdown
CVSS 3.1 2.7
CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:N/A:N
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- High
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- Low
- Integrity
- None
- Availability
- None
Weakness
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 to prevent it
- Implementation: Assume all input is malicious. Use a standard input validation mechanism to validate all input for length, type, syntax, and business rules before accepting the data. Use an "accept known good" validation strategy.
- Implementation: Use a parameterized query AND make sure that the accepted values conform to the business rules. Construct your SQL statement accordingly.
References
Advisories
Packages
Other links
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-prh4-vhfh-24mj Harbor: LDAP password and OIDC secret are not redacted in the audit log | Medium | Also affects github.com/goharbor/harbor |
| GHSA-hj7x-hmf2-hc2p Harbor allows the use of the default password for web UI login | Critical | Also affects github.com/goharbor/harbor |
| GHSA-h27m-3qw8-3pw8 Possible ORM Leak Vulnerability in the Harbor | Medium | Also affects github.com/goharbor/harbor |
| GHSA-f9vc-vf3r-pqqq Harbor repository description page has Cross-site Scripting vulnerability | Medium | Also affects github.com/goharbor/harbor |
| GHSA-r864-28pw-8682 Harbor fails to validate the user permissions when updating p2p preheat policies | High | Also affects github.com/goharbor/harbor |
| GHSA-hw28-333w-qxp3 Harbor fails to validate the user permissions when updating project configurations | Medium | Also affects github.com/goharbor/harbor |
| GHSA-5757-v49g-f6r7 Open Redirect URL in Harbor | Medium | Also affects github.com/goharbor/harbor |
| GHSA-mq6f-5xh5-hgcf Harbor timing attack risk | Medium | Also affects github.com/goharbor/harbor |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor