Repository navigation
Closed
Labels
actionsbugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorspackagingpriority-3Affects a small number of users or is largely cosmetic
Description
Describe the bug
When running Trivy on a container that pulls the built GitHub CLI from the GitHub releases location, Trivy reports the following:
usr/bin/gh (gobinary)
Total: 1 (HIGH: 1, CRITICAL: 0)
┌───────────────────────┬────────────────┬──────────┬────────┬────────────────────────────────────┬───────────────┬────────────────────────────────────────────────────────────┐
│ Library │ Vulnerability │ Severity │ Status │ Installed Version │ Fixed Version │ Title │
├───────────────────────┼────────────────┼──────────┼────────┼────────────────────────────────────┼───────────────┼────────────────────────────────────────────────────────────┤
│ github.com/cli/cli/v2 │ CVE-2024-52308 │ HIGH │ fixed │ v2.0.0-20251113120743-680a8c4c4fe2 │ 2.62.0 │ The GitHub CLI version 2.6.1 and earlier are vulnerable to │
│ │ │ │ │ │ │ remote code... │
│ │ │ │ │ │ │ https://avd.aquasec.com/nvd/cve-2024-52308 │
└───────────────────────┴────────────────┴──────────┴────────┴────────────────────────────────────┴───────────────┴────────────────────────────────────────────────────────────┘
Affected version
# gh --version
gh version 2.83.1 (2025-11-13)
https://github.com/cli/cli/releases/tag/v2.83.1
Steps to reproduce the behavior
Use this sample Dockerfile:
# https://github.com/cli/cli/releases
ARG GH_VERSION=2.83.1
FROM alpine:3.23.0
RUN apk add --no-cache --update \
curl \
unzip
ARG GH_VERSION
RUN curl -fsSLO https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_amd64.tar.gz && \
tar -zxf gh_${GH_VERSION}_linux_amd64.tar.gz && \
chmod +x gh_${GH_VERSION}_linux_amd64/bin/gh && \
cp gh_${GH_VERSION}_linux_amd64/bin/gh /usr/bin
Run a build: docker build -t gh-cli:test -f Dockerfile.test .
Run Trivy: TRIVY_IGNORE_UNFIXED=true TRIVY_SEVERITY=CRITICAL,HIGH trivy image gh-cli:test
Expected vs actual behavior
I do not expect CVE-2024-52308 to be identified.
Logs
Note that it looks like the build of the binary has changed, and this is what results in the issue. Running strings on the binary is returning the version number in v2.83.0+ and not in previous versions:
/tmp # GH_VERSION=2.62.0 && curl -fsSLO https://github.com/cli/cli/releases/download/v${GH_VERSION}
/gh_${GH_VERSION}_linux_amd64.tar.gz && tar -zxf gh_${GH_VERSION}_linux_amd64.tar.gz
/tmp # GH_VERSION=2.83.1 && curl -fsSLO https://github.com/cli/cli/releases/download/v${GH_VERSION}
/gh_${GH_VERSION}_linux_amd64.tar.gz && tar -zxf gh_${GH_VERSION}_linux_amd64.tar.gz
/tmp # GH_VERSION=2.82.1 && curl -fsSLO https://github.com/cli/cli/releases/download/v${GH_VERSION}
/gh_${GH_VERSION}_linux_amd64.tar.gz && tar -zxf gh_${GH_VERSION}_linux_amd64.tar.gz
/tmp # GH_VERSION=2.83.0 && curl -fsSLO https://github.com/cli/cli/releases/download/v${GH_VERSION}
/gh_${GH_VERSION}_linux_amd64.tar.gz && tar -zxf gh_${GH_VERSION}_linux_amd64.tar.gz
/tmp # for i in gh_2.*/bin/gh ; do echo $i: ; strings $i | grep "^mod[[:space:]]*github.com/cli/cli
/v2" ; done
gh_2.62.0_linux_amd64/bin/gh:
mod github.com/cli/cli/v2 (devel)
mod github.com/cli/cli/v2 (devel)
gh_2.82.1_linux_amd64/bin/gh:
mod github.com/cli/cli/v2 (devel)
mod github.com/cli/cli/v2 (devel)
gh_2.83.0_linux_amd64/bin/gh:
mod github.com/cli/cli/v2 v2.0.0-20251104174640-152d328db80d
mod github.com/cli/cli/v2 v2.0.0-20251104174640-152d328db80d
gh_2.83.1_linux_amd64/bin/gh:
mod github.com/cli/cli/v2 v2.0.0-20251113120743-680a8c4c4fe2
mod github.com/cli/cli/v2 v2.0.0-20251113120743-680a8c4c4fe2 Reacted by Tsvetomir Tsonev
Metadata
Metadata
Assignees
Labels
actionsbugSomething isn't workingcoreThis issue is not accepting PRs from outside contributorspackagingpriority-3Affects a small number of users or is largely cosmetic
Activity
tsvetomir commentedon Dec 8, 2025
Same for CVE-2025-66564 and CVE-2025-61729 with GH CLI v2.83.1
BagToad commentedon Dec 8, 2025
Hey folks, big thanks for opening this issue ❤️ I've been discussing this with @babakks. This was on our radar when we upgraded to Go 1.25.3 in #11926 when we noticed that
govulncheckstarted failing for the same reasons, but at the time we didn't realize what this might mean to folks scanning the binary and not the source code. We wrote some notes in #11926 (comment), but here's the pertinent information:The TLDR is just that Go has changed something with how this version information is collected and stamped into the binary, and we don't fully understand why right now or what all our options are. That said, it does seem like we do have options, so we're seeing what we can do.
babakks commentedon Dec 16, 2025
@tsvetomir, those are not false positives caused by missing/wrong embedded version. Here's the state of the work:
github.com/sigstore/timestamp-authority: PR Bump sigstore-go to v1.1.4 #12289 is to fix this (the module is bumped tov2.0.3ingo.mod).stdlib: Already fixed in our latest release,v2.83.2which uses Go 1.25.5.babakks commentedon Dec 16, 2025
Thanks everyone for the discussion. I looked into this and I'm now sharing what I think.
Observations
As @BagToad mentioned, we noticed, while upgrading to Go v1.25, that
go buildis now embedding a best-guess kind of version into the binary. Inspecting the current latest release, it seems to bev2.0.0-20251210145848-560ea94fc7d6, which is not right and is basically a pseudo-version number generated by Go (like when you add untagged dependencies):Before this change,
ghbinaries were built with(devel)as the embedded version. For example, this is what we get forv2.78.0:Let's also see an even older version, like
v2.60.0:For now just note that the version is
(devel)and it's built with Go 1.22. I'll explain why we need this later.Cause of the change
When we first noticed the problem while bumping Go from 1.24 to 1.25, we looked into it (See #11926 (comment)) and we decided this might be a new behaviour in Go 1.25. Now that I've looked deeper, I'm surprised to see this behaviour was actually introduced in Go 1.24! And it didn't affect our binaries built with that version! 🤔 If you look at the above observations, you can see
v2.78.0is built with Go 1.24 and the embedded version is(devel). This is similar with even older builds, likev2.60.0that was built with Go 1.22. So, this remains an open question. 🤷Anyway, as of Go 1.24 release notes:
And expectedly this change has caused problems for others OSS projects. A quick search yields these samples:
v0.0.0-[date]-[id]+dirtyforgithub.com/grafana/grafanain SBOM after go upgrade grafana/grafana#106728v0.0.0-[date]-[id]+dirtysince version 1.8.x in SBOM grafana/alloy#3538Potential solutions
1. Use
-buildvcs=falseand keep embedding(devel)as versionThe simplest solution which will bring
ghbinaries back to how they were is to just add the-buildvcs=falseflag togo build, as suggested by Go 1.24 release notes. We have already confirmed this approach (See #11926 (comment)).However, this is not really the best fix. It has also been suggested in those other sample issues I linked above, and the community rightfully doesn't really like it as it eliminates accurate versioning, and hence, results in unusable version metadata. We haven't had any complaints in this regard in the past, so this can still be considered as a good enough fix for
gh.2. Embed the right version
If there's a git tag on the last commit from which we build the binary, then that tag will be used embedded as version. I tested it locally and it worked. Expand the below for more details.
Details
Here a small hello-world binary is built with and without a tag on the current commit. Also the git history has only one commit, to mimic our shallow checkout in workflows. Note the
modversion in both builds (a pseudo-version in no-tag build, and the correct version in the other).This seems to be simple, but it's actually a bit tricky to implement in the
ghrelease workflow. The reason is our workflow first buildsghbinaries for different OS via separate jobs, and then after some processing (e.g. signing, making MSI/PKG installers) and making sure everything is okay, we'll create and publish the git tag. We definitely don't want to create and publish the tag before the final step, otherwise, any failure during build or signing will leave the repo in a bogus state.@BagToad and I, have already discussed this in the past. One workaround would be to create a temporary tag per build jobs and never push the tag. Since our workflow does not mutate the state of the git repository, and git objects are always created in a deterministic way, these isolated tags will all be exactly the same.
That said, this is yet to be discussed by the team.
v2#12319babakks commentedon Dec 19, 2025
@BagToad and I discussed this, and we're both into the second solution which provides a better packaging experience. However, we decided to block this issue on #12319, to avoid conflicting changes in our release workflow. Once the other PR is merged, we'll start fixing this issue.
ci: tag per build job
BagToad commentedon Jan 6, 2026
We believe this is fixed in our CI deployment workflow now, but the next release for version v2.84.0 will be the first release with the embedded version information. We will do that release soon. Please let us know if v2.84.0 continues to experience the reported false positive behavior. Thank you!