CVE-2021-41772: Vulnerability in stdlib package - Panic when opening certain archives in archive/zip

stdlib Updated 02 Oct 2025

Summary

13/01/2022
Yes i
Unrated
Not published

CVE-2021-41772: Panic when opening certain archives in archive/zip. Affects stdlib across 2 version ranges.

< 1.16.10 >= 1.17.0-0, < 1.17.3

Fixed in 1.16.10 or 1.17.3, depending on the release line you run. How to fix ↓

Also tracked for

The same CVE-2021-41772 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The stdlib package in Go is a collection of standard libraries that provide fundamental functionality for Go programs. It includes various modules for tasks such as file handling, networking, and data manipulation. One of the modules, archive/zip, allows for the creation and extraction of zip archives. However, a vulnerability has been discovered in the package that can lead to a panic when opening certain archives.

Vulnerability Detail

The vulnerability arises when attempting to open a zip archive using the (*Reader).Open function. If the archive contains a file with a name consisting solely of slash characters or ".." path elements, it could trigger a panic. Additionally, passing an empty string as an argument to the function could also result in a panic. The issue has been addressed in versions 1.16.10 and 1.17.3 of the stdlib package, where files with invalid names are skipped and not added to the file list. However, they can still be accessed through the (*Reader).File function. It's important to note that the cleaned name returned by (*Reader).Open may differ from the original name in (*Reader).File. The panic site has also been made more robust as a defense-in-depth measure.

How To Fix

Latest published version: go1.25.5 as of 22 Oct 2026

go get stdlib@vgo1.25.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.16.10 1.16.10
    go get stdlib@v1.16.10
  • >= 1.17.0-0, < 1.17.3 1.17.3
    go get stdlib@v1.17.3

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Workaround

If updating the stdlib package is not immediately feasible, a workaround can be implemented by manually skipping files with invalid names when processing zip archives. Here is an example of how this can be done:

package main

import (
	"archive/zip"
	"fmt"
	"io"
	"os"
)

func main() {
	zipFile, err := zip.OpenReader("example.zip")
	if err != nil {
		fmt.Println("Failed to open zip file: ", err)
		return
	}
	defer zipFile.Close()

	for _, file := range zipFile.File {
		if file.Name == "" || file.Name[0] == '/' || file.Name[0] == '.' {
			fmt.Println("Skipping file with invalid name: ", file.Name)
			continue
		}

		// Process the valid file
		// ...
	}
}

Conclusion

In conclusion, the stdlib package in Go is vulnerable to a panic when opening certain archives in the archive/zip module. This can be triggered by files with invalid names or passing an empty string as an argument. The issue has been addressed in versions 1.16.10 and 1.17.3 of the package. It is recommended to update the package to the patched versions or implement the provided workaround. Regularly checking for vulnerabilities using tools like Vulert can help ensure the security of your applications.

See every vulnerability recorded for stdlib →

Share this vulnerability

FAQ

The vulnerability can lead to a panic, causing the affected application to crash. This can result in a denial of service or potential data loss if the panic occurs during critical operations.

You can use the Vulert Playground at Vulert Scanner to check if your application is affected by this vulnerability. Simply upload your Gopkg.lock file and the tool will analyze it for any known vulnerabilities, including this one.

No, this vulnerability does not allow for remote exploitation. An attacker would need to have access to a zip archive with files containing invalid names and trick the application into opening it.

There are no known instances of this vulnerability being actively exploited in the wild at the time of this report. However, it is still important to patch the affected package to prevent any potential future attacks.

For further support and assistance in remedying this vulnerability, you can reach out to info@devnack.com. Our team of experts will be happy to help you with the necessary steps to mitigate the issue.

Related vulnerabilities

Recent vulnerabilities recorded for stdlib.

How To Fix

Latest published version: go1.25.5 as of 22 Oct 2026

go get stdlib@vgo1.25.5

Upgrading to it may include breaking changes; the versions below are the minimum fixed release for this vulnerability.

If you can't move to the latest

The minimum fixed version depends on the release line you run.

  • < 1.16.10 1.16.10
    go get stdlib@v1.16.10
  • >= 1.17.0-0, < 1.17.3 1.17.3
    go get stdlib@v1.17.3

Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback