tianon / gosu

Simple Go-based setuid+setgid+setgroups+exec
Apache License 2.0
4.72k stars 321 forks source link

Build gosu with a supported version of GO #136

Open jhawkins1 opened 11 months ago

jhawkins1 commented 11 months ago

Go 1.18.x is deprecated and is not receiving functional or vulnerability fixes. Are there plans to update gosu to be built with a supported version of GO (1.20 and 1.21 are the current supported releases as of the date of this issue). If not, I would like to request via this issue that gosu change to build with a newer GO.

tianon commented 11 months ago

If there is a functional or security change in a newer release of Go that's actually relevant to gosu's tiny code paths, I'd be happy to update, but I haven't seen one yet. :sweat_smile:

(see also https://github.com/tianon/gosu/blob/master/SECURITY.md)

jhawkins1 commented 11 months ago

gosu is being pulled in by our usage of the standard Cassandra Image as part of our SaaS solution.

We have a requirement that End-of-Life Software cannot be used. We are getting flagged by gosu due to its usage of a deprecated (EOLed) version of GO. So, either we work with the gosu project to update; get Cassandra to do a custom build and not pull gosu directly from gosu releases, or we fork Cassandra Image build to do custom build ourselves. I was hoping we could work with you or convince you to do an update of gosu itself to avoid the complexities of the other paths. Others that use gosu in an environment where EOL software is forbidden are going to have this same issue :)

tianon commented 11 months ago

Well, gosu is definitely not EOL. :sweat_smile:

It's also kind of a huge stretch for any tooling to claim that you're "using" Go 1.18 just because your build of gosu happens to have been compiled against it, especially when compiling it against a newer version does absolutely nothing for any possible supported or unsupported usage of the tool -- effectively it just updates a string inside the binary from the text "1.18" to the text "1.21". :see_no_evil:

If I were in your position, I'd be pushing back on that tooling for making such strong and generally unsound/incorrect assumptions about what "EOL" means, especially in the context of the compiler version of pre-built published binaries (this applies to binaries from Debian or Ubuntu or Red Hat every bit as much as binaries downloaded from the releases pages of projects on GitHub). :innocent:

erickpeirson commented 10 months ago

@jhawkins1 We've encountered the same issues using the official Redis images. For a while we forked gosu and addressed these issues ourselves, but that recently hit the end of viability so we've simply removed gosu from the images entirely.

This may be useful (if less than satisfying) context: https://github.com/tianon/gosu/pull/131

petiepooo commented 10 months ago

If I were in your position, I'd be pushing back on that tooling for making such strong and generally unsound/incorrect assumptions about what "EOL" means...

Have you tried pushing back against government security bureaucracies? They're managed by people who can't spell EOL, but are convinced it's bad because it ends with L...

petiepooo commented 10 months ago

Take for example Redmine 5.1.1, the latest version released as of this posting. Going to the docker hub page for the app shows a total of 117 vulnerabilities, including 2 critical and 28 high, all of which are attributed to stdlib 1.18.2, which is pulled in as a dependency because someone wanted what gosu provides.

Is it easier to push back against the dozens of tool makers, research every one of those 30 listed as critical and high, plus 11 of the 16 medium, to definitively prove it isn't applicable (or take your word for it), patch gosu ourselves, possibly forking it and releasing as a more current alternative, and ask dependent projects to use my fork instead of yours, or ask that you please take the half-day it would take you to update your build environment and rebuild using a currently supported version of go?

I know you don't owe us freeloaders anything, but when a high majority of flagged issues can all be traced back to "I haven't seen a real vulnerability yet and I can't be bothered to update my build environment," then yes, this project gets classified as abandonware.

Hence this. If your goal to reduce the number of projects that depend on gosu, it's working quite well.

dev-nulled commented 8 months ago

Similar ask, for a Golang version update to 1.21. We are having to fork or remove gosu from the Redis packages because of the EOL versions of Golang and some of the dependencies it is bringing into images. Your code is lovely - the issue is Golang.

An update to the version gosu is building against would be a godsend.

AlexanderYastrebov commented 8 months ago

effectively it just updates a string inside the binary from the text

This is not true, go compiler and runtime updates incorporate a lot of performance improvements and bug fixes (not necessary vulnerabilities).

Official go policy only supports last two major versions https://go.dev/doc/devel/release#policy and encourages to update it periodically. Go1.18 is therefore not supported anymore. In practice this means that you can not open go issues for the application, the go team will ask to upgrade runtime and then come back if the issue persists.

AlexanderYastrebov commented 8 months ago

Another reason for upgrade is to simplify build process, e.g. https://github.com/golang/go/issues/56426 was fixed in go1.20 https://github.com/tianon/gosu/blob/b73cc93b6f5b5a045c397ff0f75190e33d853946/Dockerfile#L12-L15

dev-nulled commented 8 months ago

@tianon Thank you. The update is huge and much appreciated.

DrJJ commented 8 months ago

@tianon any idea when 1.18 with go 1.20.5 will be released?

The Infosec team from one of our large customers is freaking out about the official redis image being flagged critical by Google GKE Security Posture. The redis image is using gosu 1.17.

I understand that this Critical is a false positive, but try to explain that to a large Enterprise, that they do not have to worry about that docker image being flagged Critical by Google.

liozzazhang commented 8 months ago

it's not a big deal to rebuild Gosu with a higher Go version, right? Any warm discussion here implies Gosu is a really powerful and wildly-used tool. we'll all appreciate it if the team can upgrade the underlying Go version. @tianon or could you guide us on how to rebuild it by ourselves? Any comments will be appreciated.

xcke commented 6 months ago

Hi there, just run into the same issue yesterday. CRITICAL severity CVEs were flagged in the latest (1.17) version. I have checked out the repo and updated to Docker file to golang:1.21.4-bookworm. Compiled the binaries and used multistage docker build to copy out. If interested documented basic steps here.

AustinMutschler commented 5 months ago

I thought I would throw my hat in the ring for this as well. Can you please release the build with the new Go version so that packages like Redis and forks can use gosu without a critical CVE popping up? Thank you.

rgarcia89 commented 5 months ago

I would also love to see a new release. The latest version includes 51 fixable vulnerabilities of which 3 are critical. I have stumbled across this because gosu is part of the https://github.com/cloudnative-pg and the reason for majority of vulnerabilities that are detected in that image.

tianon commented 5 months ago

The latest version includes 51 fixable vulnerabilities of which 3 are critical.

The latest version is not vulnerable. Please read https://github.com/tianon/gosu/blob/master/SECURITY.md

One of the biggest things that bothers me here is that we (as an industry) aren't applying this same rigor to things compiled with GCC, for example. This is a case of "we have the metadata in the binary, so we're going to apply it incorrectly" and we don't apply similar logic to other ecosystems. Would the world/vulnerability problem be better if we stripped Go version information from these binaries to avoid this misdetection? I don't think it would! However, that would put these binaries on parity with the C binaries (setpriv, etc) that folks are switching to, even though builds of them are maintained in exactly the same way I'm maintaining builds of gosu -- that is to say, they're only rebuilt if a vulnerability in GCC or their libraries actually applies to them / would change the binary in some meaningful way.

The difference with Go is that we have rich metadata that tells us which version of Go the binary was built against that makes naive tools report that it's "vulnerable" -- even though we now have a canonical tool provided and maintained by Go upstream which parses and interprets that metadata correctly instead! (govulncheck) The maintainers of that tool have written it very much in part so that other tools can use and incorporate their work, and at this point, any security scanner which is reporting "vulnerabilities" in Go binaries but not incorporating the work of that team/tool is doing the entire industry an enormous disservice.

In other words, I'm being obstinate here because I think the current state of the "vulnerability scanning ecosystem" with regards to Go is in an absolutely embarrassing state and I actively want it to be better, but if all anyone ever does is blindly accept the status quo, it will not get better.

DrJJ commented 5 months ago

@tianon maybe maybe someone at redis and influxdb will notice this and take some action. and hopefully the infosec department at our biggest customer has some sense, otherwise we will need to start building our own images of redis and influxdb.

rgarcia89 commented 5 months ago

@tianon I completely understand your perspective regarding other languages. However, considering the rich metadata available in Go, I believe it is clear that we should utilize it.

Additionally, I am having difficulty understanding the following statement:

The latest version is not vulnerable. Please read https://github.com/tianon/gosu/blob/master/SECURITY.md

I recently downloaded v1.17 and scanned it using your provided govulncheck-with-excludes.sh. Here are the results:

$ sha256sum gosu-amd64
bbc4136d03ab138b1ad66fa4fc051bafc6cc7ffae632b069a53657279a450de3  gosu-amd64
$ ./govulncheck-with-excludes.sh -mode=binary gosu-amd64

- GO-2022-0493 (aka CVE-2022-29526, GHSA-p782-xgp4-8hr8)

    When called with a non-zero flags parameter, the Faccessat function can incorrectly report that a file is accessible.

- GO-2021-0067 (aka CVE-2021-27919)

    Using Reader.Open on an archive containing a file with a path prefixed by "../" will cause a panic due to a stack overflow. If parsing user supplied archives, this may be used as a denial of service vector.

- GO-2021-0069 (aka CVE-2020-28362)

    A number of math/big.Int methods can panic when provided large inputs due to a flawed division method.

- GO-2021-0142 (aka CVE-2020-16845, GHSA-q6gq-997w-f55g)

    ReadUvarint and ReadVarint can read an unlimited number of bytes from invalid inputs.

    Certain invalid inputs to ReadUvarint or ReadVarint can cause these functions to read an unlimited number of bytes from the ByteReader parameter before returning an error. This can lead to processing more input than expected when the caller is reading directly from a network and depends on ReadUvarint or ReadVarint only consuming a small, bounded number of bytes, even from invalid inputs.

- GO-2021-0154 (aka CVE-2014-7189)

    When SessionTicketsDisabled is enabled, crypto/tls allowed man-in-the-middle attackers to spoof clients via unspecified vectors.

    If the server enables TLS client authentication using certificates (this is rare) and explicitly sets SessionTicketsDisabled to true in the tls.Config, then a malicious client can falsely assert ownership of any client certificate it wishes.

- GO-2021-0159 (aka CVE-2015-5739, CVE-2015-5740, CVE-2015-5741)

    HTTP headers were not properly parsed, which allows remote attackers to conduct HTTP request smuggling attacks via a request that contains Content-Length and Transfer-Encoding header fields.

- GO-2021-0160 (aka CVE-2015-8618)

    Int.Exp Montgomery mishandled carry propagation and produced an incorrect output, which makes it easier for attackers to obtain private RSA keys via unspecified vectors.

    This issue can affect RSA computations in crypto/rsa, which is used by crypto/tls. TLS servers on 32-bit systems could plausibly leak their RSA private key due to this issue. Other protocol implementations that create many RSA signatures could also be impacted in the same way.

    Specifically, incorrect results in one part of the RSA Chinese Remainder computation can cause the result to be incorrect in such a way that it leaks one of the primes. While RSA blinding should prevent an attacker from crafting specific inputs that trigger the bug, on 32-bit systems the bug can be expected to occur at random around one in 2^26 times. Thus collecting around 64 million signatures (of known data) from an affected server should be enough to extract the private key used.

    Note that on 64-bit systems, the frequency of the bug is so low (less than one in 2^50) that it would be very difficult to exploit.

- GO-2021-0163 (aka CVE-2016-3958)

    Untrusted search path vulnerability on Windows related to LoadLibrary allows local users to gain privileges via a malicious DLL in the current working directory.

- GO-2021-0172 (aka CVE-2017-1000098)

    When parsing large multipart/form-data, an attacker can cause a HTTP server to open a large number of file descriptors. This may be used as a denial-of-service vector.

- GO-2021-0178 (aka CVE-2017-15042)

    SMTP clients using net/smtp can use the PLAIN authentication scheme on network connections not secured with TLS, exposing passwords to man-in-the-middle SMTP servers.

- GO-2021-0223 (aka CVE-2020-14039)

    On Windows, if VerifyOptions.Roots is nil, Certificate.Verify does not check the EKU requirements specified in VerifyOptions.KeyUsages. This may allow a certificate to be used for an unintended purpose.

- GO-2021-0224 (aka CVE-2020-15586)

    HTTP servers where the Handler concurrently reads the request body and writes a response can encounter a data race and crash. The httputil.ReverseProxy Handler is affected.

- GO-2021-0226 (aka CVE-2020-24553)

    When a Handler does not explicitly set the Content-Type header, the the package would default to β€œtext/html”, which could cause a Cross-Site Scripting vulnerability if an attacker can control any part of the contents of a response.

    The Content-Type header is now set based on the contents of the first Write using http.DetectContentType, which is consistent with the behavior of the net/http package.

    Although this protects some applications that validate the contents of uploaded files, not setting the Content-Type header explicitly on any attacker-controlled file is unsafe and should be avoided.

- GO-2021-0234 (aka CVE-2021-27918)

    The Decode, DecodeElement, and Skip methods of an xml.Decoder provided by xml.NewTokenDecoder may enter an infinite loop when operating on a custom xml.TokenReader which returns an EOF in the middle of an open XML element.

- GO-2021-0235 (aka CVE-2021-3114)

    The P224() Curve implementation can in rare circumstances generate incorrect outputs, including returning invalid points from ScalarMult.

- GO-2021-0239 (aka CVE-2021-33195)

    The LookupCNAME, LookupSRV, LookupMX, LookupNS, and LookupAddr functions and their respective methods on the Resolver type may return arbitrary values retrieved from DNS which do not follow the established RFC 1035 rules for domain names. If these names are used without further sanitization, for instance unsafely included in HTML, they may allow for injection of unexpected content. Note that LookupTXT may still return arbitrary values that could require sanitization before further use.

- GO-2021-0240 (aka CVE-2021-33196)

    NewReader and OpenReader can cause a panic or an unrecoverable fatal error when reading an archive that claims to contain a large number of files, regardless of its actual size.

- GO-2021-0241 (aka CVE-2021-33197)

    ReverseProxy can be made to forward certain hop-by-hop headers, including Connection. If the target of the ReverseProxy is itself a reverse proxy, this lets an attacker drop arbitrary headers, including those set by the ReverseProxy.Director.

- GO-2021-0242 (aka CVE-2021-33198)

    Rat.SetString and Rat.UnmarshalText may cause a panic or an unrecoverable fatal error if passed inputs with very large exponents.

- GO-2021-0243 (aka CVE-2021-34558)

    crypto/tls clients can panic when provided a certificate of the wrong type for the negotiated parameters. net/http clients performing HTTPS requests are also affected.

- GO-2021-0245 (aka CVE-2021-36221)

    ReverseProxy can panic after encountering a problem copying a proxied response body.

- GO-2021-0263 (aka CVE-2021-41771)

    Calling File.ImportedSymbols on a loaded file which contains an invalid dynamic symbol table command can cause a panic, in particular if the encoded number of undefined symbols is larger than the number of symbols in the symbol table.

- GO-2021-0264 (aka CVE-2021-41772)

    Previously, opening a zip with (*Reader).Open could result in a panic if the zip contained a file whose name was exclusively made up of slash characters or ".." path elements.

    Open could also panic if passed the empty string directly as an argument.

    Now, any files in the zip whose name could not be made valid for fs.FS.Open will be skipped, and no longer added to the fs.FS file list, although they are still accessible through (*Reader).File.

    Note that it was already the case that a file could be accessible from (*Reader).Open with a name different from the one in (*Reader).File, as the former is the cleaned name, while the latter is the original one.

    Finally, the actual panic site was made robust as a defense-in-depth measure.

- GO-2021-0317 (aka CVE-2022-23772)

    Rat.SetString had an overflow issue that can lead to uncontrolled memory consumption.

- GO-2021-0319 (aka CVE-2022-23806)

    Some big.Int values that are not valid field elements (negative or overflowing) might cause Curve.IsOnCurve to incorrectly return true. Operating on those values may cause a panic or an invalid curve operation. Note that Unmarshal will never return such values.

- GO-2021-0347 (aka CVE-2022-24921)

    On 64-bit platforms, an extremely deeply nested expression can cause regexp.Compile to cause goroutine stack exhaustion, forcing the program to exit. Note this applies to very large expressions, on the order of 2MB.

- GO-2022-0166 (aka CVE-2016-3959)

    The Verify function in crypto/dsa passed certain parameters unchecked to the underlying big integer library, possibly leading to extremely long-running computations, which in turn makes Go programs vulnerable to remote denial of service attacks. Programs using HTTPS client certificates or the Go SSH server libraries are both exposed to this vulnerability.

- GO-2022-0171 (aka CVE-2017-1000097)

    On Darwin, user's trust preferences for root certificates were not honored. If the user had a root certificate loaded in their Keychain that was explicitly not trusted, a Go program would still verify a connection using that root certificate.

- GO-2022-0187 (aka CVE-2017-8932)

    The ScalarMult implementation of curve P-256 for amd64 architectures generates incorrect results for certain specific input points. An adaptive attack can progressively extract the scalar input to ScalarMult by submitting crafted points and observing failures to derive correct output. This leads to a full key recovery attack against static ECDH, as used in popular JWT libraries.

- GO-2022-0191 (aka CVE-2018-16875)

    The crypto/x509 package does not limit the amount of work performed for each chain verification, which might allow attackers to craft pathological inputs leading to a CPU denial of service. Go TLS servers accepting client certificates and TLS clients verifying certificates are affected.

- GO-2022-0211 (aka CVE-2019-14809)

    The url.Parse function accepts URLs with malformed hosts, such that the Host field can have arbitrary suffixes that appear in neither Hostname() nor Port(), allowing authorization bypasses in certain applications.

- GO-2022-0212 (aka CVE-2019-16276)

    net/http (through net/textproto) used to accept and normalize invalid HTTP/1.1 headers with a space before the colon, in violation of RFC 7230.

    If a Go server is used behind an uncommon reverse proxy that accepts and forwards but doesn't normalize such invalid headers, the reverse proxy and the server can interpret the headers differently. This can lead to filter bypasses or request smuggling, the latter if requests from separate clients are multiplexed onto the same upstream connection by the proxy. Such invalid headers are now rejected by Go servers, and passed without normalization to Go client applications.

- GO-2022-0213 (aka CVE-2019-17596)

    Invalid DSA public keys can cause a panic in dsa.Verify. In particular, using crypto/x509.Verify on a crafted X.509 certificate chain can lead to a panic, even if the certificates don't chain to a trusted root. The chain can be delivered via a crypto/tls connection to a client, or to a server that accepts and verifies client certificates. net/http clients can be made to crash by an HTTPS server, while net/http servers that accept client certificates will recover the panic and are unaffected.

    Moreover, an application might crash invoking crypto/x509.(*CertificateRequest).CheckSignature on an X.509 certificate request, parsing a golang.org/x/crypto/openpgp Entity, or during a golang.org/x/crypto/otr conversation. Finally, a golang.org/x/crypto/ssh client can panic due to a malformed host key, while a server could panic if either PublicKeyCallback accepts a malformed public key, or if IsUserAuthority accepts a certificate with a malformed public key.

- GO-2022-0217 (aka CVE-2019-6486)

    A DoS vulnerability in the crypto/elliptic implementations of the P-521 and P-384 elliptic curves may let an attacker craft inputs that consume excessive amounts of CPU.

    These inputs might be delivered via TLS handshakes, X.509 certificates, JWT tokens, ECDH shares or ECDSA signatures. In some cases, if an ECDH private key is reused more than once, the attack can also lead to key recovery.

- GO-2022-0220 (aka CVE-2019-9634)

    Go on Windows misused certain LoadLibrary functionality, leading to DLL injection.

- GO-2022-0229 (aka CVE-2020-7919, GHSA-cjjc-xp8v-855w)

    On 32-bit architectures, a malformed input to crypto/x509 or the ASN.1 parsing functions of golang.org/x/crypto/cryptobyte can lead to a panic.

    The malformed certificate can be delivered via a crypto/tls connection to a client, or to a server that accepts client certificates. net/http clients can be made to crash by an HTTPS server, while net/http servers that accept client certificates will recover the panic and are unaffected.

- GO-2022-0236 (aka CVE-2021-31525, GHSA-h86h-8ppg-mxmh)

    A malicious HTTP server or client can cause the net/http client or server to panic.

    ReadRequest and ReadResponse can hit an unrecoverable panic when reading a very large header (over 7MB on 64-bit architectures, or over 4MB on 32-bit ones). Transport and Client are vulnerable and the program can be made to crash by a malicious server. Server is not vulnerable by default, but can be if the default max header of 1MB is overridden by setting Server.MaxHeaderBytes to a higher value, in which case the program can be made to crash by a malicious client.

    This also affects golang.org/x/net/http2/h2c and HeaderValuesContainsToken in golang.org/x/net/http/httpguts.

- GO-2022-0273 (aka CVE-2021-39293)

    The NewReader and OpenReader functions in archive/zip can cause a panic or an unrecoverable fatal error when reading an archive that claims to contain a large number of files, regardless of its actual size. This is caused by an incomplete fix for CVE-2021-33196.

- GO-2022-0288 (aka CVE-2021-44716, GHSA-vc3p-29h2-gpcp)

    An attacker can cause unbounded memory growth in servers accepting HTTP/2 requests.

- GO-2022-0289 (aka CVE-2021-44717)

    When a Go program running on a Unix system is out of file descriptors and calls syscall.ForkExec (including indirectly by using the os/exec package), syscall.ForkExec can close file descriptor 0 as it fails. If this happens (or can be provoked) repeatedly, it can result in misdirected I/O such as writing network traffic intended for one connection to a different connection, or content intended for one file to a different one.

    For users who cannot immediately update to the new release, the bug can be mitigated by raising the per-process file descriptor limit.

- GO-2022-0433 (aka CVE-2022-24675)

    encoding/pem in Go before 1.17.9 and 1.18.x before 1.18.1 has a Decode stack overflow via a large amount of PEM data.

- GO-2022-0434 (aka CVE-2022-27536)

    Verifying certificate chains containing certificates which are not compliant with RFC 5280 causes Certificate.Verify to panic on macOS.

    These chains can be delivered through TLS and can cause a crypto/tls or net/http client to crash.

- GO-2022-0435 (aka CVE-2022-28327)

    A crafted scalar input longer than 32 bytes can cause P256().ScalarMult or P256().ScalarBaseMult to panic. Indirect uses through crypto/ecdsa and crypto/tls are unaffected. amd64, arm64, ppc64le, and s390x are unaffected.

- GO-2022-0477 (aka CVE-2022-30634)

    On Windows, rand.Read will hang indefinitely if passed a buffer larger than 1 << 32 - 1 bytes.

- GO-2022-0493 (aka CVE-2022-29526, GHSA-p782-xgp4-8hr8)

    When called with a non-zero flags parameter, the Faccessat function can incorrectly report that a file is accessible.

- GO-2022-0515 (aka CVE-2022-1962)

    Calling any of the Parse functions on Go source code which contains deeply nested types or declarations can cause a panic due to stack exhaustion.

- GO-2022-0520 (aka CVE-2022-32148)

    Client IP adresses may be unintentionally exposed via X-Forwarded-For headers.

    When httputil.ReverseProxy.ServeHTTP is called with a Request.Header map containing a nil value for the X-Forwarded-For header, ReverseProxy sets the client IP as the value of the X-Forwarded-For header, contrary to its documentation.

    In the more usual case where a Director function sets the X-Forwarded-For header value to nil, ReverseProxy leaves the header unmodified as expected.

- GO-2022-0521 (aka CVE-2022-28131)

    Calling Decoder.Skip when parsing a deeply nested XML document can cause a panic due to stack exhaustion.

- GO-2022-0522 (aka CVE-2022-30632)

    Calling Glob on a path which contains a large number of path separators can cause a panic due to stack exhaustion.

- GO-2022-0523 (aka CVE-2022-30633)

    Unmarshaling an XML document into a Go struct which has a nested field that uses the 'any' field tag can panic due to stack exhaustion.

- GO-2022-0524 (aka CVE-2022-30631)

    Calling Reader.Read on an archive containing a large number of concatenated 0-length compressed files can cause a panic due to stack exhaustion.

- GO-2022-0525 (aka CVE-2022-1705)

    The HTTP/1 client accepted some invalid Transfer-Encoding headers as indicating a "chunked" encoding. This could potentially allow for request smuggling, but only if combined with an intermediate server that also improperly failed to reject the header as invalid.

- GO-2022-0526 (aka CVE-2022-30635)

    Calling Decoder.Decode on a message which contains deeply nested structures can cause a panic due to stack exhaustion.

- GO-2022-0527 (aka CVE-2022-30630)

    Calling Glob on a path which contains a large number of path separators can cause a panic due to stack exhaustion.

- GO-2022-0531 (aka CVE-2022-30629)

    An attacker can correlate a resumed TLS session with a previous connection.

    Session tickets generated by crypto/tls do not contain a randomly generated ticket_age_add, which allows an attacker that can observe TLS handshakes to correlate successive connections by comparing ticket ages during session resumption.

- GO-2022-0532 (aka CVE-2022-30580)

    On Windows, executing Cmd.Run, Cmd.Start, Cmd.Output, or Cmd.CombinedOutput when Cmd.Path is unset will unintentionally trigger execution of any binaries in the working directory named either "..com" or "..exe".

- GO-2022-0533 (aka CVE-2022-29804)

    On Windows, the filepath.Clean function can convert certain invalid paths to valid, absolute paths, potentially allowing a directory traversal attack.

    For example, Clean(".\c:") returns "c:".

- GO-2022-0535 (aka CVE-2020-0601)

    A Windows vulnerability allows attackers to spoof valid certificate chains when the system root store is in use.

    A workaround is present in Go 1.12.6+ and Go 1.13.7+, but affected users should additionally install the Windows security update to protect their system.

    See https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2020-0601 for details on the Windows vulnerability.

- GO-2022-0536 (aka CVE-2019-9512, CVE-2019-9514, GHSA-39qc-96h7-956f, GHSA-hgr8-6h9x-f7q9)

    Some HTTP/2 implementations are vulnerable to a reset flood, potentially leading to a denial of service.

    Servers that accept direct connections from untrusted clients could be remotely made to allocate an unlimited amount of memory, until the program crashes. The attacker opens a number of streams and sends an invalid request over each stream that should solicit a stream of RST_STREAM frames from the peer. Depending on how the peer queues the RST_STREAM frames, this can consume excess memory, CPU, or both.

- GO-2022-0537 (aka CVE-2022-32189)

    Decoding big.Float and big.Rat types can panic if the encoded message is too short, potentially allowing a denial of service.

- GO-2022-0761 (aka CVE-2016-5386)

    An input validation flaw in the CGI components allows the HTTP_PROXY environment variable to be set by the incoming Proxy header, which changes where Go by default proxies all outbound HTTP requests.

    This environment variable is also used to set the outgoing proxy, enabling an attacker to insert a proxy into outgoing requests of a CGI program.

    Read more about "httpoxy" here: https://httpoxy.org.

- GO-2022-0969 (aka CVE-2022-27664, GHSA-69cg-p879-7622)

    HTTP/2 server connections can hang forever waiting for a clean shutdown that was preempted by a fatal error. This condition can be exploited by a malicious client to cause a denial of service.

- GO-2022-0988 (aka CVE-2022-32190)

    JoinPath and URL.JoinPath do not remove ../ path elements appended to a relative path. For example, JoinPath("https://go.dev", "../go") returns the URL "https://go.dev/../go", despite the JoinPath documentation stating that ../ path elements are removed from the result.

- GO-2022-1037 (aka CVE-2022-2879)

    Reader.Read does not set a limit on the maximum size of file headers. A maliciously crafted archive could cause Read to allocate unbounded amounts of memory, potentially causing resource exhaustion or panics. After fix, Reader.Read limits the maximum size of header blocks to 1 MiB.

- GO-2022-1038 (aka CVE-2022-2880)

    Requests forwarded by ReverseProxy include the raw query parameters from the inbound request, including unparsable parameters rejected by net/http. This could permit query parameter smuggling when a Go proxy forwards a parameter with an unparsable value.

    After fix, ReverseProxy sanitizes the query parameters in the forwarded query when the outbound request's Form field is set after the ReverseProxy. Director function returns, indicating that the proxy has parsed the query parameters. Proxies which do not parse query parameters continue to forward the original query parameters unchanged.

- GO-2022-1039 (aka CVE-2022-41715)

    Programs which compile regular expressions from untrusted sources may be vulnerable to memory exhaustion or denial of service.

    The parsed regexp representation is linear in the size of the input, but in some cases the constant factor can be as high as 40,000, making relatively small regexps consume much larger amounts of memory.

    After fix, each regexp being parsed is limited to a 256 MB memory footprint. Regular expressions whose representation would use more space than that are rejected. Normal use of regular expressions is unaffected.

- GO-2022-1095 (aka CVE-2022-41716)

    Due to unsanitized NUL values, attackers may be able to maliciously set environment variables on Windows.

    In syscall.StartProcess and os/exec.Cmd, invalid environment variable values containing NUL values are not properly checked for. A malicious environment variable value can exploit this behavior to set a value for a different environment variable. For example, the environment variable string "A=B\x00C=D" sets the variables "A=B" and "C=D".

- GO-2022-1143 (aka CVE-2022-41720)

    On Windows, restricted files can be accessed via os.DirFS and http.Dir.

    The os.DirFS function and http.Dir type provide access to a tree of files rooted at a given directory. These functions permit access to Windows device files under that root. For example, os.DirFS("C:/tmp").Open("COM1") opens the COM1 device. Both os.DirFS and http.Dir only provide read-only filesystem access.

    In addition, on Windows, an os.DirFS for the directory (the root of the current drive) can permit a maliciously crafted path to escape from the drive and access any path on the system.

    With fix applied, the behavior of os.DirFS("") has changed. Previously, an empty root was treated equivalently to "/", so os.DirFS("").Open("tmp") would open the path "/tmp". This now returns an error.

- GO-2022-1144 (aka CVE-2022-41717, GHSA-xrjj-mj9h-534m)

    An attacker can cause excessive memory growth in a Go server accepting HTTP/2 requests.

    HTTP/2 server connections contain a cache of HTTP header keys sent by the client. While the total number of entries in this cache is capped, an attacker sending very large keys can cause the server to allocate approximately 64 MiB per open connection.

- GO-2023-1568 (aka CVE-2022-41722)

    A path traversal vulnerability exists in filepath.Clean on Windows.

    On Windows, the filepath.Clean function could transform an invalid path such as "a/../c:/b" into the valid path "c:\b". This transformation of a relative (if invalid) path into an absolute path could enable a directory traversal attack.

    After fix, the filepath.Clean function transforms this path into the relative (but still invalid) path ".\c:\b".

- GO-2023-1569 (aka CVE-2022-41725)

    A denial of service is possible from excessive resource consumption in net/http and mime/multipart.

    Multipart form parsing with mime/multipart.Reader.ReadForm can consume largely unlimited amounts of memory and disk files. This also affects form parsing in the net/http package with the Request methods FormFile, FormValue, ParseMultipartForm, and PostFormValue.

    ReadForm takes a maxMemory parameter, and is documented as storing "up to maxMemory bytes +10MB (reserved for non-file parts) in memory". File parts which cannot be stored in memory are stored on disk in temporary files. The unconfigurable 10MB reserved for non-file parts is excessively large and can potentially open a denial of service vector on its own. However, ReadForm did not properly account for all memory consumed by a parsed form, such as map entry overhead, part names, and MIME headers, permitting a maliciously crafted form to consume well over 10MB. In addition, ReadForm contained no limit on the number of disk files created, permitting a relatively small request body to create a large number of disk temporary files.

    With fix, ReadForm now properly accounts for various forms of memory overhead, and should now stay within its documented limit of 10MB + maxMemory bytes of memory consumption. Users should still be aware that this limit is high and may still be hazardous.

    In addition, ReadForm now creates at most one on-disk temporary file, combining multiple form parts into a single temporary file. The mime/multipart.File interface type's documentation states, "If stored on disk, the File's underlying concrete type will be an *os.File.". This is no longer the case when a form contains more than one file part, due to this coalescing of parts into a single file. The previous behavior of using distinct files for each form part may be reenabled with the environment variable GODEBUG=multipartfiles=distinct.

    Users should be aware that multipart.ReadForm and the http.Request methods that call it do not limit the amount of disk consumed by temporary files. Callers can limit the size of form data with http.MaxBytesReader.

- GO-2023-1570 (aka CVE-2022-41724)

    Large handshake records may cause panics in crypto/tls.

    Both clients and servers may send large TLS handshake records which cause servers and clients, respectively, to panic when attempting to construct responses.

    This affects all TLS 1.3 clients, TLS 1.2 clients which explicitly enable session resumption (by setting Config.ClientSessionCache to a non-nil value), and TLS 1.3 servers which request client certificates (by setting Config.ClientAuth >= RequestClientCert).

- GO-2023-1571 (aka CVE-2022-41723, GHSA-vvpx-j8f3-3w6h)

    A maliciously crafted HTTP/2 stream could cause excessive CPU consumption in the HPACK decoder, sufficient to cause a denial of service from a small number of small requests.

- GO-2023-1621 (aka CVE-2023-24532)

    The ScalarMult and ScalarBaseMult methods of the P256 Curve may return an incorrect result if called with some specific unreduced scalars (a scalar larger than the order of the curve).

    This does not impact usages of crypto/ecdsa or crypto/ecdh.

- GO-2023-1702 (aka CVE-2023-24537)

    Calling any of the Parse functions on Go source code which contains //line directives with very large line numbers can cause an infinite loop due to integer overflow.

- GO-2023-1703 (aka CVE-2023-24538)

    Templates do not properly consider backticks (`) as Javascript string delimiters, and do not escape them as expected.

    Backticks are used, since ES6, for JS template literals. If a template contains a Go template action within a Javascript template literal, the contents of the action can be used to terminate the literal, injecting arbitrary Javascript code into the Go template.

    As ES6 template literals are rather complex, and themselves can do string interpolation, the decision was made to simply disallow Go template actions from being used inside of them (e.g. "var a = {{.}}"), since there is no obviously safe way to allow this behavior. This takes the same approach as github.com/google/safehtml.

    With fix, Template.Parse returns an Error when it encounters templates like this, with an ErrorCode of value 12. This ErrorCode is currently unexported, but will be exported in the release of Go 1.21.

    Users who rely on the previous behavior can re-enable it using the GODEBUG flag jstmpllitinterp=1, with the caveat that backticks will now be escaped. This should be used with caution.

- GO-2023-1704 (aka CVE-2023-24534)

    HTTP and MIME header parsing can allocate large amounts of memory, even when parsing small inputs, potentially leading to a denial of service.

    Certain unusual patterns of input data can cause the common function used to parse HTTP and MIME headers to allocate substantially more memory than required to hold the parsed headers. An attacker can exploit this behavior to cause an HTTP server to allocate large amounts of memory from a small request, potentially leading to memory exhaustion and a denial of service.

    With fix, header parsing now correctly allocates only the memory required to hold parsed headers.

- GO-2023-1705 (aka CVE-2023-24536)

    Multipart form parsing can consume large amounts of CPU and memory when processing form inputs containing very large numbers of parts.

    This stems from several causes:

    1. mime/multipart.Reader.ReadForm limits the total memory a parsed multipart form can consume. ReadForm can undercount the amount of memory consumed, leading it to accept larger inputs than intended.
    2. Limiting total memory does not account for increased pressure on the garbage collector from large numbers of small allocations in forms with many parts.
    3. ReadForm can allocate a large number of short-lived buffers, further increasing pressure on the garbage collector.

    The combination of these factors can permit an attacker to cause an program that parses multipart forms to consume large amounts of CPU and memory, potentially resulting in a denial of service. This affects programs that use mime/multipart.Reader.ReadForm, as well as form parsing in the net/http package with the Request methods FormFile, FormValue, ParseMultipartForm, and PostFormValue.

    With fix, ReadForm now does a better job of estimating the memory consumption of parsed forms, and performs many fewer short-lived allocations.

    In addition, the fixed mime/multipart.Reader imposes the following limits on the size of parsed forms:

    1. Forms parsed with ReadForm may contain no more than 1000 parts. This limit may be adjusted with the environment variable GODEBUG=multipartmaxparts=.
    2. Form parts parsed with NextPart and NextRawPart may contain no more than 10,000 header fields. In addition, forms parsed with ReadForm may contain no more than 10,000 header fields across all parts. This limit may be adjusted with the environment variable GODEBUG=multipartmaxheaders=.

- GO-2023-1751 (aka CVE-2023-24539)

    Angle brackets (<>) are not considered dangerous characters when inserted into CSS contexts. Templates containing multiple actions separated by a '/' character can result in unexpectedly closing the CSS context and allowing for injection of unexpected HTML, if executed with untrusted input.

- GO-2023-1752 (aka CVE-2023-24540)

    Not all valid JavaScript whitespace characters are considered to be whitespace. Templates containing whitespace characters outside of the character set "\t\n\f\r\u0020\u2028\u2029" in JavaScript contexts that also contain actions may not be properly sanitized during execution.

- GO-2023-1753 (aka CVE-2023-29400)

    Templates containing actions in unquoted HTML attributes (e.g. "attr={{.}}") executed with empty input can result in output with unexpected results when parsed due to HTML normalization rules. This may allow injection of arbitrary attributes into tags.

- GO-2023-1840 (aka CVE-2023-29403)

    On Unix platforms, the Go runtime does not behave differently when a binary is run with the setuid/setgid bits. This can be dangerous in certain cases, such as when dumping memory state, or assuming the status of standard i/o file descriptors.

    If a setuid/setgid binary is executed with standard I/O file descriptors closed, opening any files can result in unexpected content being read or written with elevated privileges. Similarly, if a setuid/setgid program is terminated, either via panic or signal, it may leak the contents of its registers.

- GO-2023-1878 (aka CVE-2023-29406)

    The HTTP/1 client does not fully validate the contents of the Host header. A maliciously crafted Host header can inject additional headers or entire requests.

    With fix, the HTTP/1 client now refuses to send requests containing an invalid Request.Host or Request.URL.Host value.

- GO-2023-1987 (aka CVE-2023-29409)

    Extremely large RSA keys in certificate chains can cause a client/server to expend significant CPU time verifying signatures.

    With fix, the size of RSA keys transmitted during handshakes is restricted to <= 8192 bits.

    Based on a survey of publicly trusted RSA keys, there are currently only three certificates in circulation with keys larger than this, and all three appear to be test certificates that are not actively deployed. It is possible there are larger keys in use in private PKIs, but we target the web PKI, so causing breakage here in the interests of increasing the default safety of users of crypto/tls seems reasonable.

- GO-2023-2041 (aka CVE-2023-39318)

    The html/template package does not properly handle HTML-like "" comment tokens, nor hashbang "#!" comment tokens, in <script> contexts. This may cause the template parser to improperly interpret the contents of <script> contexts, causing actions to be improperly escaped. This may be leveraged to perform an XSS attack.

- GO-2023-2043 (aka CVE-2023-39319)

    The html/template package does not apply the proper rules for handling occurrences of "<script", "<!--", and "</script" within JS literals in <script> contexts. This may cause the template parser to improperly consider script contexts to be terminated early, causing actions to be improperly escaped. This could be leveraged to perform an XSS attack.

- GO-2023-2044 (aka CVE-2023-39321)

    Processing an incomplete post-handshake message for a QUIC connection can cause a panic.

- GO-2023-2045 (aka CVE-2023-39322)

    QUIC connections do not set an upper bound on the amount of data buffered when reading post-handshake messages, allowing a malicious QUIC connection to cause unbounded memory growth.

    With fix, connections now consistently reject messages larger than 65KiB in size.

- GO-2023-2102 (aka CVE-2023-39325, GHSA-4374-p667-p6c8)

    A malicious HTTP/2 client which rapidly creates requests and immediately resets them can cause excessive server resource consumption. While the total number of requests is bounded by the http2.Server.MaxConcurrentStreams setting, resetting an in-progress request allows the attacker to create a new request while the existing one is still executing.

    With the fix applied, HTTP/2 servers now bound the number of simultaneously executing handler goroutines to the stream concurrency limit (MaxConcurrentStreams). New requests arriving when at the limit (which can only happen after the client has reset an existing, in-flight request) will be queued until a handler exits. If the request queue grows too large, the server will terminate the connection.

    This issue is also fixed in golang.org/x/net/http2 for users manually configuring HTTP/2.

    The default stream concurrency limit is 250 streams (requests) per HTTP/2 connection. This value may be adjusted using the golang.org/x/net/http2 package; see the Server.MaxConcurrentStreams setting and the ConfigureServer function.

- GO-2023-2185 (aka CVE-2023-45283)

    The filepath package does not recognize paths with a \??\ prefix as special.

    On Windows, a path beginning with \??\ is a Root Local Device path equivalent to a path beginning with \\?\. Paths with a \??\ prefix may be used to access arbitrary locations on the system. For example, the path \??\c:\x is equivalent to the more common path c:\x.

    Before fix, Clean could convert a rooted path such as \a\..\??\b into the root local device path \??\b. Clean will now convert this to .\??\b.

    Similarly, Join(\, ??, b) could convert a seemingly innocent sequence of path elements into the root local device path \??\b. Join will now convert this to \.\??\b.

    In addition, with fix, IsAbs now correctly reports paths beginning with \??\ as absolute, and VolumeName correctly reports the \??\ prefix as a volume name.

    UPDATE: Go 1.20.11 and Go 1.21.4 inadvertently changed the definition of the volume name in Windows paths starting with \?, resulting in filepath.Clean(\?\c:) returning \?\c: rather than \?\c:\ (among other effects). The previous behavior has been restored.

- GO-2023-2185 (aka CVE-2023-45283)

    The filepath package does not recognize paths with a \??\ prefix as special.

    On Windows, a path beginning with \??\ is a Root Local Device path equivalent to a path beginning with \\?\. Paths with a \??\ prefix may be used to access arbitrary locations on the system. For example, the path \??\c:\x is equivalent to the more common path c:\x.

    Before fix, Clean could convert a rooted path such as \a\..\??\b into the root local device path \??\b. Clean will now convert this to .\??\b.

    Similarly, Join(\, ??, b) could convert a seemingly innocent sequence of path elements into the root local device path \??\b. Join will now convert this to \.\??\b.

    In addition, with fix, IsAbs now correctly reports paths beginning with \??\ as absolute, and VolumeName correctly reports the \??\ prefix as a volume name.

    UPDATE: Go 1.20.11 and Go 1.21.4 inadvertently changed the definition of the volume name in Windows paths starting with \?, resulting in filepath.Clean(\?\c:) returning \?\c: rather than \?\c:\ (among other effects). The previous behavior has been restored.

- GO-2023-2186 (aka CVE-2023-45284)

    On Windows, The IsLocal function does not correctly detect reserved device names in some cases.

    Reserved names followed by spaces, such as "COM1 ", and reserved names "COM" and "LPT" followed by superscript 1, 2, or 3, are incorrectly reported as local.

    With fix, IsLocal now correctly reports these names as non-local.

- GO-2023-2375 (aka CVE-2023-45287)

    Before Go 1.20, the RSA based TLS key exchanges used the math/big library, which is not constant time. RSA blinding was applied to prevent timing attacks, but analysis shows this may not have been fully effective. In particular it appears as if the removal of PKCS#1 padding may leak timing information, which in turn could be used to recover session key bits.

    In Go 1.20, the crypto/tls library switched to a fully constant time RSA implementation, which we do not believe exhibits any timing side channels.

- GO-2023-2382 (aka CVE-2023-39326)

    A malicious HTTP sender can use chunk extensions to cause a receiver reading from a request or response body to read many more bytes from the network than are in the body.

    A malicious HTTP client can further exploit this to cause a server to automatically read a large amount of data (up to about 1GiB) when a handler fails to read the entire body of a request.

    Chunk extensions are a little-used HTTP feature which permit including additional metadata in a request or response body sent using the chunked encoding. The net/http chunked encoding reader discards this metadata. A sender can exploit this by inserting a large metadata segment with each byte transferred. The chunk reader now produces an error if the ratio of real body to encoded bytes grows too small.

- GO-2024-2598 (aka CVE-2024-24783)

    Verifying a certificate chain which contains a certificate with an unknown public key algorithm will cause Certificate.Verify to panic.

    This affects all crypto/tls clients, and servers that set Config.ClientAuth to VerifyClientCertIfGiven or RequireAndVerifyClientCert. The default behavior is for TLS servers to not verify client certificates.

- GO-2024-2599 (aka CVE-2023-45290)

    When parsing a multipart form (either explicitly with Request.ParseMultipartForm or implicitly with Request.FormValue, Request.PostFormValue, or Request.FormFile), limits on the total size of the parsed form were not applied to the memory consumed while reading a single form line. This permits a maliciously crafted input containing very long lines to cause allocation of arbitrarily large amounts of memory, potentially leading to memory exhaustion.

    With fix, the ParseMultipartForm function now correctly limits the maximum size of form lines.

- GO-2024-2600 (aka CVE-2023-45289)

    When following an HTTP redirect to a domain which is not a subdomain match or exact match of the initial domain, an http.Client does not forward sensitive headers such as "Authorization" or "Cookie". For example, a redirect from foo.com to www.foo.com will forward the Authorization header, but a redirect to bar.com will not.

    A maliciously crafted HTTP redirect could cause sensitive headers to be unexpectedly forwarded.

- GO-2024-2609 (aka CVE-2024-24784)

    The ParseAddressList function incorrectly handles comments (text within parentheses) within display names. Since this is a misalignment with conforming address parsers, it can result in different trust decisions being made by programs using different parsers.

- GO-2024-2610 (aka CVE-2024-24785)

    If errors returned from MarshalJSON methods contain user controlled data, they may be used to break the contextual auto-escaping behavior of the html/template package, allowing for subsequent actions to inject unexpected content into templates.

- GO-2024-2687 (aka CVE-2023-45288, GHSA-4v7x-pqxf-cx7m)

    An attacker may cause an HTTP/2 endpoint to read arbitrary amounts of header data by sending an excessive number of CONTINUATION frames.

    Maintaining HPACK state requires parsing and processing all HEADERS and CONTINUATION frames on a connection. When a request's headers exceed MaxHeaderBytes, no memory is allocated to store the excess headers, but they are still parsed.

    This permits an attacker to cause an HTTP/2 endpoint to read arbitrary amounts of header data, all associated with a request which is going to be rejected. These headers can include Huffman-encoded data which is significantly more expensive for the receiver to decode than for an attacker to send.

    The fix sets a limit on the amount of excess header frames we will process before closing a connection.

- GO-2024-2824 (aka CVE-2024-24788)

    A malformed DNS message in response to a query can cause the Lookup functions to get stuck in an infinite loop.

- GO-2024-2887 (aka CVE-2024-24790)

    The various Is methods (IsPrivate, IsLoopback, etc) did not work as expected for IPv4-mapped IPv6 addresses, returning false for addresses which would return true in their traditional IPv4 forms.

- GO-2024-2888 (aka CVE-2024-24789)

    The archive/zip package's handling of certain types of invalid zip files differs from the behavior of most zip implementations. This misalignment could be exploited to create an zip file with contents that vary depending on the implementation reading the file. The archive/zip package now rejects files containing these errors.

Using your build.sh script, I created a fresh build of the gosu-amd64 binary. When I ran a scan on it, the results were as follows:

$ ./govulncheck-with-excludes.sh --mode=binary gosu-amd64
=== Symbol Results ===

No vulnerabilities found.

Your code is affected by 0 vulnerabilities.
This scan also found 1 vulnerability in packages you import and 14
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.

Maybe I am misunderstanding it. If that's the case, I apologize – I am not a developer and just trying to make do with the tools available.

tianon commented 5 months ago

Nice, definitely something misbehaving; thanks for the report (I've copied it to https://github.com/tianon/gosu/issues/144). :heart:

tianon commented 5 months ago

Script is fixed via https://github.com/tianon/gosu/pull/145 :+1: :heart:

matt-gribben commented 5 months ago

Can I also throw my hat into the ring here and ask that a release is published with the new Go version? The critical CVEs that exist because of an older version prevent this being used with the majority of our customers and presents a significant hurdle.

shubhamrajvanshi commented 3 months ago

It's been 10 month since the last release and since then there's been new commits added to the repo. Are there any plans for a new release now since now there has been new changes/commits added, @tianon ?

tianon commented 3 months ago

The reduction in code, binary size, and use of Go's stdlib from the changes to main.go (https://github.com/tianon/gosu/compare/tianon:0d18474...tianon:052c5c2) is probably worth a release, yeah -- however, note that if I do a new release, my builds will be from Go 1.20.5, so may not accomplish your goals for me doing a new release (in the interest of full disclosure).

shubhamrajvanshi commented 3 months ago

Thanks, that would be helpful but while you are at it can we at least stick to the latest minor release version i.e. 1.20.14 at a minimum?

Alternatively, I would like to point out that 1.23 was released 2 days back which makes 1.20 out of support according to the Golang release policy It would be worth it to bump the go version before the release.

tianon commented 3 months ago

If there is a functional or security change in a newer release of Go that's actually relevant to gosu's tiny code paths, I'd be happy to update, but I haven't seen one yet. πŸ˜…

(see also https://github.com/tianon/gosu/blob/master/SECURITY.md)

CRCinAU commented 3 months ago

@tianon - I'm kinda curious about your mindset on spending so much of your time and effort pushing back on just updating things and maintaining your own project.

I don't even see your point in claiming that an EOL Go version is 'just fine' because it gets to a point where people don't even accept bug reports against EOL versions of tools - meaning even if there is a security problem, you'll never know about it because it'll be rejected as against an EOL version.

What it does do is to completely expose anyone who uses your project to anything you don't know about. Is this theoretical? Sure. Just as your proposition is that there aren't any issues staying on an EOL version. It's perfectly ok - up until it isn't - and you end up poisoning the entire supply chain.

Considering the resources utilised to keep having this argument again, and again, and again, and again - and the countless hours outside of your own effort by everyone else who has to deal with it, wouldn't it be a much smaller wasted human effort to just adhere to accepted best practices for just about everyone else?

ldath commented 1 month ago
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Library β”‚ Vulnerability  β”‚ Severity β”‚ Status β”‚ Installed Version β”‚  Fixed Version  β”‚                           Title                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ stdlib  β”‚ CVE-2023-24538 β”‚ CRITICAL β”‚ fixed  β”‚ 1.18.2            β”‚ 1.19.8, 1.20.3  β”‚ golang: html/template: backticks not treated as string     β”‚
β”‚         β”‚                β”‚          β”‚        β”‚                   β”‚                 β”‚ delimiters                                                 β”‚
β”‚         β”‚                β”‚          β”‚        β”‚                   β”‚                 β”‚ https://avd.aquasec.com/nvd/cve-2023-24538                 β”‚
β”‚         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€          β”‚        β”‚                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         β”‚ CVE-2023-24540 β”‚          β”‚        β”‚                   β”‚ 1.19.9, 1.20.4  β”‚ golang: html/template: improper handling of JavaScript     β”‚
β”‚         β”‚                β”‚          β”‚        β”‚                   β”‚                 β”‚ whitespace                                                 β”‚
β”‚         β”‚                β”‚          β”‚        β”‚                   β”‚                 β”‚ https://avd.aquasec.com/nvd/cve-2023-24540                 β”‚
β”‚         β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€          β”‚        β”‚                   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         β”‚ CVE-2024-24790 β”‚          β”‚        β”‚                   β”‚ 1.21.11, 1.22.4 β”‚ golang: net/netip: Unexpected behavior from Is methods for β”‚
β”‚         β”‚                β”‚          β”‚        β”‚                   β”‚                 β”‚ IPv4-mapped IPv6 addresses                                 β”‚
β”‚         β”‚                β”‚          β”‚        β”‚                   β”‚                 β”‚ https://avd.aquasec.com/nvd/cve-2024-24790                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

It is not important if gosu can be affected by it or not. Problem is that if you are using gosu and your image is scanned than your image is failing security test.

I'm fortunately not using this project in the corporate environment and in a free time I'll just update my fork to fix this and switch to my own version.

By checking how long fixing this problem takes my only suggestion to others is to do the same - fork this very good project and maintain it in your own fork.

szh commented 1 month ago

I'm experiencing this with Trivy scanning an image based on postgres:15-alpine. You can actually see it on the DockerHub page here

Screenshot 2024-10-22 at 11 11 05β€―AM Screenshot 2024-10-22 at 11 11 10β€―AM

Is there any workaround, other than going in and removing the gosu binary from the image (and hoping that doesn't break anything)? To clarify, I understand it's a false positive, but Trivy and other scanners are catching it, and it seems like the easiest path forward is to recompile it or remove it.

AlexanderYastrebov commented 1 month ago

I'm experiencing this with Trivy

This ticket https://github.com/aquasecurity/trivy/issues/2845 claims that govuln was integrated into Trivy.

I also checked postgres:15-alpine and it looks like there is indeed one issue reported:

$ ID=$(docker create postgres:15-alpine)
$ docker cp $ID:/usr/local/bin/gosu /tmp/postgres-gosu
Successfully copied 2.36MB to /tmp/postgres-gosu
$ go version -m /tmp/postgres-gosu 
/tmp/postgres-gosu: go1.18.2
        path    github.com/tianon/gosu
        mod     github.com/tianon/gosu  (devel)
        dep     github.com/moby/sys/user        v0.1.0  h1:WmZ93f5Ux6het5iituh9x2zAG7NFY9Aqi49jjE1PaQg=
        dep     golang.org/x/sys        v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
        build   -compiler=gc
        build   -ldflags="-d -w"
        build   CGO_ENABLED=0
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v1
$ govulncheck -mode=binary /tmp/postgres-gosu 
=== Symbol Results ===

Vulnerability #1: GO-2023-1840
    Unsafe behavior in setuid/setgid binaries in runtime
  More info: https://pkg.go.dev/vuln/GO-2023-1840
  Standard library
    Found in: runtime@go1.18.2
    Fixed in: runtime@go1.19.10
    Vulnerable symbols found:
      #1: runtime.Caller
      #2: runtime.CallersFrames
      #3: runtime.Frames.Next
      #4: runtime.Func.Entry
      #5: runtime.Func.Name
      Use '-show traces' to see the other 20 found symbols

Your code is affected by 1 vulnerability from the Go standard library.
This scan also found 3 vulnerabilities in packages you import and 44
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.
Verbose mode output ```console $ govulncheck -mode=binary -show=verbose /tmp/postgres-gosu Scanning your binary for known vulnerabilities... Fetching vulnerabilities from the database... Checking the binary against the vulnerabilities... === Symbol Results === Vulnerability #1: GO-2023-1840 Unsafe behavior in setuid/setgid binaries in runtime More info: https://pkg.go.dev/vuln/GO-2023-1840 Standard library Found in: runtime@go1.18.2 Fixed in: runtime@go1.19.10 Vulnerable symbols found: #1: runtime.Caller #2: runtime.CallersFrames #3: runtime.Frames.Next #4: runtime.Func.Entry #5: runtime.Func.Name Use '-show traces' to see the other 20 found symbols === Package Results === Vulnerability #1: GO-2023-2186 Incorrect detection of reserved device names on Windows in path/filepath More info: https://pkg.go.dev/vuln/GO-2023-2186 Standard library Found in: path/filepath@go1.18.2 Fixed in: path/filepath@go1.20.11 Vulnerability #2: GO-2022-0527 Stack exhaustion in Glob on certain paths in io/fs More info: https://pkg.go.dev/vuln/GO-2022-0527 Standard library Found in: io/fs@go1.18.2 Fixed in: io/fs@go1.18.4 Vulnerability #3: GO-2022-0522 Stack exhaustion on crafted paths in path/filepath More info: https://pkg.go.dev/vuln/GO-2022-0522 Standard library Found in: path/filepath@go1.18.2 Fixed in: path/filepath@go1.18.4 === Module Results === Vulnerability #1: GO-2024-3107 Stack exhaustion in Parse in go/build/constraint More info: https://pkg.go.dev/vuln/GO-2024-3107 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.22.7 Vulnerability #2: GO-2024-3106 Stack exhaustion in Decoder.Decode in encoding/gob More info: https://pkg.go.dev/vuln/GO-2024-3106 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.22.7 Vulnerability #3: GO-2024-3105 Stack exhaustion in all Parse functions in go/parser More info: https://pkg.go.dev/vuln/GO-2024-3105 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.22.7 Vulnerability #4: GO-2024-2963 Denial of service due to improper 100-continue handling in net/http More info: https://pkg.go.dev/vuln/GO-2024-2963 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.12 Vulnerability #5: GO-2024-2888 Mishandling of corrupt central directory record in archive/zip More info: https://pkg.go.dev/vuln/GO-2024-2888 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.11 Vulnerability #6: GO-2024-2887 Unexpected behavior from Is methods for IPv4-mapped IPv6 addresses in net/netip More info: https://pkg.go.dev/vuln/GO-2024-2887 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.11 Vulnerability #7: GO-2024-2687 HTTP/2 CONTINUATION flood in net/http More info: https://pkg.go.dev/vuln/GO-2024-2687 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.9 Vulnerability #8: GO-2024-2610 Errors returned from JSON marshaling may break template escaping in html/template More info: https://pkg.go.dev/vuln/GO-2024-2610 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.8 Vulnerability #9: GO-2024-2609 Comments in display names are incorrectly handled in net/mail More info: https://pkg.go.dev/vuln/GO-2024-2609 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.8 Vulnerability #10: GO-2024-2600 Incorrect forwarding of sensitive headers and cookies on HTTP redirect in net/http More info: https://pkg.go.dev/vuln/GO-2024-2600 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.8 Vulnerability #11: GO-2024-2599 Memory exhaustion in multipart form parsing in net/textproto and net/http More info: https://pkg.go.dev/vuln/GO-2024-2599 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.8 Vulnerability #12: GO-2024-2598 Verify panics on certificates with an unknown public key algorithm in crypto/x509 More info: https://pkg.go.dev/vuln/GO-2024-2598 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.21.8 Vulnerability #13: GO-2023-2382 Denial of service via chunk extensions in net/http More info: https://pkg.go.dev/vuln/GO-2023-2382 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.20.12 Vulnerability #14: GO-2023-2375 Before Go 1.20, the RSA based key exchange methods in crypto/tls may exhibit a timing side channel More info: https://pkg.go.dev/vuln/GO-2023-2375 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.20 Vulnerability #15: GO-2023-2102 HTTP/2 rapid reset can cause excessive work in net/http More info: https://pkg.go.dev/vuln/GO-2023-2102 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.20.10 Vulnerability #16: GO-2023-2043 Improper handling of special tags within script contexts in html/template More info: https://pkg.go.dev/vuln/GO-2023-2043 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.20.8 Vulnerability #17: GO-2023-2041 Improper handling of HTML-like comments in script contexts in html/template More info: https://pkg.go.dev/vuln/GO-2023-2041 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.20.8 Vulnerability #18: GO-2023-1987 Large RSA keys can cause high CPU usage in crypto/tls More info: https://pkg.go.dev/vuln/GO-2023-1987 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.12 Vulnerability #19: GO-2023-1878 Insufficient sanitization of Host header in net/http More info: https://pkg.go.dev/vuln/GO-2023-1878 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.11 Vulnerability #20: GO-2023-1753 Improper handling of empty HTML attributes in html/template More info: https://pkg.go.dev/vuln/GO-2023-1753 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.9 Vulnerability #21: GO-2023-1752 Improper handling of JavaScript whitespace in html/template More info: https://pkg.go.dev/vuln/GO-2023-1752 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.9 Vulnerability #22: GO-2023-1751 Improper sanitization of CSS values in html/template More info: https://pkg.go.dev/vuln/GO-2023-1751 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.9 Vulnerability #23: GO-2023-1705 Excessive resource consumption in net/http, net/textproto and mime/multipart More info: https://pkg.go.dev/vuln/GO-2023-1705 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.8 Vulnerability #24: GO-2023-1704 Excessive memory allocation in net/http and net/textproto More info: https://pkg.go.dev/vuln/GO-2023-1704 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.8 Vulnerability #25: GO-2023-1703 Backticks not treated as string delimiters in html/template More info: https://pkg.go.dev/vuln/GO-2023-1703 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.8 Vulnerability #26: GO-2023-1702 Infinite loop in parsing in go/scanner More info: https://pkg.go.dev/vuln/GO-2023-1702 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.8 Vulnerability #27: GO-2023-1621 Incorrect calculation on P256 curves in crypto/internal/nistec More info: https://pkg.go.dev/vuln/GO-2023-1621 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.7 Vulnerability #28: GO-2023-1571 Denial of service via crafted HTTP/2 stream in net/http and golang.org/x/net More info: https://pkg.go.dev/vuln/GO-2023-1571 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.6 Vulnerability #29: GO-2023-1570 Panic on large handshake records in crypto/tls More info: https://pkg.go.dev/vuln/GO-2023-1570 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.6 Vulnerability #30: GO-2023-1569 Excessive resource consumption in mime/multipart More info: https://pkg.go.dev/vuln/GO-2023-1569 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.19.6 Vulnerability #31: GO-2022-1144 Excessive memory growth in net/http and golang.org/x/net/http2 More info: https://pkg.go.dev/vuln/GO-2022-1144 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.9 Vulnerability #32: GO-2022-1039 Memory exhaustion when compiling regular expressions in regexp/syntax More info: https://pkg.go.dev/vuln/GO-2022-1039 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.7 Vulnerability #33: GO-2022-1038 Incorrect sanitization of forwarded query parameters in net/http/httputil More info: https://pkg.go.dev/vuln/GO-2022-1038 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.7 Vulnerability #34: GO-2022-1037 Unbounded memory consumption when reading headers in archive/tar More info: https://pkg.go.dev/vuln/GO-2022-1037 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.7 Vulnerability #35: GO-2022-0969 Denial of service in net/http and golang.org/x/net/http2 More info: https://pkg.go.dev/vuln/GO-2022-0969 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.6 Vulnerability #36: GO-2022-0537 Panic when decoding Float and Rat types in math/big More info: https://pkg.go.dev/vuln/GO-2022-0537 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.5 Vulnerability #37: GO-2022-0531 Session tickets lack random ticket_age_add in crypto/tls More info: https://pkg.go.dev/vuln/GO-2022-0531 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.3 Vulnerability #38: GO-2022-0526 Stack exhaustion when decoding certain messages in encoding/gob More info: https://pkg.go.dev/vuln/GO-2022-0526 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Vulnerability #39: GO-2022-0525 Improper sanitization of Transfer-Encoding headers in net/http More info: https://pkg.go.dev/vuln/GO-2022-0525 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Vulnerability #40: GO-2022-0524 Stack exhaustion when reading certain archives in compress/gzip More info: https://pkg.go.dev/vuln/GO-2022-0524 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Vulnerability #41: GO-2022-0523 Stack exhaustion when unmarshaling certain documents in encoding/xml More info: https://pkg.go.dev/vuln/GO-2022-0523 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Vulnerability #42: GO-2022-0521 Stack exhaustion from deeply nested XML documents in encoding/xml More info: https://pkg.go.dev/vuln/GO-2022-0521 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Vulnerability #43: GO-2022-0520 Exposure of client IP addresses in net/http More info: https://pkg.go.dev/vuln/GO-2022-0520 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Vulnerability #44: GO-2022-0515 Stack exhaustion due to deeply nested types in go/parser More info: https://pkg.go.dev/vuln/GO-2022-0515 Standard library Found in: stdlib@go1.18.2 Fixed in: stdlib@go1.18.4 Your code is affected by 1 vulnerability from the Go standard library. This scan also found 3 vulnerabilities in packages you import and 44 vulnerabilities in modules you require, but your code doesn't appear to call these vulnerabilities. ```
tianon commented 1 month ago

https://github.com/tianon/gosu/blob/4233b796eeb3ba76c8597a46d89eab1f116188e2/SECURITY.md

Our govulncheck wrapper script (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.

https://github.com/tianon/gosu/blob/4233b796eeb3ba76c8597a46d89eab1f116188e2/govulncheck-with-excludes.sh#L9-L13

AlexanderYastrebov commented 1 month ago

Our govulncheck wrapper script (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.

FWIW govulncheck reports none for gosu built with latest golang. I think this is due to https://go-review.googlesource.com/c/go/+/501223 that mitigates GO-2023-1840

szh commented 4 weeks ago

I thought maybe we could use Copa to remove the vulnerability automatically but it only deals with OS packages so it had no effect here.

tianon commented 4 weeks ago

That, and the "vulnerable code" doesn't even exist inside the binary, so there's nothing to remove.

shusaan commented 2 weeks ago

I have verified that there is no vulnerable code, and govulncheck-with-excludes.sh did not find any vulnerabilities. However, after researching tools like Trivyand Grype, I found that they perform extensive scans and have identified vulnerabilities in the gosu binary. These vulnerabilities are due to the build environment being old version and some modules being outdated. For details on the build environment and modules, please refer to this PR.

tianon commented 2 weeks ago

I would say "more naive" instead of "more extensive" -- they identify the version numbers involved and assume the software is vulnerable whether it involves the vulnerable code paths or not (that's what makes govulncheck different; it actually knows which code paths are vulnerable and checks for those directly, which means a lot fewer false positives).