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

Fix hardening measure in release extraction #55

Merged
merged 1 commit into from
Dec 9, 2024

Conversation

grembo
Copy link
Contributor

@grembo grembo commented Dec 8, 2024

In #49 a hardening measure was imported from truenas/iocage#358. This hardening measure limits what can be extracted (location and attributes). It is implemented by applying the 'tar' filter from tarfile. That filter does this[0]:

  • Strip leading slashes (/ and os.sep) from filenames.
  • Refuse to extract files with absolute paths (in case the name is absolute even after stripping slashes, e.g. C:/foo on Windows). This raises AbsolutePathError.
  • Refuse to extract files whose absolute path (after following symlinks) would end up outside the destination. This raises OutsideDestinationError.
  • Clear high mode bits (setuid, setgid, sticky) and group/other write bits (S_IWGRP | S_IWOTH).

While the first three modifications are desirable, the last one damages the extracted release image, as things like sticky bits and world writable files are required by a proper FreeBSD (jail) installation.

Fixes #54

[0]https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter

Make sure to follow and check these boxes before submitting a PR! Thank you.

In freebsd#49 a hardening measure was imported from
truenas/iocage#358. This hardening measure limits what
can be extracted (location and attributes). It is implemented by
applying the 'tar' filter from tarfile. That filter does this[0]:

- Strip leading slashes (/ and os.sep) from filenames.
- Refuse to extract files with absolute paths (in case the name is
  absolute even after stripping slashes, e.g. C:/foo on Windows). This
  raises AbsolutePathError.
- Refuse to extract files whose absolute path (after following symlinks)
  would end up outside the destination. This raises
  OutsideDestinationError.
- Clear high mode bits (setuid, setgid, sticky) and group/other write
  bits (S_IWGRP | S_IWOTH).

While the first three modifications are desirable, the last one
damages the extracted release image, as things like sticky bits and
world writable files are required by a proper FreeBSD (jail)
installation.

Fixes freebsd#54

[0]https://docs.python.org/3/library/tarfile.html#tarfile-extraction-filter
@coveralls
Copy link

coveralls commented Dec 8, 2024

Pull Request Test Coverage Report for Build 12223403055

Details

  • 0 of 15 (0.0%) changed or added relevant lines in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.02%) to 7.733%

Changes Missing Coverage Covered Lines Changed/Added Lines %
iocage_lib/ioc_fetch.py 0 15 0.0%
Files with Coverage Reduction New Missed Lines %
iocage_lib/release.py 1 0.0%
Totals Coverage Status
Change from base Build 12088701378: -0.02%
Covered Lines: 799
Relevant Lines: 7815

💛 - Coveralls

freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Dec 8, 2024
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Dec 8, 2024
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Dec 8, 2024
freebsd-git pushed a commit to freebsd/freebsd-ports that referenced this pull request Dec 8, 2024
@dgeo dgeo merged commit a5066c6 into freebsd:master Dec 9, 2024
2 checks passed
@dgeo dgeo added this to the 1.10 milestone Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

iocage-fetch loses some release permissions
3 participants