CVE-2021-4120

8.2 HIGH

📋 TL;DR

This vulnerability in snapd allows malicious snaps to bypass strict confinement by injecting arbitrary AppArmor policy rules through malformed content interface and layout declarations. It affects systems running snapd 2.54.2 and earlier versions. Attackers could potentially escape snap confinement and gain elevated privileges on affected systems.

💻 Affected Systems

Products:
  • snapd
Versions: snapd versions before 2.54.3+18.04, 2.54.3+20.04, and 2.54.3+21.10.1
Operating Systems: Ubuntu 18.04 LTS, Ubuntu 20.04 LTS, Ubuntu 21.10, Fedora Linux, Other Linux distributions using snapd
Default Config Vulnerable: ⚠️ Yes
Notes: Systems using snap packages with content interfaces and layouts are vulnerable. The vulnerability is in the snap confinement mechanism itself.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete system compromise through privilege escalation, allowing attackers to execute arbitrary code with elevated privileges, access sensitive data, and potentially pivot to other systems.

🟠

Likely Case

Local privilege escalation allowing malicious snaps to break out of confinement and access system resources they shouldn't have access to, potentially leading to data exfiltration or further system compromise.

🟢

If Mitigated

Limited impact with proper snap confinement and security policies in place, but still represents a significant security boundary violation.

🌐 Internet-Facing: MEDIUM - While exploitation typically requires local access, internet-facing systems with snap services could be targeted through other initial access vectors.
🏢 Internal Only: HIGH - Internal systems running vulnerable snapd versions are at significant risk from insider threats or compromised accounts.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires creating or modifying a malicious snap package with specific malformed declarations. Proof of concept details are available in security advisories.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: snapd 2.54.3+18.04, 2.54.3+20.04, or 2.54.3+21.10.1 and later

Vendor Advisory: https://ubuntu.com/security/notices/USN-5292-1

Restart Required: No

Instructions:

1. Update snapd using your distribution's package manager. 2. For Ubuntu: 'sudo apt update && sudo apt install snapd'. 3. For Fedora: 'sudo dnf update snapd'. 4. Verify the update completed successfully.

🔧 Temporary Workarounds

Disable snapd temporarily

linux

Temporarily disable snapd service to prevent exploitation while planning updates

sudo systemctl stop snapd
sudo systemctl disable snapd

Remove untrusted snaps

linux

Remove any untrusted or unnecessary snap packages to reduce attack surface

sudo snap list
sudo snap remove [untrusted-snap-name]

🧯 If You Can't Patch

  • Implement strict snap review and approval processes for all snap installations
  • Monitor system logs for unusual snap activity and implement network segmentation for systems running vulnerable snapd

🔍 How to Verify

Check if Vulnerable:

Check snapd version with 'snap version' or 'snapd --version' and compare against vulnerable versions

Check Version:

snap version | grep 'snapd'

Verify Fix Applied:

Verify snapd version is 2.54.3+18.04, 2.54.3+20.04, or 2.54.3+21.10.1 or later using 'snap version'

📡 Detection & Monitoring

Log Indicators:

  • Unusual snap installation or modification events
  • AppArmor policy violations or modifications related to snap confinement
  • System logs showing unexpected privilege escalation

Network Indicators:

  • Unexpected outbound connections from snap-confined processes
  • Network traffic patterns inconsistent with normal snap behavior

SIEM Query:

source="snapd" AND (event="install" OR event="refresh" OR event="remove") AND package_name="*malicious*" OR source="apparmor" AND event="DENIED" AND process="snap.*"

🔗 References

📤 Share & Export