CVE-2021-40153
📋 TL;DR
This vulnerability in Squashfs-Tools allows directory traversal attacks during archive extraction. Attackers can craft malicious squashfs archives that write files outside the intended destination directory when unsquashfs processes them. Anyone using vulnerable versions of squashfs-tools to extract untrusted archives is affected.
💻 Affected Systems
- squashfs-tools
📦 What is this software?
Fedora by Fedoraproject
Fedora by Fedoraproject
Squashfs Tools by Squashfs Tools Project
⚠️ Risk & Real-World Impact
Worst Case
Arbitrary file write leading to remote code execution, system compromise, or data destruction by overwriting critical system files.
Likely Case
Local privilege escalation or arbitrary file write to sensitive locations when processing malicious archives.
If Mitigated
Limited to file writes within user's permissions if proper access controls exist, but still dangerous for privilege escalation.
🎯 Exploit Status
Exploitation requires creating a malicious squashfs archive with directory traversal sequences in filenames.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 4.5 with commit 79b5a555058eef4e1e7ff220c344d39f8cd09646 or later
Vendor Advisory: https://lists.debian.org/debian-lts-announce/2021/08/msg00030.html
Restart Required: No
Instructions:
1. Update squashfs-tools package using your distribution's package manager. 2. For Debian/Ubuntu: sudo apt update && sudo apt upgrade squashfs-tools. 3. For Fedora: sudo dnf update squashfs-tools. 4. For source installations: pull latest from GitHub and rebuild.
🔧 Temporary Workarounds
Extract as unprivileged user
linuxRun unsquashfs with minimal privileges to limit damage scope
sudo -u nobody unsquashfs archive.squashfs
Use container isolation
linuxExtract archives in isolated containers to prevent host system access
docker run --rm -v $(pwd):/data alpine unsquashfs /data/archive.squashfs
🧯 If You Can't Patch
- Only extract archives from trusted sources with verified integrity
- Run unsquashfs in chroot or containerized environments with restricted filesystem access
🔍 How to Verify
Check if Vulnerable:
Check squashfs-tools version: unsquashfs -version | grep 'version'
Check Version:
unsquashfs -version
Verify Fix Applied:
Verify version is 4.5 with patch or later, or test with known malicious archive that should now be rejected
📡 Detection & Monitoring
Log Indicators:
- Failed file writes outside expected directories
- unsquashfs processes with unusual arguments
Network Indicators:
- Downloads of squashfs archives followed by extraction processes
SIEM Query:
process.name='unsquashfs' AND file.path contains '../'
🔗 References
- https://bugs.launchpad.net/ubuntu/+source/squashfs-tools/+bug/1941790
- https://github.com/plougher/squashfs-tools/commit/79b5a555058eef4e1e7ff220c344d39f8cd09646
- https://github.com/plougher/squashfs-tools/issues/72
- https://lists.debian.org/debian-lts-announce/2021/08/msg00030.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GSMRKVJMJFX3MB7D3PXJSYY3TLZROE5S/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/RAOZ4BKWAC4Y3U2K5MMW3S77HWWXHQDL/
- https://security.gentoo.org/glsa/202305-29
- https://www.debian.org/security/2021/dsa-4967
- https://bugs.launchpad.net/ubuntu/+source/squashfs-tools/+bug/1941790
- https://github.com/plougher/squashfs-tools/commit/79b5a555058eef4e1e7ff220c344d39f8cd09646
- https://github.com/plougher/squashfs-tools/issues/72
- https://lists.debian.org/debian-lts-announce/2021/08/msg00030.html
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/GSMRKVJMJFX3MB7D3PXJSYY3TLZROE5S/
- https://lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/RAOZ4BKWAC4Y3U2K5MMW3S77HWWXHQDL/
- https://security.gentoo.org/glsa/202305-29
- https://www.debian.org/security/2021/dsa-4967