Skip to content

Commit

Permalink
Update to Go 1.20.5
Browse files Browse the repository at this point in the history
This allows us to drop the mips64le upstream patch we've been applying (fixed in Go 1.20.0) and the GO-2023-1840 / CVE-2023-29403 govulncheck exclusion (which still doesn't apply, but was fixed in Go in 1.20.5 and thus we no longer need to ignore).

Also:
- update the tests to Debian Bookworm and Alpine 3.19
- update `SECURITY.md` to make our Go version update policy explicit and written down (including the parallel to how Linux distributions handle similar situations)
  • Loading branch information
tianon committed Mar 20, 2024
1 parent 64a0cd9 commit 9ea56fe
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
8 changes: 1 addition & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
FROM golang:1.18.2-bullseye
FROM golang:1.20.5-bookworm

RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
arch-test \
file \
patch \
; \
rm -rf /var/lib/apt/lists/*

# https://github.com/golang/go/issues/56426
RUN set -eux; \
wget -O /tmp/go-mips.patch 'https://github.com/golang/go/commit/2c7c98c3ad719aa9d6d2594827a6894ff9950042.patch'; \
patch --strip=1 --directory=/usr/local/go --input=/tmp/go-mips.patch

# note: we cannot add "-s" here because then "govulncheck" does not work (see SECURITY.md); the ~0.2MiB increase (as of 2022-12-16, Go 1.18) is worth it
ENV BUILD_FLAGS="-v -trimpath -ldflags '-d -w'"

Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.test-alpine
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM alpine:3.17
FROM alpine:3.19

# add "nobody" to ALL groups (makes testing edge cases more interesting)
RUN cut -d: -f1 /etc/group | xargs -n1 addgroup nobody
RUN cut -d: -f1 /etc/group | xargs -rtn1 addgroup nobody

RUN { \
echo '#!/bin/sh'; \
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile.test-debian
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM debian:bullseye-slim
FROM debian:bookworm-slim

# add "nobody" to ALL groups (makes testing edge cases more interesting)
RUN cut -d: -f1 /etc/group | xargs -n1 -I'{}' usermod -aG '{}' nobody
RUN cut -d: -f1 /etc/group | xargs -rtI'{}' usermod -aG '{}' nobody
# emulate Alpine's "games" user (which is part of the "users" group)
RUN usermod -aG users games

Expand Down
6 changes: 6 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ If you have a tool which is reporting that `gosu` is vulnerable to a particular

Our `govulncheck` wrapper script ([`govulncheck-with-excludes.sh`](govulncheck-with-excludes.sh)) may include a small set of vulnerabilities that will be reported by `govulncheck` which do not apply (due to other mitigations or otherwise). See comments in that script for details.

## Go Version Updates

Similar to the how traditional Linux distributions such as Debian handle rebuilding binaries between stable releases / for updated compilers (or rather, the situations and reasons for which they do *not* do so), and in the same spirit as the above CVE policy, we do *not* update the compiler/rebuild with a newer compiler unless there is a compelling functional or security reason in the code that ends up as part of the `gosu` binary that warrants doing so.

As above, if you have a "security scanning" tool which does not agree with this policy, please take that up with your scanning tool vendor (report as a false positive, improve the tool to `govulncheck`, etc).

# Reporting Vulnerabilities

The surface area of `gosu` itself is really limited -- it only directly contains a small amount of Go code to instrument an interface that is part of [`github.com/moby/sys/user` (the Docker Engine's `--user` parsing code, to be exact)](https://github.com/moby/sys/tree/main/user) (and which itself is a pretty limited interface) intended for providing the same behavior as Docker's `--user` flag (switching from `root` to a less privileged user), but from within an already running container.
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/tianon/gosu

go 1.18
go 1.20

require (
github.com/moby/sys/user v0.1.0
Expand Down
3 changes: 2 additions & 1 deletion govulncheck-with-excludes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ set -Eeuo pipefail

excludeVulns="$(jq -nc '[
# fixed in Go 1.20.5+
# https://pkg.go.dev/vuln/GO-2023-1840
# we already mitigate setuid in our code
"GO-2023-1840", "CVE-2023-29403",
#"GO-2023-1840", "CVE-2023-29403",
# (https://github.com/tianon/gosu/issues/128#issuecomment-1607803883)
empty # trailing comma hack (makes diffs smaller)
Expand Down

0 comments on commit 9ea56fe

Please sign in to comment.