Skip to content

[docker-ptf] re-add gnmic, built from openconfig/gnmic main#27340

Open
ronan-nexthop wants to merge 4 commits into
sonic-net:masterfrom
nexthop-ai:ronan.gnmic-from-source-pin
Open

[docker-ptf] re-add gnmic, built from openconfig/gnmic main#27340
ronan-nexthop wants to merge 4 commits into
sonic-net:masterfrom
nexthop-ai:ronan.gnmic-from-source-pin

Conversation

@ronan-nexthop
Copy link
Copy Markdown
Contributor

@ronan-nexthop ronan-nexthop commented May 13, 2026

Why I did it

Two related changes to docker-ptf/Dockerfile.j2:

1. Re-add gnmic, built from a pinned upstream main commit.
docker-ptf previously shipped gnmic (added in #25537, switched to from-source build with dep overrides shortly after). In #27059 it was removed because three CVEs in v0.45.0's dependency chain could not be patched cleanly via go get @latest overrides:

  • GHSA-x744-4wpc-v9h2 / GHSA-pxq6-2prw-chj9github.com/docker/docker needed a version that didn't exist as a Go module tag (Docker moved to moby/moby/v2, gnmic still imported the old path).
  • GHSA-vffh-x6r8-xx99github.com/prometheus/prometheus upgrade pulled in k8s.io/kube-openapi with a broken transitive dep, breaking go mod tidy.

Those fixes have all since landed on openconfig/gnmic main (grpc 1.79.3, otel-sdk 1.43.0, go-git 5.19.0, docker→moby/moby/v2 migration, prometheus v0.311.3). The pinned commit 653dc5dd4ddcd3bd4197317875a10c1ce8b06653 is the merge of openconfig/gnmic#872 into main and additionally closes CVE-2026-42151 (prometheus → v0.311.3). To unblock gNMI testing in docker-ptf before the next tagged gnmic release, re-add gnmic by building from that pinned main commit.

2. Bump Go toolchain to 1.25.10.
Go 1.25.10 is the 2026-05-07 stdlib security release (golang-announce qcCIEXso47M). It closes five DoS/crash CVEs present in 1.25.9, all of which currently end up in the from-source binaries this Dockerfile builds (grpcurl, gnoic, gnmic):

  • CVE-2026-33811net.LookupCNAME double-free (cgo resolver)
  • CVE-2026-33814 — net/http HTTP/2 SETTINGS_MAX_FRAME_SIZE=0 DoS (most relevant for gRPC tools)
  • CVE-2026-39820net/mail.ParseAddress/ParseDate DoS
  • CVE-2026-39836net.Dial/LookupPort panic on Windows with NUL byte
  • CVE-2026-42499net/mail.consumePhrase DoS

How I did it

dockers/docker-ptf/Dockerfile.j2:

  • New RUN block that clones openconfig/gnmic, checks out commit 653dc5dd, and runs go build -o /usr/local/bin/gnmic . — no go get @latest chains, no gocloud patch; trust upstream's vendored deps. Cleans up /tmp/gnmic, \$GOPATH/pkg/mod, and the Go build cache after the build to keep layer size in check. Placed right before "Remove Go toolchain to reduce image size" so the Go toolchain is still available.
  • Bumped GO_VERSION=1.25.9 → 1.25.10 and the matching armv6l/arm64/amd64 SHA256s (taken from https://go.dev/dl/?mode=json on 2026-05-14).

The gnmic pin is temporary — the intent is to swap back to a tagged release once openconfig/gnmic cuts one that contains the dep fixes from #864 and #872.

How to verify it

Build the docker-ptf image and confirm gnmic is on PATH and links against the patched toolchain and prometheus:

```
$ docker run -it --rm --entrypoint bash docker-ptf:latest
root@...:~# gnmic version
```

Expected: gnmic reports a version string referencing commit 653dc5dd (or whatever the pinned SHA is). The compiled binaries (grpcurl, gnoic, gnmic) embed Go 1.25.10 stdlib, and gnmic links against prometheus/prometheus v0.311.3.

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

  • 202305
  • 202311
  • 202405
  • 202411
  • 202505
  • 202511

Tested branch (Please provide the tested image version)

Description for the changelog

re-add gnmic to docker-ptf (built from openconfig/gnmic main, pinned); bump Go toolchain to 1.25.10

Link to config_db schema for YANG module changes

N/A

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented May 13, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: ronan-nexthop / name: Ronan Mac Fhlannchadha (ff98406)

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

PR sonic-net#27059 removed gnmic because three CVEs in v0.45.0's deps couldn't
be patched cleanly via `go get @latest` overrides. Those dependency
fixes have since landed on openconfig/gnmic main. Build from a pinned
main commit (71878d1936327b96883488d5f7a7584b1dda9bf1) so docker-ptf
has gnmic available again for gNMI testing while we wait for the next
tagged release.

Signed-off-by: Ronan Mac Fhlannchadha <ronan@nexthop.ai>
@ronan-nexthop ronan-nexthop force-pushed the ronan.gnmic-from-source-pin branch from aaa9aab to ff98406 Compare May 13, 2026 06:29
@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).

@ronan-nexthop
Copy link
Copy Markdown
Contributor Author

@hdwhdw

@ronan-nexthop ronan-nexthop marked this pull request as ready for review May 13, 2026 06:31
@ronan-nexthop ronan-nexthop requested a review from lguohan as a code owner May 13, 2026 06:31
@hdwhdw
Copy link
Copy Markdown
Contributor

hdwhdw commented May 13, 2026

LGTM. @qiluo-msft @auspham Anything we can do to validate this?

@auspham
Copy link
Copy Markdown
Contributor

auspham commented May 14, 2026

@hdwhdw lets see if the pipeline scan doesnt show any vulnerability for this

@auspham
Copy link
Copy Markdown
Contributor

auspham commented May 14, 2026

/azpw retry

@mssonicbld
Copy link
Copy Markdown
Collaborator

Retrying failed(or canceled) jobs...

@yijingyan2
Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@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).

@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).

Go 1.25.10 is the 2026-05-07 stdlib security release
(golang-announce qcCIEXso47M). It closes five DoS/crash CVEs
present in 1.25.9, all of which currently compile into the
docker-ptf grpcurl, gnoic and gnmic binaries:

- CVE-2026-33811  net.LookupCNAME double-free (cgo resolver)
- CVE-2026-33814  net/http HTTP/2 SETTINGS_MAX_FRAME_SIZE=0 DoS
                  (the most relevant for these gRPC binaries)
- CVE-2026-39820  net/mail.ParseAddress / ParseDate DoS
- CVE-2026-39836  net.Dial / LookupPort panic on Windows
- CVE-2026-42499  net/mail.consumePhrase DoS

x86_64 / arm64 / armv6l Go tarball SHA256s taken from
https://go.dev/dl/?mode=json on 2026-05-14.

Signed-off-by: Ronan Mac Fhlannchadha <ronan@nexthop.ai>
Closes CVE-2026-42151 / GHSA-wg65-39gg-5wfj (HIGH, CVSS 7.5):
Prometheus < v0.311.3 exposes Azure AD OAuth client secrets in
plaintext via the config API. Fixed only in v0.311.3.

Upstream gnmic main still pins prometheus v0.311.2 at SHA 71878d19.
Add a single 'go get github.com/prometheus/prometheus@v0.311.3'
override to the from-source build so the docker-ptf gnmic binary
picks up the fix without waiting on an upstream gnmic release.

Once the corresponding gnmic upstream PR (openconfig/gnmic#872)
merges and we move the pinned SHA forward, this override line
becomes redundant and can be removed.

Signed-off-by: Ronan Mac Fhlannchadha <ronan@nexthop.ai>
@ronan-nexthop ronan-nexthop force-pushed the ronan.gnmic-from-source-pin branch from 7499e03 to f2ea88c Compare May 14, 2026 07:35
@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).

@ronan-nexthop
Copy link
Copy Markdown
Contributor Author

new go version just go dropped with more CVE's, have raised another PR in gnmic repo to fix this. For this PR i'm upgrading us to go1.25.10 and manually upgrading prometheus one point version, this should have the tooling happy

@sneelam20 sneelam20 requested a review from hdwhdw May 14, 2026 16:12
@sneelam20
Copy link
Copy Markdown

@hdwhdw Can you take a look?

@ronan-nexthop
Copy link
Copy Markdown
Contributor Author

the vuln scanner is not tripping up on gnmic anymore, it is failing for other reasons

…s override

openconfig/gnmic PR sonic-net#872 (Go 1.25.10 + prometheus v0.311.3) merged
upstream at SHA 653dc5dd4ddcd3bd4197317875a10c1ce8b06653. Move the
pinned commit to that merge SHA and remove the local
'go get github.com/prometheus/prometheus@v0.311.3' override, which
is now redundant since v0.311.3 is in gnmic's own go.mod.

No change in the resulting binary's prometheus or Go stdlib version;
this just collapses the from-source build back to a single git
checkout + go build with no dependency overrides.

Signed-off-by: Ronan Mac Fhlannchadha <ronan@nexthop.ai>
@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).

@ronan-nexthop
Copy link
Copy Markdown
Contributor Author

upstream PR has merged, all scanned CVE's are now fixed. Have updated the build hash to point to gnmic master, will change to a release version once it's released

@hdwhdw
Copy link
Copy Markdown
Contributor

hdwhdw commented May 14, 2026

Thanks so much! @ronan-nexthop @qiluo-msft can you sign off?

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.

6 participants