dbmate icon indicating copy to clipboard operation
dbmate copied to clipboard

ToolChain Specifies go1.24.3 but should go1.24.5

Open ConProgramming opened this issue 5 months ago • 8 comments

Description

Another issue already moved dependency to 1.24.5 but toolchain and thus image scanners still show 1.24.3.

ConProgramming avatar Aug 04 '25 14:08 ConProgramming

@ConProgramming Can you give an example of a scanner that shows 1.24.3?

My understanding, based on my interpretation of Go Toolchains, is that we are using 1.24.5 because the Dockerfile used to build v2.28.0 is based on the golang:1.24.5 image, and the Go toolchain uses the bundled toolchain in 1.24.5 or the go or toolchain lines if they're newer:

In the standard configuration, the go command uses its own bundled toolchain when that toolchain is at least as new as the go or toolchain lines in the main module or workspace. For example, when using the go command bundled with Go 1.21.3 in a main module that says go 1.21.0, the go command uses Go 1.21.3. When the go or toolchain line is newer than the bundled toolchain, the go command runs the newer toolchain instead. For example, when using the go command bundled with Go 1.21.3 in a main module that says go 1.21.9, the go command finds and runs Go 1.21.9 instead. It first looks in the PATH for a program named go1.21.9 and otherwise downloads and caches a copy of the Go 1.21.9 toolchain. This automatic toolchain switching can be disabled, but in that case, for more precise forwards compatibility, the go command will refuse to run in a main module or workspace in which the go line requires a newer version of Go. That is, the go line sets the minimum required Go version necessary to use a module or workspace.

If you have an image scanner that is scanning dbmate v2.28.0 and it's showing Go 1.24.3, I almost think that's a defect/bug in the image scanner.

To verify what version of the toolchain the current dbmate v2.28.0 image is using, I did:

$ docker run --rm -it --entrypoint /bin/sh amacneil/dbmate:2.28.0
# apk add go
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.22/community/x86_64/APKINDEX.tar.gz
(1/11) Installing jansson (2.14.1-r0)
(2/11) Installing binutils (2.44-r2)
(3/11) Installing libgomp (14.2.0-r6)
(4/11) Installing libatomic (14.2.0-r6)
(5/11) Installing gmp (6.3.0-r3)
(6/11) Installing isl26 (0.26-r1)
(7/11) Installing mpfr4 (4.2.1_p1-r0)
(8/11) Installing mpc1 (1.3.1-r1)
(9/11) Installing gcc (14.2.0-r6)
(10/11) Installing musl-dev (1.2.5-r10)
(11/11) Installing go (1.24.4-r0)
Executing busybox-1.37.0-r18.trigger
OK: 410 MiB in 42 packages
/ # go version -m /usr/local/bin/dbmate
/usr/local/bin/dbmate: go1.24.5
	path	github.com/amacneil/dbmate/v2
	mod	github.com/amacneil/dbmate/v2	(devel)
	dep	cloud.google.com/go	v0.121.4	h1:cVvUiY0sX0xwyxPwdSU2KsF9knOVmtRyAMt8xou0iTs=
	dep	cloud.google.com/go/auth	v0.16.3	h1:kabzoQ9/bobUmnseYnBO6qQG7q4a/CffFRlJSxv2wCc=
	dep	cloud.google.com/go/auth/oauth2adapt	v0.2.8	h1:keo8NaayQZ6wimpNSmW5OPc283g65QNIiLpZnkHRbnc=
	dep	cloud.google.com/go/bigquery	v1.69.0	h1:rZvHnjSUs5sHK3F9awiuFk2PeOaB8suqNuim21GbaTc=
	dep	cloud.google.com/go/compute/metadata	v0.7.0	h1:PBWF+iiAerVNe8UCHxdOt6eHLVc3ydFeOCw78U8ytSU=
	dep	cloud.google.com/go/iam	v1.5.2	h1:qgFRAGEmd8z6dJ/qyEchAuL9jpswyODjA2lS+w234g8=
	dep	filippo.io/edwards25519	v1.1.0	h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
	dep	github.com/ClickHouse/ch-go	v0.67.0	h1:18MQF6vZHj+4/hTRaK7JbS/TIzn4I55wC+QzO24uiqc=
	dep	github.com/ClickHouse/clickhouse-go/v2	v2.39.0	h1:spDlvQPW4d2EIOmzxeoRdeUPQ5j9zFryEx6L+XjfGoM=
	dep	github.com/andybalholm/brotli	v1.2.0	h1:ukwgCxwYrmACq68yiUqwIWnGY0cTPox/M94sVwToPjQ=
	dep	github.com/apache/arrow/go/v15	v15.0.2	h1:60IliRbiyTWCWjERBCkO1W4Qun9svcYoZrSLcyOsMLE=
	dep	github.com/cpuguy83/go-md2man/v2	v2.0.7	h1:zbFlGlXEAKlwXpmvle3d8Oe3YnkKIK4xSRTd3sHPnBo=
	dep	github.com/felixge/httpsnoop	v1.0.4	h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
	dep	github.com/go-faster/city	v1.0.1	h1:4WAxSZ3V2Ws4QRDrscLEDcibJY8uf41H6AhXDrNDcGw=
	dep	github.com/go-faster/errors	v0.7.1	h1:MkJTnDoEdi9pDabt1dpWf7AA8/BaSYZqibYyhZ20AYg=
	dep	github.com/go-logr/logr	v1.4.3	h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI=
	dep	github.com/go-logr/stdr	v1.2.2	h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
	dep	github.com/go-sql-driver/mysql	v1.9.3	h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
	dep	github.com/goccy/go-json	v0.10.5	h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
	dep	github.com/google/flatbuffers	v25.2.10+incompatible	h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q=
	dep	github.com/google/s2a-go	v0.1.9	h1:LGD7gtMgezd8a/Xak7mEWL0PjoTQFvpRudN895yqKW0=
	dep	github.com/google/uuid	v1.6.0	h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
	dep	github.com/googleapis/enterprise-certificate-proxy	v0.3.6	h1:GW/XbdyBFQ8Qe+YAmFU9uHLo7OnF5tL52HFAgMmyrf4=
	dep	github.com/googleapis/gax-go/v2	v2.15.0	h1:SyjDc1mGgZU5LncH8gimWo9lW1DtIfPibOG81vgd/bo=
	dep	github.com/jinzhu/inflection	v1.0.0	h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
	dep	github.com/jinzhu/now	v1.1.5	h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
	dep	github.com/joho/godotenv	v1.5.1	h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
	dep	github.com/klauspost/compress	v1.18.0	h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
	dep	github.com/klauspost/cpuid/v2	v2.3.0	h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
	dep	github.com/lib/pq	v1.10.9	h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
	dep	github.com/mattn/go-sqlite3	v1.14.28	h1:ThEiQrnbtumT+QMknw63Befp/ce/nUPgBPMlRFEum7A=
	dep	github.com/paulmach/orb	v0.11.1	h1:3koVegMC4X/WeiXYz9iswopaTwMem53NzTJuTF20JzU=
	dep	github.com/pierrec/lz4/v4	v4.1.22	h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
	dep	github.com/russross/blackfriday/v2	v2.1.0	h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
	dep	github.com/segmentio/asm	v1.2.0	h1:9BQrFxC+YOHJlTlHGkTrFWf59nbL3XnCoFLTwDCI7ys=
	dep	github.com/shopspring/decimal	v1.4.0	h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
	dep	github.com/sirupsen/logrus	v1.9.3	h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
	dep	github.com/urfave/cli/v2	v2.27.7	h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU=
	dep	github.com/xrash/smetrics	v0.0.0-20250705151800-55b8f293f342	h1:FnBeRrxr7OU4VvAzt5X7s6266i6cSVkkFPS0TuXWbIg=
	dep	github.com/zeebo/xxh3	v1.0.2	h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0=
	dep	go.opentelemetry.io/auto/sdk	v1.1.0	h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
	dep	go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc	v0.62.0	h1:rbRJ8BBoVMsQShESYZ0FkvcITu8X8QNwJogcLUmDNNw=
	dep	go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp	v0.62.0	h1:Hf9xI/XLML9ElpiHVDNwvqI0hIFlzV8dgIr35kV1kRU=
	dep	go.opentelemetry.io/otel	v1.37.0	h1:9zhNfelUvx0KBfu/gb+ZgeAfAgtWrfHJZcAqFC228wQ=
	dep	go.opentelemetry.io/otel/metric	v1.37.0	h1:mvwbQS5m0tbmqML4NqK+e3aDiO02vsf/WgbsdpcPoZE=
	dep	go.opentelemetry.io/otel/trace	v1.37.0	h1:HLdcFNbRQBE2imdSEgm/kwqmQj1Or1l/7bW6mxVK7z4=
	dep	golang.org/x/crypto	v0.40.0	h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM=
	dep	golang.org/x/exp	v0.0.0-20250718183923-645b1fa84792	h1:R9PFI6EUdfVKgwKjZef7QIwGcBKu86OEFpJ9nUEP2l4=
	dep	golang.org/x/net	v0.42.0	h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs=
	dep	golang.org/x/oauth2	v0.30.0	h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
	dep	golang.org/x/sync	v0.16.0	h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
	dep	golang.org/x/sys	v0.34.0	h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA=
	dep	golang.org/x/text	v0.27.0	h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4=
	dep	golang.org/x/time	v0.12.0	h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
	dep	golang.org/x/xerrors	v0.0.0-20240903120638-7835f813f4da	h1:noIWHXmPHxILtqtCOPIhSt0ABwskkZKjD3bXGnZGpNY=
	dep	google.golang.org/api	v0.243.0	h1:sw+ESIJ4BVnlJcWu9S+p2Z6Qq1PjG77T8IJ1xtp4jZQ=
	dep	google.golang.org/genproto	v0.0.0-20250721164621-a45f3dfb1074	h1:OC4JjCnGdf5dQ5lMsq3KOGmd0xFXTeeo4h8QFoiLQhA=
	dep	google.golang.org/genproto/googleapis/api	v0.0.0-20250721164621-a45f3dfb1074	h1:mVXdvnmR3S3BQOqHECm9NGMjYiRtEvDYcqAqedTXY6s=
	dep	google.golang.org/genproto/googleapis/rpc	v0.0.0-20250721164621-a45f3dfb1074	h1:qJW29YvkiJmXOYMu5Tf8lyrTp3dOS+K4z6IixtLaCf8=
	dep	google.golang.org/grpc	v1.74.2	h1:WoosgB65DlWVC9FqI82dGsZhWFNBSLjQ84bjROOpMu4=
	dep	google.golang.org/protobuf	v1.36.6	h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
	dep	gopkg.in/yaml.v3	v3.0.1	h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
	dep	gorm.io/driver/bigquery	v1.2.0	h1:E94oEXErYb4uImcR8oiCjE1SP2VdnrL5f3d78PtFWNk=
	dep	gorm.io/gorm	v1.30.0	h1:qbT5aPv1UH8gI99OsRlvDToLxW5zR7FzS9acZDOZcgs=
	build	-buildmode=exe
	build	-compiler=gc
	build	-ldflags="-s -extldflags \"-static\""
	build	-tags=netgo,osusergo,sqlite_omit_load_extension,sqlite_fts5,sqlite_json
	build	DefaultGODEBUG=gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=linux
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=7cae7094ff0ee40b48ebca00705957fd58d986fe
	build	vcs.time=2025-07-23T16:22:48Z
	build	vcs.modified=false

The first line of the go version -m /usr/local/bin/dbmate output reads:

/usr/local/bin/dbmate: go1.24.5

This indicates that the dbmate binary was built using go1.24.5, as expected.

dossy avatar Aug 04 '25 18:08 dossy

@dossy I have essentially zero understanding of Go in all honesty.

But, I can confirm Trivy is showing use of vulnerable version of stdlib v1.24.3. Since Trivy is very broadly used, I would assume the issue is not with Trivy. Maybe some weirdness of Go?

Thoughts? Any issues with bumping the toolchain version?

ConProgramming avatar Aug 04 '25 19:08 ConProgramming

I don't see any issue bumping the toolchain version in the go.mod file, but I'm not knowledgeable enough about Go and how dbmate is used as a package embedded within other Go programs to know what the consequences of doing so would be.

But, it does appear that Trivy incorrectly assumes that the version of the toolchain identified in go.mod is the version of the toolchain that built the Go executable, which is not guaranteed and can result in false-positives like you reported.

https://github.com/aquasecurity/trivy/issues/7111

We can leave this issue open until the toolchain in go.mod is bumped, but for anyone who arrives at this issue with the same concern: the officially released dbmate v2.28.0 was built with go1.24.5 and is not vulnerable to the issues identified in prior Go versions, and scanners like Trivy will falsely identify it as vulnerable if they do not properly examine the binary to identify the version of Go that was used to build it.

dossy avatar Aug 04 '25 22:08 dossy

We should really update it to 1.24.6 since there's another vulnerability in 1.24.4.

Image

Related to https://github.com/amacneil/dbmate/issues/669

o-lee avatar Aug 15 '25 18:08 o-lee

@dossy can we close this and merge https://github.com/amacneil/dbmate/pull/684 ?

ConProgramming avatar Nov 11 '25 04:11 ConProgramming

@dossy can we close this and merge #684 ?

@dossy and make a new version :)

ConProgramming avatar Nov 11 '25 04:11 ConProgramming

@ConProgramming A bunch of things are blocked by #679, and unless I'm mistaken, only @amacneil can unblock that by approving the PR so it can be merged, and I believe he's quite busy at the moment with Foxglove (big announcement finally landed yesterday!). I'm sure once he has time to breathe again, we'll get this unblocked and going again.

Trust me, I know how difficult it can be to wait for things, but I also can appreciate that this is a free project and we all have to prioritize differently.

Thanks for hanging in there with the rest of us. 😬

dossy avatar Nov 13 '25 16:11 dossy

@ConProgramming A bunch of things are blocked by #679, and unless I'm mistaken, only @amacneil can unblock that by approving the PR so it can be merged, and I believe he's quite busy at the moment with Foxglove (big announcement finally landed yesterday!). I'm sure once he has time to breathe again, we'll get this unblocked and going again.

Trust me, I know how difficult it can be to wait for things, but I also can appreciate that this is a free project and we all have to prioritize differently.

Thanks for hanging in there with the rest of us. 😬

@dossy 100% - thank you. We ended up just building from source :)

ConProgramming avatar Nov 13 '25 16:11 ConProgramming