GHSA-4f8r-qqr9-fq8j

Suggest an improvement
Source
https://github.com/advisories/GHSA-4f8r-qqr9-fq8j
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/10/GHSA-4f8r-qqr9-fq8j/GHSA-4f8r-qqr9-fq8j.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-4f8r-qqr9-fq8j
Aliases
Related
Published
2024-10-01T18:13:25Z
Modified
2024-10-11T14:23:04Z
Severity
  • 7.5 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N CVSS Calculator
  • 8.7 (High) CVSS_V4 - CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/SC:N/SI:N/SA:N CVSS Calculator
Summary
Incorrect delegation lookups can make go-tuf download the wrong artifact
Details

During the ongoing work on the TUF conformance test suite, we have come across a test that reveals what we believe is a bug in go-tuf with security implications. The bug exists in go-tuf delegation tracing and could result in downloading the wrong artifact.

We have come across this issue in the test in this PR: https://github.com/theupdateframework/tuf-conformance/pull/115.

The test - test_graph_traversal - sets up a repository with a series of delegations, invokes the clients refresh() and then checks the order in which the client traced the delegations. The test shows that the go-tuf client inconsistently traces the delegations in a wrong way. For example, during one CI run, the two-level-delegations test case triggered a wrong order. The delegations in this look as such:

"two-level-delegations": DelegationsTestCase(
        delegations=[
            DelegationTester("targets", "A"),
            DelegationTester("targets", "B"),
            DelegationTester("B", "C"),
        ],
        visited_order=["A", "B", "C"],
    ),

Here, targets delegate to "A", and to "B", and "B" delegates to "C". The client should trace the delegations in the order "A" then "B" then "C" but in this particular CI run, go-tuf traced the delegations "B"->"C"->"A".

In a subsequent CI run, this test case did not fail, but another one did.

@jku has done a bit of debugging and believes that the returned map of GetRolesForTarget returns a map that causes this behavior:

https://github.com/theupdateframework/go-tuf/blob/f95222bdd22d2ac4e5b8ed6fe912b645e213c3b5/metadata/metadata.go#L565-L580

We believe that this map should be an ordered list instead of a map.

Database specific
{
    "nvd_published_at": "2024-10-01T16:15:09Z",
    "cwe_ids": [
        "CWE-362"
    ],
    "severity": "HIGH",
    "github_reviewed": true,
    "github_reviewed_at": "2024-10-01T18:13:25Z"
}
References

Affected packages

Go / github.com/theupdateframework/go-tuf/v2

Package

Name
github.com/theupdateframework/go-tuf/v2
View open source insights on deps.dev
Purl
pkg:golang/github.com/theupdateframework/go-tuf/v2

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
2.0.1