Repository navigation
archive/zip: EOCDR comment length handling is inconsistent with other ZIP implementations #66869
Copy link
Copy link
Closed
NixOS/nixpkgs
#319485Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Security
Milestone
Description
Activity
- addedNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Apr 17, 2024 - addedNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.and removedNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
on Apr 22, 2024 Change https://go.dev/cl/585397 mentions this issue:
archive/zip: treat truncated EOCDR comment as an error- added a commit that references this issue
on May 16, 2024 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:
[release-branch.go1.21] archive/zip: treat truncated EOCDR comment as an errorChange https://go.dev/cl/588796 mentions this issue:
[release-branch.go1.22] archive/zip: treat truncated EOCDR comment as an error- added a commit that references this issue
on Jun 5, 2024 - locked and limited conversation to collaborators
on May 28, 2025
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.Security
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 envin 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/zipshould return an error when a bogus EOCDR is encountered.