CVE-2024-42472
CVE-2024-42472
Weakness (CWE)
CVSS Vector
v3.1- Attack Vector
- Network
- Attack Complexity
- Low
- Privileges Required
- None
- User Interaction
- None
- Scope
- Changed
- Confidentiality
- High
- Integrity
- High
- Availability
- None
Description
Flatpak is a Linux application sandboxing and distribution framework. Prior to versions 1.14.0 and 1.15.10, a malicious or compromised Flatpak app using persistent directories could access and write files outside of what it would otherwise have access to, which is an attack on integrity and confidentiality. When `persistent=subdir` is used in the application permissions (represented as `--persist=subdir` in the command-line interface), that means that an application which otherwise doesn't have access to the real user home directory will see an empty home directory with a writeable subdirectory `subdir`. Behind the scenes, this directory is actually a bind mount and the data is stored in the per-application directory as `~/.var/app/$APPID/subdir`. This allows existing apps that are not aware of the per-application directory to still work as intended without general home directory access. However, the application does have write access to the application directory `~/.var/app/$APPID` where this directory is stored. If the source directory for the `persistent`/`--persist` option is replaced by a symlink, then the next time the application is started, the bind mount will follow the symlink and mount whatever it points to into the sandbox. Partial protection against this vulnerability can be provided by patching Flatpak using the patches in commits ceec2ffc and 98f79773. However, this leaves a race condition that could be exploited by two instances of a malicious app running in parallel. Closing the race condition requires updating or patching the version of bubblewrap that is used by Flatpak to add the new `--bind-fd` option using the patch and then patching Flatpak to use it. If Flatpak has been configured at build-time with `-Dsystem_bubblewrap=bwrap` (1.15.x) or `--with-system-bubblewrap=bwrap` (1.14.x or older), or a similar option, then the version of bubblewrap that needs to be patched is a system copy that is distributed separately, typically `/usr/bin/bwrap`. This configuration is the one that is typically used in Linux distributions. If Flatpak has been configured at build-time with `-Dsystem_bubblewrap=` (1.15.x) or with `--without-system-bubblewrap` (1.14.x or older), then it is the bundled version of bubblewrap that is included with Flatpak that must be patched. This is typically installed as `/usr/libexec/flatpak-bwrap`. This configuration is the default when building from source code. For the 1.14.x stable branch, these changes are included in Flatpak 1.14.10. The bundled version of bubblewrap included in this release has been updated to 0.6.3. For the 1.15.x development branch, these changes are included in Flatpak 1.15.10. The bundled version of bubblewrap in this release is a Meson "wrap" subproject, which has been updated to 0.10.0. The 1.12.x and 1.10.x branches will not be updated for this vulnerability. Long-term support OS distributions should backport the individual changes into their versions of Flatpak and bubblewrap, or update to newer versions if their stability policy allows it. As a workaround, avoid using applications using the `persistent` (`--persist`) permission.
Comprehensive Technical Analysis of CVE-2024-42472
1. Vulnerability Assessment and Severity Evaluation
CVE ID: CVE-2024-42472 CVSS Score: 10
Severity Evaluation: The CVSS score of 10 indicates a critical vulnerability. This score reflects the high impact on both integrity and confidentiality, as well as the ease of exploitation. The vulnerability allows a malicious or compromised Flatpak application to access and write files outside its intended sandbox, potentially leading to unauthorized data access, modification, or deletion.
2. Potential Attack Vectors and Exploitation Methods
Attack Vectors:
- Symlink Attack: An attacker could replace the source directory for the
persistent/--persistoption with a symlink pointing to a sensitive directory. When the application is restarted, the bind mount will follow the symlink, granting the application access to the targeted directory. - Race Condition: If two instances of a malicious application run in parallel, they could exploit a race condition to manipulate the bind mount process, further compromising the system.
Exploitation Methods:
- Local Privilege Escalation: An attacker with local access could exploit this vulnerability to escalate privileges by manipulating the bind mounts to access sensitive system files or user data.
- Data Exfiltration: By redirecting the bind mount to a directory containing sensitive information, an attacker could exfiltrate data from the system.
3. Affected Systems and Software Versions
Affected Software:
- Flatpak versions prior to 1.14.0 and 1.15.10
Affected Systems:
- Linux distributions using Flatpak for application sandboxing and distribution.
- Systems where Flatpak applications are configured to use the
persistent/--persistoption.
4. Recommended Mitigation Strategies
Immediate Mitigation:
- Avoid Using
persistent/--persist: As a workaround, avoid using applications that require thepersistent/--persistpermission until the vulnerability is patched.
Long-Term Mitigation:
- Update Flatpak: Upgrade to Flatpak versions 1.14.10 or 1.15.10, which include patches for this vulnerability.
- Patch Bubblewrap: Ensure that the version of bubblewrap used by Flatpak is updated to include the necessary patches. This may involve updating the system copy of bubblewrap or the bundled version, depending on the build configuration.
- Backport Patches: For long-term support OS distributions, backport the individual changes into their versions of Flatpak and bubblewrap, or update to newer versions if stability policies allow.
5. Impact on Cybersecurity Landscape
Impact:
- Widespread Use of Flatpak: Given the widespread use of Flatpak in Linux distributions, this vulnerability poses a significant risk to a large number of systems.
- Sandbox Integrity: The vulnerability undermines the integrity of the sandboxing mechanism, which is a critical component of modern application security.
- Data Confidentiality: The potential for unauthorized data access and modification highlights the importance of robust sandboxing and permission management in application security.
6. Technical Details for Security Professionals
Technical Overview:
- Bind Mount Mechanism: The vulnerability exploits the bind mount mechanism used by Flatpak to provide persistent directories. When a symlink is used instead of a regular directory, the bind mount follows the symlink, granting the application access to the targeted directory.
- Race Condition: The race condition arises from the possibility of two instances of a malicious application running in parallel and manipulating the bind mount process.
Patch Details:
- Partial Patch: Commits ceec2ffc and 98f7973 provide partial protection by addressing the symlink issue but leave the race condition unresolved.
- Full Patch: To fully mitigate the vulnerability, the version of bubblewrap used by Flatpak must be updated to include the
--bind-fdoption, and Flatpak must be patched to use this option.
References:
Conclusion:
CVE-2024-42472 represents a critical vulnerability in Flatpak that can be exploited to compromise the integrity and confidentiality of sandboxed applications. Immediate mitigation strategies include avoiding the use of the persistent/--persist option and updating to patched versions of Flatpak and bubblewrap. The cybersecurity community should prioritize addressing this vulnerability to maintain the security of Linux systems using Flatpak.