-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
archive/zip: EOCDR comment length handling is inconsistent with other ZIP implementations #66869
Comments
Change https://go.dev/cl/585397 mentions this issue: |
This parser misalignment is a PUBLIC track security issue. We have assigned this CVE-2024-24789. @gopherbot please open backport issues. This is a security issue. |
Backport issue(s) opened: #67553 (for 1.21), #67554 (for 1.22). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/588795 mentions this issue: |
Change https://go.dev/cl/588796 mentions this issue: |
… an error When scanning for an end of central directory record, treat an EOCDR signature with a record containing a truncated comment as an error. Previously, we would skip over the invalid record and look for another one. Other implementations do not do this (they either consider this a hard error, or just ignore the truncated comment). This parser misalignment allowed presenting entirely different archive contents to Go programs and other zip decoders. For #66869 Fixes #67554 Change-Id: I94e5cb028534bb5704588b8af27f1e22ea49c7c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/585397 Reviewed-by: Joseph Tsai <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit 33d725e) Reviewed-on: https://go-review.googlesource.com/c/go/+/588796 Reviewed-by: Matthew Dempsky <[email protected]>
… an error When scanning for an end of central directory record, treat an EOCDR signature with a record containing a truncated comment as an error. Previously, we would skip over the invalid record and look for another one. Other implementations do not do this (they either consider this a hard error, or just ignore the truncated comment). This parser misalignment allowed presenting entirely different archive contents to Go programs and other zip decoders. For #66869 Fixes #67553 Change-Id: I94e5cb028534bb5704588b8af27f1e22ea49c7c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/585397 Reviewed-by: Joseph Tsai <[email protected]> Reviewed-by: Dmitri Shuralyov <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> (cherry picked from commit 33d725e) Reviewed-on: https://go-review.googlesource.com/c/go/+/588795 Reviewed-by: Matthew Dempsky <[email protected]>
Notably includes golang/go#66869 and `RemoveInsecurePaths()` for golang/go#55356 Updates CI.
Notably includes golang/go#66869 and `RemoveInsecurePaths()` for golang/go#55356
This has been reported in email and accepted as a PUBLIC track security issue.
Go version
go version go1.22.2 linux/amd64
Output of
go env
in your module/workspace:What did you do?
Use
archive/zip
(actually, a thin wrapper library https://github.com/evilsocket/islazy/blob/master/zip/unzip.go) to extract the attached ZIP archive: poc.zip (Warning: It contains malware. Do not open the extracted exe file!)It is constructed as illustrated below:
What did you see happen?
It can get the malware inside the ZIP archive. This is caused by the following logic, which skips EOCDR with a bogus comment length field and continues to search for the next one:
go/src/archive/zip/reader.go
Lines 702 to 704 in c51f6c6
However, this is inconsistent with most other ZIP implementations, so they are using different EOCDRs and get different files extracted. Most other ZIP implementations are not able to get the virus. The PoC file is flagged by only 1/62 security vendor on VirusTotal.
This inconsistency can also be used in other scenarios depending on the specific use case of the package, such as hiding add-on files from linter and reviewers.
What did you expect to see?
archive/zip
should return an error when a bogus EOCDR is encountered.The text was updated successfully, but these errors were encountered: