Skip to content

fix: upgrade vulnerable Go dependencies to fix CRITICAL/HIGH CVEs - #743

Closed
qiluo-msft wants to merge 7 commits into
masterfrom
fix/cve-gnmi-clean-2026-08
Closed

fix: upgrade vulnerable Go dependencies to fix CRITICAL/HIGH CVEs#743
qiluo-msft wants to merge 7 commits into
masterfrom
fix/cve-gnmi-clean-2026-08

Conversation

@qiluo-msft

Copy link
Copy Markdown
Collaborator

Why I did it

Trivy CVE scan identified multiple CRITICAL and HIGH severity vulnerabilities in the Go module dependencies of sonic-gnmi.

How I did it

Updated go.mod, Makefile, and regenerated go.sum via go mod tidy with the following version bumps:

Package Old New CVEs Fixed
google.golang.org/grpc v1.69.2 v1.82.1 CVE-2026-33186, GHSA-hrxh-6v49-42gf
golang.org/x/crypto v0.36.0 v0.52.0 CVE-2024-45337, CVE-2025-22869, CVE-2025-47913, CVE-2026-39828–39832
golang.org/x/net v0.38.0 v0.55.0 CVE-2023-39325, CVE-2023-45288, CVE-2024-45338, CVE-2026-25681, CVE-2026-27136, CVE-2026-33814, CVE-2026-39821
golang.org/x/text v0.23.0 v0.39.0 CVE-2026-56852
github.com/antchfx/xpath v1.1.10 v1.3.6 CVE-2026-32287
github.com/antchfx/jsonquery v1.1.4 v1.3.7 (parent of vulnerable xpath)
github.com/antchfx/xmlquery v1.3.1 v1.5.1 (parent of vulnerable xpath)

Makefile change: Removed the obsolete x/crypto@v0.0.0-20191206172530 (Dec 2019) vendor override. This ancient version was incompatible with grpc v1.82.1 and is no longer needed — x/crypto v0.52.0 retains ssh/terminal and RevokedCertificates backward compatibility.

CodeQL fix needed (separate PR): grpc v1.82.1 and x/crypto v0.52.0 require go >= 1.25.0, but the CodeQL workflow uses the runner's default Go 1.24.x. A reviewer with workflow scope should add to .github/workflows/codeql-analysis.yml before the Initialize CodeQL step:

- name: Set up Go
  uses: actions/setup-go@v5
  with:
    go-version: '1.25'

How to verify it

trivy fs . --severity CRITICAL,HIGH  # should show 0 CRITICAL
make all                               # ensure build succeeds

- google.golang.org/grpc v1.69.2 -> v1.82.1 (CVE-2026-33186, GHSA-hrxh-6v49-42gf)
- golang.org/x/crypto v0.36.0 -> v0.52.0 (CVE-2024-45337, CVE-2025-22869, CVE-2026-39828-39832)
- golang.org/x/net v0.38.0 -> v0.55.0 (CVE-2023-39325, CVE-2024-45338, CVE-2026-25681, CVE-2026-33814)
- golang.org/x/text v0.23.0 -> v0.39.0 (CVE-2026-56852)
- antchfx/xpath v1.1.10 -> v1.3.6 (CVE-2026-32287)
- antchfx/jsonquery v1.1.4 -> v1.3.7 (parent of vulnerable xpath)
- antchfx/xmlquery v1.3.1 -> v1.5.1 (parent of vulnerable xpath)
Also update replace directives for grpc and crypto to match.
Update replace directives so they no longer downgrade dependencies:
- golang.org/x/sys v0.26.0 -> v0.45.0 (matches go mod tidy selection)
- google.golang.org/protobuf v1.34.1 -> v1.36.11 (matches require)
The Makefile previously downloaded x/crypto v0.0.0-20191206172530-e9b2fee46413
(Dec 2019) and replaced the vendored modern crypto before building gnmi CLI
tools, then restored the modern crypto afterward. This override is incompatible
with grpc v1.82.1 which uses crypto APIs added after 2019.

The override is no longer needed because:
- x/crypto v0.52.0 retains ssh/terminal (used by gnmi_cli)
- x/crypto v0.52.0 retains RevokedCertificates as a deprecated alias
  (used by the 0002-Fix-advance-tls-build-with-go-119.patch)

Use the already-vendored modern crypto for all builds.
grpc v1.82.1 and x/sys v0.45.0 require go >= 1.25.0 which breaks CodeQL
(uses Go 1.24.13). Use the highest versions that still fix CVE-2026-33186
while requiring only go 1.24.x:

- google.golang.org/grpc v1.82.1 -> v1.80.0 (go 1.24.0, fixes CVE-2026-33186)
- golang.org/x/crypto v0.52.0 -> v0.48.0 (go 1.24.0, fixes CVE-2024-45337+)
- golang.org/x/net v0.55.0 -> v0.49.0 (go 1.24.0)
- golang.org/x/text v0.39.0 -> v0.34.0 (go 1.24.0)
- golang.org/x/sys v0.45.0 -> v0.40.0 (go 1.24.0)
Update replace directives accordingly.
grpc v1.82.1 requires go >= 1.25.0. The CodeQL workflow needs to be updated
separately to add 'setup-go: 1.25' step (requires 'workflow' OAuth scope).
That change is tracked in the PR description.
Copilot AI lite review requested due to automatic review settings August 7, 2026 01:20
@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates sonic-gnmi’s Go module dependencies to remediate CRITICAL/HIGH CVEs flagged by Trivy, and adjusts the build vendoring/patch flow to remove an obsolete x/crypto override that conflicts with newer dependency versions.

Changes:

  • Upgraded several Go dependencies (notably gRPC and golang.org/x/*) in go.mod to newer versions intended to address reported CVEs.
  • Removed the Makefile logic that temporarily overrode vendored golang.org/x/crypto with a very old 2019 revision during gNMI client patching.
  • Updated related indirect dependencies pulled in by the upgraded modules.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
Makefile Removes the legacy x/crypto vendored-override workflow during client patching; updates build comments accordingly.
go.mod Bumps direct/indirect module versions (including gRPC and x/*) and adjusts replace pins to match the intended upgraded versions.

Comment thread go.mod
github.com/gogo/protobuf v1.3.2
github.com/golang/glog v1.2.4
github.com/golang/mock v1.6.0
github.com/golang/glog v1.2.5
Comment thread go.mod
github.com/golang/glog v1.2.4
github.com/golang/mock v1.6.0
github.com/golang/glog v1.2.5
github.com/golang/mock v1.7.0-rc.1
Comment thread Makefile
Comment on lines +124 to +125
# use the already-vendored crypto (no longer need the old 2019 override;
# x/crypto v0.24.0+ retains ssh/terminal and RevokedCertificates backward compat)
grpc v1.82.1 and x/crypto v0.52.0 require go >= 1.25.0.
Without this, CodeQL's 'go get' fallback fails with:
  google.golang.org/grpc@v1.82.1 requires go >= 1.25.0 (running go 1.24.13)
@mssonicbld

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@qiluo-msft

Copy link
Copy Markdown
Collaborator Author

Superseded by two focused PRs: #744 (go 1.24 compat, 12 CVEs) and a follow-up for go 1.25+ CVEs.

@qiluo-msft qiluo-msft closed this Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants