CVE-2021-21272: Zip slip directory exploit in github.com/deislabs/oras
Summary
CVE-2021-21272: Zip slip directory exploit in github.com/deislabs/oras. Affects github.com/deislabs/oras versions < 0.9.0. Fixed in 0.9.0. How to fix ↓
Also tracked for
- oras · Bitnami
The same CVE-2021-21272 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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.
No signup required · Results in about 60 seconds
Background
The package under scrutiny is github.com/deislabs/oras, which is written in Go. It is a content-addressable artifact registry for storing and retrieving artifacts. The package provides functionalities for working with OCI (Open Container Initiative) images and other artifact types. The vulnerability in this package allows for a directory traversal exploit during archive extraction, specifically when using the pkg/content.FileStore content store. This vulnerability enables a malicious archive to write paths to arbitrary locations that the process can write to.
Vulnerability Detail
The vulnerability arises due to improper path validation in the content.FileStore content store of github.com/deislabs/oras. This allows an attacker to craft a malicious archive that can traverse directories and write files to arbitrary paths that the process has write access to. The impact of this vulnerability can be severe, as it can lead to unauthorized modification or deletion of files, potential code execution, and privilege escalation if the process has elevated privileges. It is important to note that this vulnerability affects versions prior to 0.9.0 of the package.
How To Fix
Minimum fixed version
0.9.0
This is the first release that contains the fix.
go get github.com/deislabs/oras@v0.9.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
As a workaround, if updating the package is not immediately feasible, it is recommended to exercise caution when extracting archives using the content.FileStore content store. Ensure that the extracted paths are properly validated and restricted to the intended directories. Implementing additional path validation checks can help mitigate the risk of directory traversal exploits.
Conclusion
In conclusion, the github.com/deislabs/oras package is vulnerable to a directory traversal exploit during archive extraction. This can lead to unauthorized modification or deletion of files, potential code execution, and privilege escalation. It is crucial to update to version 0.9.0 or later of the package to mitigate this vulnerability. If immediate update is not feasible, exercise caution when extracting archives and implement additional path validation checks. For further support on vulnerability remediation, please contact DevNack.com.
See every vulnerability recorded for github.com/deislabs/oras →
FAQ
The impact of this vulnerability can be severe, as it allows for unauthorized modification or deletion of files, potential code execution, and privilege escalation if the process has elevated privileges.
Versions prior to 0.9.0 of github.com/deislabs/oras are affected by this vulnerability.
To fix this vulnerability, update the github.com/deislabs/oras package to version 0.9.0 or later.
As a workaround, exercise caution when extracting archives using the content.FileStore content store and implement additional path validation checks.
Here is an example code snippet that demonstrates the vulnerability:
package main
import (
"github.com/deislabs/oras/pkg/content"
"os"
)
func main() {
archivePath := "/path/to/malicious/archive.zip"
extractPath := "/path/to/extract"
fileStore := content.NewFileStore(extractPath)
fileStore.Extract(archivePath)
}