Skip to main content

CVE-2024-1724: Canonical Snapd Privilege Escalation Flaw

CVE-2024-1724 is a privilege escalation vulnerability in Canonical Snapd allowing attackers to escape sandbox confinement via $HOME/bin PATH manipulation. This article covers technical details, affected versions, and mitigation.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-1724 Overview

CVE-2024-1724 affects Canonical snapd versions prior to 2.62. The vulnerability allows a malicious snap using the home plug to escape the AppArmor sandbox by writing arbitrary scripts into the $HOME/bin directory. On Ubuntu systems, this directory is automatically added to the user's PATH when it exists. An attacker who convinces a user to install a crafted snap can plant executables that run outside the snap confinement when the user later invokes them from a shell.

Critical Impact

Successful exploitation enables sandbox escape and arbitrary code execution in the user's unconfined context, breaking the core snap confinement security boundary.

Affected Products

  • Canonical snapd versions prior to 2.62
  • Ubuntu distributions shipping vulnerable snapd packages
  • Any Linux distribution using snapd with AppArmor enforcement

Discovery Timeline

  • 2024-07-25 - CVE CVE-2024-1724 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-1724

Vulnerability Analysis

The flaw is an incorrect permission assignment ([CWE-732]) in the AppArmor profile generated for snaps that declare the home interface plug. The home plug is intended to grant snaps controlled access to non-hidden files in the user's home directory while blocking writes to directories that could be used for sandbox escape. The existing profile denied writes to files inside $HOME/bin/ but did not deny writes to the $HOME/bin directory entry itself, leaving a gap in enforcement.

On Ubuntu, the default ~/.profile adds $HOME/bin to the user's PATH when the directory exists. A malicious snap can create or populate $HOME/bin with executable scripts. The next time the user opens a shell and runs a common command, the planted script executes with the user's full privileges outside snap confinement.

Root Cause

The AppArmor rule set in interfaces/builtin/home.go denied writes to the glob @{HOME}/bin/{,**} but omitted a corresponding rule for the directory path @{HOME}/bin itself. This mismatch between path semantics in AppArmor allowed snaps with the home plug to create or modify the directory and populate it with scripts.

Attack Vector

Exploitation requires local access, low privileges, and user interaction. An attacker publishes or delivers a snap package that declares the home plug. Once the victim installs the snap, the snap writes attacker-controlled executables into $HOME/bin. When the user later invokes a command whose name matches a planted binary, the shell resolves it from $HOME/bin and executes it outside the snap sandbox.

go
// Security patch in interfaces/builtin/home.go
// Disallow writes to the well-known directory included in
// the user's PATH on several distributions
audit deny @{HOME}/bin/{,**} wl,
+audit deny @{HOME}/bin wl,

Source: snapd commit aa191f9. The patch adds an explicit audit deny rule for the $HOME/bin directory path, closing the gap that allowed snaps to create or modify the directory.

Detection Methods for CVE-2024-1724

Indicators of Compromise

  • Unexpected files or scripts appearing in $HOME/bin shortly after snap installations
  • Executable files in $HOME/bin with names shadowing common system commands such as ls, sudo, or git
  • Snap packages requesting the home plug from untrusted publishers

Detection Strategies

  • Audit the AppArmor logs under /var/log/audit/audit.log for apparmor="DENIED" entries referencing @{HOME}/bin write operations
  • Monitor file creation events in user home directories correlated with snapd or snap application process ancestry
  • Inventory installed snaps and flag any declaring the home interface plug from unverified publishers

Monitoring Recommendations

  • Enable file integrity monitoring on $HOME/bin directories across managed Linux endpoints
  • Alert on process executions where the resolved binary path is $HOME/bin/* and the parent is a login shell
  • Track snap install command invocations and the plugs each installed snap connects

How to Mitigate CVE-2024-1724

Immediate Actions Required

  • Upgrade snapd to version 2.62 or later on all affected systems
  • Audit the contents of $HOME/bin on every user account and remove unexpected scripts
  • Review connected snap interfaces using snap connections and disconnect home plugs from untrusted snaps

Patch Information

The fix is included in snapd 2.62 via pull request #13689 and commit aa191f9. The patch adds an AppArmor rule denying writes to the $HOME/bin directory itself, complementing the existing rule covering its contents. For technical background, see the McPhail blog post explaining CVE-2024-1724.

Workarounds

  • Remove or empty $HOME/bin and modify ~/.profile to prevent its addition to PATH until patching is complete
  • Restrict snap installations to signed packages from trusted publishers via organizational policy
  • Disconnect the home plug from any installed snap that does not require home directory access using snap disconnect <snap>:home
bash
# Update snapd to the patched version
sudo snap refresh snapd
snap version

# Review and disconnect the home plug from untrusted snaps
snap connections | grep ':home '
sudo snap disconnect <snap-name>:home

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.