Skip to content

[docker-ptf]: Upgrade gnmic golang.org/x/* deps to fix security vulne… - #28038

Merged
qiluo-msft merged 1 commit into
sonic-net:masterfrom
auspham:austinpham/38538287-gnmic-security-upgrade
Jun 23, 2026
Merged

[docker-ptf]: Upgrade gnmic golang.org/x/* deps to fix security vulne…#28038
qiluo-msft merged 1 commit into
sonic-net:masterfrom
auspham:austinpham/38538287-gnmic-security-upgrade

Conversation

@auspham

@auspham auspham commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Why I did it

S360 / Trivy container scanning flags the docker-ptf image's gnmic binary
(/usr/local/bin/gnmic) with HIGH golang.org/x/* CVEs. The gnmic build was
changed (#27059) to build from a pinned upstream commit (653dc5dd), which
locks older modules — golang.org/x/crypto v0.50.0, x/net v0.53.0,
x/text v0.36.0, x/sys v0.43.0. Unlike the grpcurl build step in the same
Dockerfile, the gnmic step did not upgrade these, so the vulnerable
versions ship in the image.

Work item tracking
  • Microsoft ADO: 38538287

How I did it

In dockers/docker-ptf/Dockerfile.j2, added
go get golang.org/x/crypto@latest golang.org/x/net@latest golang.org/x/text@latest golang.org/x/sys@latest golang.org/x/oauth2@latest && go mod tidy
before go build in the gnmic RUN block, matching the existing grpcurl step.

How to verify it

Build target/docker-ptf.gz, load it, and scan:

trivy image docker-ptf:latest --scanners vuln --ignore-unfixed

usr/local/bin/gnmic should report 0 fixable vulns (x/* upgraded to latest).

Which release branch to backport (provide reason below if selected)

Tested branch (Please provide the tested image version)

  • docker-ptf built from this branch on latest master

Description for the changelog

[docker-ptf]: Upgrade gnmic golang.org/x/* dependencies to address HIGH CVEs

…rabilities

The gnmic build (pinned upstream commit 653dc5dd) locks older golang.org/x/*
modules (x/crypto v0.50.0, x/net v0.53.0, x/text v0.36.0, x/sys v0.43.0) that
Trivy/S360 flags as HIGH. Unlike the grpcurl build step, gnmic did not upgrade
these. Add 'go get golang.org/x/{crypto,net,text,sys,oauth2}@latest && go mod
tidy' before the build so gnmic picks up the patched x/* releases, matching the
grpcurl step.
Signed-off-by: Austin Pham <austinpham@microsoft.com>
Copilot AI review requested due to automatic review settings June 23, 2026 04:14
@auspham
auspham requested a review from lguohan as a code owner June 23, 2026 04:14
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@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

Updates the docker-ptf image build to ensure the gnmic binary is compiled with patched golang.org/x/* module versions, addressing security scanner findings for the pinned upstream gnmic commit.

Changes:

  • Extend the gnmic build step to go get the latest golang.org/x/{crypto,net,text,sys,oauth2} modules.
  • Run go mod tidy before building gnmic so the updated dependency set is captured for the build.

Comment on lines +421 to 425
# forced removal in #27059. The golang.org/x/* modules are additionally
# upgraded to latest to clear current/future golang.org/x/* CVEs (the
# pinned commit still locks older x/crypto, x/net, etc.). Temporary until
# the next tagged gnmic release ships.
RUN GNMIC_REV=653dc5dd4ddcd3bd4197317875a10c1ce8b06653 \
@qiluo-msft
qiluo-msft merged commit f0dd523 into sonic-net:master Jun 23, 2026
29 checks passed
roger-nexthop pushed a commit to nexthop-ai/sonic-buildimage that referenced this pull request Jul 12, 2026
…rabilities (sonic-net#28038)

Why I did it
S360 / Trivy container scanning flags the docker-ptf image's gnmic binary
(/usr/local/bin/gnmic) with HIGH golang.org/x/* CVEs. The gnmic build was
changed (sonic-net#27059) to build from a pinned upstream commit (653dc5dd), which
locks older modules — golang.org/x/crypto v0.50.0, x/net v0.53.0,
x/text v0.36.0, x/sys v0.43.0. Unlike the grpcurl build step in the same
Dockerfile, the gnmic step did not upgrade these, so the vulnerable
versions ship in the image.

Work item tracking
Microsoft ADO: 38538287
How I did it
In dockers/docker-ptf/Dockerfile.j2, added
go get golang.org/x/crypto@latest golang.org/x/net@latest golang.org/x/text@latest golang.org/x/sys@latest golang.org/x/oauth2@latest && go mod tidy
before go build in the gnmic RUN block, matching the existing grpcurl step.

How to verify it
Build target/docker-ptf.gz, load it, and scan:

trivy image docker-ptf:latest --scanners vuln --ignore-unfixed
usr/local/bin/gnmic should report 0 fixable vulns (x/* upgraded to latest).

Which release branch to backport (provide reason below if selected)
Tested branch (Please provide the tested image version)
docker-ptf built from this branch on latest master
Description for the changelog
[docker-ptf]: Upgrade gnmic golang.org/x/* dependencies to address HIGH CVEs
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.

5 participants