You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Assuming the situation where we want extract an docker image. This image contains all files, directories and symlinks that an operating system would contain.
Taking the ubuntu:latest as an example. The extraction will fail, bc/ the directory stucture contains symlinks that points to the root filesystem:
The extraction of root/escaped_file would be blocked.
To ensure that go-extract will not be vulnerable to a link-write attack, the sanity check for file overwrite need to be adjusted. Before the call to target.CreateFile is performed, we need to check if the target exist, is a symlink (with fi, err := target.Lstat; err == nil && fi.Mode & os.ModeSymlink != 0) and if following symlinks (config.FollowSymlinks() == true) is enabled.
By offering this feature, we can still extract archives, but puts the burden on the consumer to ensure that they are aware of the possible consumption of symlinks that point to arbitrary locations in the file system
The text was updated successfully, but these errors were encountered:
NodyHub
changed the title
Feature: Extraction of symlinks with absolut path as link destination
Feature: Safe extraction of symlinks with absolut path (/<whatever>) as link target
Aug 1, 2024
Assuming the situation where we want extract an docker image. This image contains all files, directories and symlinks that an operating system would contain.
Taking the
ubuntu:latest
as an example. The extraction will fail, bc/ the directory stucture contains symlinks that points to the root filesystem:Offering extraction of symlinks with absolut paths does not poses go-extract to be vulnerable to arbitrary file writes in the filesystem.
Assuming the situation that an archive contains following files:
% tar -ztvf malformed.tar lrw------- 0 0 0 0 1 Jan 1970 root -> / -rw------- 0 0 0 13 1 Jan 1970 root/escaped_file
The symlink
root -> /
would be extracted, but go-extract prevents arbitrary writes by inventing the optionconfig.FollowSymlinks()
.go-extract/extractor/target.go
Lines 240 to 251 in ffdb27f
The extraction of
root/escaped_file
would be blocked.To ensure that go-extract will not be vulnerable to a link-write attack, the sanity check for file overwrite need to be adjusted. Before the call to
target.CreateFile
is performed, we need to check if the target exist, is a symlink (withfi, err := target.Lstat; err == nil && fi.Mode & os.ModeSymlink != 0
) and if following symlinks (config.FollowSymlinks() == true
) is enabled.By offering this feature, we can still extract archives, but puts the burden on the consumer to ensure that they are aware of the possible consumption of symlinks that point to arbitrary locations in the file system
The text was updated successfully, but these errors were encountered: