tianon / gosu

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

govulncheck-with-excludes reporting lots of results, including archive/zip #144

Closed tianon closed 3 months ago

tianon commented 3 months ago

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.

Originally posted by @rgarcia89 in https://github.com/tianon/gosu/issues/136#issuecomment-2152209745

tianon commented 3 months ago

This is really interesting -- I can reproduce, and it's definitely something going wrong (as most obviously evidenced by archive/zip being in that list, for example -- we don't touch anything from that module in gosu's codepaths).

tianon commented 3 months ago

Separately, I also clearly need to update the CI here to download the latest release and test that too.

tianon commented 3 months ago

Well this is interesting -- maybe a bug in govulncheck or me misunderstanding their JSON format:

$ govulncheck -mode=binary ./gosu-amd64
=== 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 40
vulnerabilities in modules you require, but your code doesn't appear to call
these vulnerabilities.
Use '-show verbose' for more details.

(only the one result, as expected)

$ govulncheck -mode=binary -format json ./gosu-amd64 | jq -s 'map(.osv.id // empty) | unique | join("\n")' -r
GO-2021-0067
GO-2021-0069
GO-2021-0142
GO-2021-0154
GO-2021-0159
GO-2021-0160
GO-2021-0163
GO-2021-0172
GO-2021-0178
GO-2021-0223
GO-2021-0224
GO-2021-0226
GO-2021-0234
GO-2021-0235
GO-2021-0239
GO-2021-0240
GO-2021-0241
GO-2021-0242
GO-2021-0243
GO-2021-0245
GO-2021-0263
GO-2021-0264
GO-2021-0317
GO-2021-0319
GO-2021-0347
GO-2022-0166
GO-2022-0171
GO-2022-0187
GO-2022-0191
GO-2022-0211
GO-2022-0212
GO-2022-0213
GO-2022-0217
GO-2022-0220
GO-2022-0229
GO-2022-0236
GO-2022-0273
GO-2022-0288
GO-2022-0289
GO-2022-0433
GO-2022-0434
GO-2022-0435
GO-2022-0477
GO-2022-0493
GO-2022-0515
GO-2022-0520
GO-2022-0521
GO-2022-0522
GO-2022-0523
GO-2022-0524
GO-2022-0525
GO-2022-0526
GO-2022-0527
GO-2022-0531
GO-2022-0532
GO-2022-0533
GO-2022-0535
GO-2022-0536
GO-2022-0537
GO-2022-0761
GO-2022-0969
GO-2022-0988
GO-2022-1037
GO-2022-1038
GO-2022-1039
GO-2022-1095
GO-2022-1143
GO-2022-1144
GO-2023-1568
GO-2023-1569
GO-2023-1570
GO-2023-1571
GO-2023-1621
GO-2023-1702
GO-2023-1703
GO-2023-1704
GO-2023-1705
GO-2023-1751
GO-2023-1752
GO-2023-1753
GO-2023-1840
GO-2023-1878
GO-2023-1987
GO-2023-2041
GO-2023-2043
GO-2023-2044
GO-2023-2045
GO-2023-2102
GO-2023-2185
GO-2023-2186
GO-2023-2375
GO-2023-2382
GO-2024-2598
GO-2024-2599
GO-2024-2600
GO-2024-2609
GO-2024-2610
GO-2024-2687
GO-2024-2824
GO-2024-2887
GO-2024-2888

(whoa baby, what?)

tianon commented 3 months ago

Aha, it looks like -format has a new openvex output mode which lists the inverse of the normal output, and I bet the JSON changes are related to that.

tianon commented 3 months ago

As far as I can tell, the JSON output now no longer differentiates between "module used but codepath is not" and "module used and codepath in callstack" which is wild.

tianon commented 3 months ago

At least the sarif output includes level which is either note or error to help differentiate these. :confused:

tianon commented 3 months ago

https://github.com/golang/vuln/releases/tag/v1.0.2

govulncheck (streaming) JSON now emits an OSV message for each vulnerability associated with user modules and its transitive dependencies, regardless of the module version.

This is great, but needs some sane way to filter. :grimacing:

zpavlinovic commented 3 months ago

Have you looked at govulncheck Finding at all?

Also, one of its comments explains how to filter. (In fact, we create SARIF output from these structures and the comment explanations)

tianon commented 3 months ago

Ah, that's really helpful context, thank you! :heart:

(I really appreciate your time/eyes on this :bow:)

tianon commented 3 months ago

Hmm, I must still be holding it wrong: :sob: (when I look at findings instead, I still get a long list not what -format text prints out)

$ govulncheck -mode=binary -format json ./gosu-amd64 | jq -s 'map(.finding.osv // empty) | unique | join("\n")' -r
GO-2022-0515
GO-2022-0520
GO-2022-0521
GO-2022-0522
GO-2022-0523
GO-2022-0524
GO-2022-0525
GO-2022-0526
GO-2022-0527
GO-2022-0531
GO-2022-0537
GO-2022-0969
GO-2022-1037
GO-2022-1038
GO-2022-1039
GO-2022-1144
GO-2023-1569
GO-2023-1570
GO-2023-1571
GO-2023-1621
GO-2023-1702
GO-2023-1703
GO-2023-1704
GO-2023-1705
GO-2023-1751
GO-2023-1752
GO-2023-1753
GO-2023-1840
GO-2023-1878
GO-2023-1987
GO-2023-2041
GO-2023-2043
GO-2023-2102
GO-2023-2186
GO-2023-2375
GO-2023-2382
GO-2024-2598
GO-2024-2599
GO-2024-2600
GO-2024-2609
GO-2024-2610
GO-2024-2687
GO-2024-2887
GO-2024-2888
tianon commented 3 months ago

I guess that's this note:

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

but I can't figure out how to filter these 40 from the JSON :disappointed:

tianon commented 3 months ago

Oh, I guess checking the trace for function/receiver?

tianon commented 3 months ago

Aha, that is the key, thank you again!! :bow: :heavy_heart_exclamation:

$ govulncheck -mode=binary -format json ./gosu-amd64 | jq -s 'map(select(.finding and .finding.trace and any(.finding.trace[]; has("function"))) | .finding.osv // empty) | unique | join("\n")' -r
GO-2023-1840
zpavlinovic commented 3 months ago

I don't have more time to help with this as this is not a bug related to govulncheck. The documentation on Finding contains the necessary information. If you are analyzing source code and want symbol-level findings, you will need to look at Findings whose first trace element has Function != "". You can also use internal/sarif as a reference.

tianon commented 3 months ago

Totally fair, I appreciate it very much!! (and also govulncheck :heart:)