121 Commits

Author SHA1 Message Date
Cory Snider
9ebbf652bd client: do not modify user-provided HTTP client
The http.Client passed into client.WithHTTPClient() is modified by the
constructor in-place: the value of its Transport field is mutated and
wrapped in an OpenTelemetry decorator. This can lead to very surprising
behaviour when a second client is constructed reusing the same
http.Client value. If the http.Client is configured for TLS, the second
client will fail to detect that and will incorrectly dial the Engine API
socket as cleartext HTTP. Copy the provided http.Client so our
modifications don't leak out to unexpected places.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2026-01-06 18:14:13 -05:00
Sebastiaan van Stijn
9ae239e654 golangci-lint: iface: ignore identical interfaces in client module
These interfaces in the client module are identical by design to allow
future expansion.

    client/container_export.go:15:6: identical: interface 'ContainerExportResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerLogsResult, ImageImportResult, ImageLoadResult, ImageSaveResult, ServiceLogsResult, TaskLogsResult) (iface)
    type ContainerExportResult interface {
         ^
    client/container_logs.go:26:6: identical: interface 'ContainerLogsResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerExportResult, ImageImportResult, ImageLoadResult, ImageSaveResult, ServiceLogsResult, TaskLogsResult) (iface)
    type ContainerLogsResult interface {
         ^
    client/image_import.go:12:6: identical: interface 'ImageImportResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerExportResult, ContainerLogsResult, ImageLoadResult, ImageSaveResult, ServiceLogsResult, TaskLogsResult) (iface)
    type ImageImportResult interface {
         ^
    client/image_load.go:12:6: identical: interface 'ImageLoadResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerExportResult, ContainerLogsResult, ImageImportResult, ImageSaveResult, ServiceLogsResult, TaskLogsResult) (iface)
    type ImageLoadResult interface {
         ^
    client/image_pull.go:17:6: identical: interface 'ImagePullResponse' contains identical methods or type constraints with another interface, causing redundancy (see: ImagePushResponse) (iface)
    type ImagePullResponse interface {
         ^
    client/image_push.go:20:6: identical: interface 'ImagePushResponse' contains identical methods or type constraints with another interface, causing redundancy (see: ImagePullResponse) (iface)
    type ImagePushResponse interface {
         ^
    client/image_save.go:9:6: identical: interface 'ImageSaveResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerExportResult, ContainerLogsResult, ImageImportResult, ImageLoadResult, ServiceLogsResult, TaskLogsResult) (iface)
    type ImageSaveResult interface {
         ^
    client/service_logs.go:28:6: identical: interface 'ServiceLogsResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerExportResult, ContainerLogsResult, ImageImportResult, ImageLoadResult, ImageSaveResult, TaskLogsResult) (iface)
    type ServiceLogsResult interface {
         ^
    client/task_logs.go:26:6: identical: interface 'TaskLogsResult' contains identical methods or type constraints with another interface, causing redundancy (see: ContainerExportResult, ContainerLogsResult, ImageImportResult, ImageLoadResult, ImageSaveResult, ServiceLogsResult) (iface)
    type TaskLogsResult interface {
         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-18 17:11:24 +01:00
Sebastiaan van Stijn
1f532963ed golangci-lint: remove unused exclusion rule
WARN [runner/exclusion_rules] Skipped 0 issues by rules: [Text: "type name will be used as (container|volume)\\.(Container|Volume).* by other packages, and that stutters; consider calling this", Path: "api/types/(volume|container)/", Linters: "revive"]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-16 16:55:33 +01:00
Sebastiaan van Stijn
9cd41375ce Dockerfile: update golangci-lint to v2.7.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-16 16:55:32 +01:00
Paweł Gronowski
37fdb6d775 ci: Remove concurrency setting from golangci-lint config
Remove the hardcoded concurrency limit of 2 from the golangci-lint
configuration to allow the linter to match the machine CPU's core count.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:55:32 +01:00
Paweł Gronowski
6f9d1ec3fb update to go1.25.5
These releases include 2 security fixes following the security policy:

- crypto/x509: excessive resource consumption in printing error string for host certificate validation

    Within HostnameError.Error(), when constructing an error string, there is no limit to the number of hosts that will be printed out.
    Furthermore, the error string is constructed by repeated string concatenation, leading to quadratic runtime.

    Therefore, a certificate provided by a malicious actor can result in excessive resource consumption.
    HostnameError.Error() now limits the number of hosts and utilizes strings.Builder when constructing an error string.

    Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

    This is CVE-2025-61729 and Go issue https://go.dev/issue/76445.

- crypto/x509: excluded subdomain constraint does not restrict wildcard SANs

    An excluded subdomain constraint in a certificate chain does not restrict the
    usage of wildcard SANs in the leaf certificate. For example a constraint that
    excludes the subdomain test.example.com does not prevent a leaf certificate from
    claiming the SAN *.example.com.

    This is CVE-2025-61727 and Go issue https://go.dev/issue/76442.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.25.5

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-02 20:30:08 +01:00
Paweł Gronowski
922cd97491 update to go1.25.4
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-06 14:15:23 +01:00
Paweł Gronowski
1aa73144f2 update to go1.25.3
This release addresses breakage caused by a security patch included in
Go 1.25.2 and 1.24.8, which enforced overly restrictive validation on
the parsing of X.509 certificates. We've removed those restrictions
while maintaining the security fix that the initial release addressed.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-14 09:11:27 +02:00
Sebastiaan van Stijn
28018a51d8 update to go1.25.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-11 20:14:22 +02:00
Paweł Gronowski
0aed907a86 update to go1.24.8
This minor release includes 10 security fixes following the security policy:

- net/mail: excessive CPU consumption in ParseAddress

    The ParseAddress function constructed domain-literal address components through repeated string concatenation. When parsing large domain-literal components, this could cause excessive CPU consumption.

    Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

    This is CVE-2025-61725 and Go issue https://go.dev/issue/75680.

- crypto/x509: quadratic complexity when checking name constraints

    Due to the design of the name constraint checking algorithm, the processing time
    of some inputs scales non-linearly with respect to the size of the certificate.

    This affects programs which validate arbitrary certificate chains.

    Thanks to Jakub Ciolek for reporting this issue.

    This is CVE-2025-58187 and Go issue https://go.dev/issue/75681.

- crypto/tls: ALPN negotiation errors can contain arbitrary text

    The crypto/tls conn.Handshake method returns an error on the server-side when
    ALPN negotation fails which can contain arbitrary attacker controlled
    information provided by the client-side of the connection which is not escaped.

    This affects programs which log these errors without any additional form of
    sanitization, and may allow injection of attacker controlled information into
    logs.

    Thanks to National Cyber Security Centre Finland for reporting this issue.

    This is CVE-2025-58189 and Go issue https://go.dev/issue/75652.

- encoding/pem: quadratic complexity when parsing some invalid inputs

    Due to the design of the PEM parsing function, the processing time for some
    inputs scales non-linearly with respect to the size of the input.

    This affects programs which parse untrusted PEM inputs.

    Thanks to Jakub Ciolek for reporting this issue.

    This is CVE-2025-61723 and Go issue https://go.dev/issue/75676.

- net/url: insufficient validation of bracketed IPv6 hostnames

    The Parse function permitted values other than IPv6 addresses to be included in square brackets within the host component of a URL. RFC 3986 permits IPv6 addresses to be included within the host component, enclosed within square brackets. For example: "http://[::1]/". IPv4 addresses and hostnames must not appear within square brackets. Parse did not enforce this requirement.

    Thanks to Enze Wang, Jingcheng Yang and Zehui Miao of Tsinghua University for reporting this issue.

    This is CVE-2025-47912 and Go issue https://go.dev/issue/75678.

- encoding/asn1: pre-allocating memory when parsing DER payload can cause memory exhaustion

    When parsing DER payloads, memories were being allocated prior to fully validating the payloads.
    This permits an attacker to craft a big empty DER payload to cause memory exhaustion in functions such as asn1.Unmarshal, x509.ParseCertificateRequest, and ocsp.ParseResponse.

    Thanks to Jakub Ciolek for reporting this issue.

    This is CVE-2025-58185 and Go issue https://go.dev/issue/75671.

- net/http: lack of limit when parsing cookies can cause memory exhaustion

    Despite HTTP headers having a default limit of 1 MB, the number of cookies that can be parsed did not have a limit.
    By sending a lot of very small cookies such as "a=;", an attacker can make an HTTP server allocate a large amount of structs, causing large memory consumption.

    net/http now limits the number of cookies accepted to 3000, which can be adjusted using the httpcookiemaxnum GODEBUG option.

    Thanks to jub0bs for reporting this issue.

    This is CVE-2025-58186 and Go issue https://go.dev/issue/75672.

- crypto/x509: panic when validating certificates with DSA public keys

    Validating certificate chains which contain DSA public keys can cause programs
    to panic, due to a interface cast that assumes they implement the Equal method.

    This affects programs which validate arbitrary certificate chains.

    Thanks to Jakub Ciolek for reporting this issue.

    This is CVE-2025-58188 and Go issue https://go.dev/issue/75675.

- archive/tar: unbounded allocation when parsing GNU sparse map

    tar.Reader did not set a maximum size on the number of sparse region data blocks in GNU tar pax 1.0 sparse files. A maliciously-crafted archive containing a large number of sparse regions could cause a Reader to read an unbounded amount of data from the archive into memory. When reading from a compressed source, a small compressed input could result in large allocations.

    Thanks to Harshit Gupta (Mr HAX) - https://www.linkedin.com/in/iam-harshit-gupta/ for reporting this issue.

    This is CVE-2025-58183 and Go issue https://go.dev/issue/75677.

- net/textproto: excessive CPU consumption in Reader.ReadResponse

    The Reader.ReadResponse function constructed a response string through
    repeated string concatenation of lines. When the number of lines in a response is large,
    this could cause excessive CPU consumption.

    Thanks to Jakub Ciolek for reporting this issue.

    This is CVE-2025-61724 and Go issue https://go.dev/issue/75716.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-07 15:49:36 -05:00
Sebastiaan van Stijn
fdd61821da use consistent alias for docker image spec
This package was aliased as "imagespec" in some places, and "dockerspec"
in other places, which made it easy to confuse.

Change all uses of this package to be aliased as "dockerspec" and configure
an "importas" linting check to enforce it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-06 14:24:41 +02:00
Paweł Gronowski
30406d42e3 update to go1.24.7
This includes 1 security fix:

- net/http: CrossOriginProtection bypass patterns are over-broad

    When passing patterns to CrossOriginProtection.AddInsecureBypassPattern,
    requests that would have redirected to those patterns (e.g. without a trailing
    slash) were also exempted, which might be unexpected.

    Thanks to Marco Gazerro for reporting this issue.

    This is CVE-2025-47910 and Go issue https://go.dev/issue/75054.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.24.7

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-09-03 20:31:17 +02:00
Rob Murray
4b97831992 Merge pull request #50671 from mmorel-35/github.com/hashicorp/go-multierror
chore: use errors.Join instead of github.com/hashicorp/go-multierror
2025-08-08 19:40:36 +01:00
Matthieu MOREL
050fbbccca chore: use errors.Join instead of github.com/hashicorp/go-multierror
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-08-08 19:19:21 +02:00
Matthieu MOREL
96f8c6395e chore: enable use-any rule from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-08-08 17:07:07 +02:00
Austin Vazquez
b25b421f97 update to go1.24.6
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-08-07 17:14:22 -05:00
Sebastiaan van Stijn
e30b8e3393 update golangci-lint settings
The github.com/docker/docker/reference package was moved to
github.com/moby/moby/v2/daemon/internal/refstore, so this
check no longer did anything (and no aliasing needed).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 17:32:31 +02:00
Paweł Gronowski
2dcd8b8def golangci: Replace old package name with moby/v2
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-08-04 16:35:44 +02:00
Derek McGowan
0abcdb7405 Update golangci for lazyregexp
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-24 12:21:11 -07:00
Sebastiaan van Stijn
b5d7d6c1e7 Merge pull request #50465 from thaJeztah/less_lazyregexp
remove uses of lazyregexp in tests, test-utilities and packages used externally
2025-07-21 22:49:30 +02:00
Sebastiaan van Stijn
f651a5d5e9 registry: remove uses of lazyregexp
This package is imported by the CLI; implement a more basic approach.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 21:24:46 +02:00
Sebastiaan van Stijn
b33b4bd290 internal/testutils/networking: rm uses of lazyregexp
It's not needed for test-utilities.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 21:24:13 +02:00
Sebastiaan van Stijn
a089c51160 pkg/idtools: remove deprecated functions and types
Remove;

- `MkdirAllAndChown`
- `MkdirAndChown`
- `MkdirAllAndChownNew`
- `GetRootUIDGID`
- `FromUserIdentityMapping`
- `ToUserIdentityMapping`
- `CurrentIdentity`
- `IdentityMapping`
- `Identity.Chown`
- `IDMap`

Also remove the temporary consts that were previously in use by BuildKit;

- `SeTakeOwnershipPrivilege`
- `ContainerAdministratorSidString`
- `ContainerUserSidString`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-20 23:06:16 +02:00
Paweł Gronowski
0a047e825c update to go1.24.5
- https://github.com/golang/go/issues?q=milestone%3AGo1.24.5+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.24.4...go1.24.5

This minor releases include 1 security fixes following the security policy:

- cmd/go: unexpected command execution in untrusted VCS repositories

    Various uses of the Go toolchain in untrusted VCS repositories can result in
    unexpected code execution. When using the Go toolchain in directories fetched
    using various VCS tools (such as directly cloning Git or Mercurial repositories)
    can cause the toolchain to execute unexpected commands, if said directory
    contains multiple VCS configuration metadata (such as a '.hg' directory in a Git
    repository). This is due to how the Go toolchain attempts to resolve which VCS
    is being used in order to embed build information in binaries and determine
    module versions.

    The toolchain will now abort attempting to resolve which VCS is being used if it
    detects multiple VCS configuration metadata in a module directory or nested VCS
    configuration metadata (such as a '.git' directoy in a parent directory and a
    '.hg' directory in a child directory). This will not prevent the toolchain from
    building modules, but will result in binaries omitting VCS related build
    information.

    If this behavior is expected by the user, the old behavior can be re-enabled by
    setting GODEBUG=allowmultiplevcs=1. This should only be done in trusted
    repositories.

    Thanks to RyotaK (https://ryotak.net) of GMO Flatt Security Inc for reporting
    this issue.

    This is CVE-2025-4674 and https://go.dev/issue/74380.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.24.5

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-07-08 19:21:37 +02:00
Sebastiaan van Stijn
0683bc6355 fix some inconsistency in import aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-01 21:48:26 +02:00
Sebastiaan van Stijn
650ab23785 Merge pull request #49920 from mmorel-35/fix-nakedret
pluginrpc-gen: align generator with generated
2025-06-30 12:18:27 +02:00
Matthieu MOREL
6b8afec95b fix redefines-builtin-id from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:45 +00:00
Matthieu MOREL
90ab64cbda fix increment-decrement from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Matthieu MOREL
381d9d0723 fix use-errors-new from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Matthieu MOREL
f0136d1dba fix superfluous-else from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Matthieu MOREL
369c8f828e fix var-declaration from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:24 +00:00
Matthieu MOREL
b40fe5cb8b pluginrpc-gen: align generator with generated
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-25 07:51:37 +02:00
Sebastiaan van Stijn
b7ef527bdc pkg/idtools: deprecate IdentityMapping, Identity.Chown
The IdentityMapping and Identity types are still used internally, but
should be considered transitional.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-16 17:38:40 +02:00
Matthieu MOREL
6d737371b8 fix comparison rule from errorlint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-13 08:26:56 +00:00
Matthieu MOREL
20b6075380 fix badCall from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-08 09:02:11 +02:00
Matthieu MOREL
c466ae0f71 fix badLock from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
19f5ac3c81 fix initClause from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
aa632664b6 fix mapKey from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
5ad4e4edf7 fix deprecatedComment from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
b8a4f6534f fix stringsCompare and stringConcatSimplify from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
a62de57aa1 fix sprintfQuotedString from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
bc9ec5fc02 fix emptyStringTest from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
469afa5f8f fix httpNoBody from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
8f7faa01d1 fix boolExprSimplify from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
e5be7b54b1 fix yodaStyleExpr from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
64075850fc fix go-critic linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Paweł Gronowski
1603ad636e update to go1.24.4
- https://github.com/golang/go/issues?q=milestone%3AGo1.24.4+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.24.3...go1.24.4

This release includes 3 security fixes following the security policy:

- net/http: sensitive headers not cleared on cross-origin redirect

    Proxy-Authorization and Proxy-Authenticate headers persisted on cross-origin redirects potentially leaking sensitive information.

    Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this issue.

    This is CVE-2025-4673 and Go issue https://go.dev/issue/73816.

- os: inconsistent handling of O_CREATE|O_EXCL on Unix and Windows

    os.OpenFile(path, os.O_CREATE|O_EXCL) behaved differently on Unix and Windows systems when the target path was a dangling symlink. On Unix systems, OpenFile with O_CREATE and O_EXCL flags never follows symlinks. On Windows, when the target path was a symlink to a nonexistent location, OpenFile would create a file in that location.

    OpenFile now always returns an error when the O_CREATE and O_EXCL flags are both set and the target path is a symlink.

    Thanks to Junyoung Park and Dong-uk Kim of KAIST Hacking Lab for discovering this issue.

    This is CVE-2025-0913 and Go issue https://go.dev/issue/73702.

- crypto/x509: usage of ExtKeyUsageAny disables policy validation

    Calling Verify with a VerifyOptions.KeyUsages that contains ExtKeyUsageAny unintentionally disabledpolicy validation. This only affected certificate chains which contain policy graphs, which are rather uncommon.

    Thanks to Krzysztof Skrzętnicki (@Tener) of Teleport for reporting this issue.

    This is CVE-2025-22874 and Go issue https://go.dev/issue/73612.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-06 19:35:32 +02:00
Matthieu MOREL
9b5d8cd186 fix thelper linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-05 21:42:05 +00:00
Matthieu MOREL
637e8142ce clean up golangci-lint config for deprectated errdefs.*
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:42:45 +00:00
Sebastiaan van Stijn
48733b0751 Merge pull request #47883 from dmcgowan/errdefs-check-containerd
Update errdefs package to use containerd/errdefs
2025-05-16 18:20:41 +02:00