Skip to content

guarddog go scan and go verify leave uppercase version characters unescaped in GOPROXY URLs #930

Backlog

Description

@trackoor

GoModuleScanner case-encodes module paths (! + lowercase) when building proxy.golang.org URLs, but leaves uppercase characters in the module version unescaped in @v/{version}.zip and @v/{version}.info, causing guarddog go scan and guarddog go verify to fail on published Go releases with uppercase pre-release or build identifiers (such as github.com/nats-io/nats-server/v2 v2.15.3-RC.2).

guarddog --log-level debug go scan github.com/nats-io/nats-server/v2 --version v2.15.3-RC.2 --no-sandbox --output-format=json

Actual: GuardDog requests https://proxy.golang.org/github.com/nats-io/nats-server/v2/@v/v2.15.3-RC.2.zip (DEBUG: Downloading package archive from https://proxy.golang.org/github.com/nats-io/nats-server/v2/@v/v2.15.3-RC.2.zip), receives an HTTP 404 response body from proxy.golang.org instead of a zip archive, and reports a download-package error without scanning the module ({"package": "github.com/nats-io/nats-server/v2", "issues": 0, "errors": {"download-package": "unsupported or unreadable archive (not a valid tar or zip): ..."}}; running without --no-sandbox or via guarddog go verify on require github.com/nats-io/nats-server/v2 v2.15.3-RC.2 fails at the same download step).

Expected: GuardDog case-encodes the version segment per the Go module proxy protocol (.../v2/@v/v2.15.3-!r!c.2.zip and .../v2/@v/v2.15.3-!r!c.2.info, which both return HTTP 200 on proxy.golang.org) and scans the module, matching how --version v2.15.3 succeeds.

Tested on GuardDog v3 (5da9538eb05b8c2710db60541ec9732557687f8b); guarddog/scanners/go_package_scanner.py is identical in v3.2.0 (3da172679cb58b1c9a780f9f5d640f855be016dc).

In guarddog/scanners/go_package_scanner.py, GoModuleScanner.download_and_get_package_info calls escape_module_name(package_name) on lines 43 and 49 while interpolating {version} directly into @v/{version}.zip and @v/{version}.info, even though the Go proxy protocol comment at lines 60-65 notes that both $module and $version are case-encoded.

Credit: https://ucsbplse.github.io/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions