Skip to content
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

Add hardening measures on untar #49

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion iocage_lib/ioc_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
from iocage_lib.pools import Pool
from iocage_lib.dataset import Dataset

# deliberately crash if tarfile doesn't have required filter
tarfile.tar_filter


class IOCFetch:

Expand Down Expand Up @@ -817,7 +820,7 @@ def fetch_extract(self, f):
# removing them first.
member = self.__fetch_extract_remove__(f)
member = self.__fetch_check_members__(member)
f.extractall(dest, members=member)
f.extractall(dest, members=member, filter='tar')

def fetch_update(self, cli=False, uuid=None):
"""This calls 'freebsd-update' to update the fetched RELEASE."""
Expand Down
5 changes: 4 additions & 1 deletion iocage_lib/ioc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
GIT_LOCK = threading.Lock()
RE_PLUGIN_VERSION = re.compile(r'"path":"([/\.\+,\d\w-]*)\.txz"')

# deliberately crash if tarfile doesn't have required filter
tarfile.tar_filter


class IOCPlugin(object):

Expand Down Expand Up @@ -157,7 +160,7 @@ def download_parse_packagesite(packagesite_url):
shutil.copyfileobj(r.raw, f)

with tarfile.open(packagesite_txz_path) as p_file:
p_file.extractall(path=tmpdir)
p_file.extractall(path=tmpdir, filter='data')

packagesite_path = os.path.join(tmpdir, 'packagesite.yaml')
if not os.path.exists(packagesite_path):
Expand Down
Loading