CVE-2026-40354 Overview
CVE-2026-40354 is a symlink attack vulnerability in Flatpak xdg-desktop-portal that allows any Flatpak application to trash arbitrary files in the host context. The vulnerability exists in versions prior to 1.20.4 and versions 1.21.x before 1.21.1, where improper handling of symbolic links in the g_file_trash function enables malicious sandboxed applications to escape containment and delete files on the host system.
Critical Impact
A malicious Flatpak application can leverage symlink manipulation to delete arbitrary files on the host system, potentially leading to data loss or denial of service conditions by removing critical system or user files.
Affected Products
- Flatpak xdg-desktop-portal versions before 1.20.4
- Flatpak xdg-desktop-portal versions 1.21.x before 1.21.1
Discovery Timeline
- April 11, 2026 - CVE-2026-40354 published to NVD
- April 13, 2026 - Last updated in NVD database
Technical Details for CVE-2026-40354
Vulnerability Analysis
This vulnerability is classified under CWE-61 (UNIX Symbolic Link (Symlink) Following), a category of file system vulnerabilities where an application follows symbolic links without proper validation. In the context of xdg-desktop-portal, the issue arises within the g_file_trash function, which is responsible for moving files to the system trash.
The flaw allows a sandboxed Flatpak application—which should have limited filesystem access—to craft a symbolic link pointing to an arbitrary file on the host system. When the portal service processes a trash request for this symlink, it follows the link and moves the target file to the trash instead of the symlink itself. This effectively allows the sandboxed application to delete any file accessible to the portal service, breaking the security boundaries that Flatpak is designed to enforce.
The vulnerability requires local access and has high attack complexity, as the attacker must successfully create and manipulate symlinks in a manner that exploits the race condition or improper validation in the trash operation.
Root Cause
The root cause of CVE-2026-40354 lies in insufficient validation of file paths before performing the trash operation. The g_file_trash function follows symbolic links without verifying that the resolved target path remains within the permitted scope of the requesting Flatpak application. This design oversight enables a Time-of-Check Time-of-Use (TOCTOU) style attack where the symlink can be manipulated between validation and the actual file operation.
Attack Vector
The attack requires local access to the system where a vulnerable version of xdg-desktop-portal is installed. An attacker would need to install or run a malicious Flatpak application that:
- Creates a symbolic link within its sandbox pointing to a target file on the host filesystem
- Requests the xdg-desktop-portal service to trash the symbolic link
- The portal service follows the symlink and moves the actual target file to trash
The vulnerability mechanism involves the improper handling of symbolic links in the g_file_trash function. When a Flatpak application requests to trash a file, the portal service should verify that the operation stays within the application's permitted sandbox boundaries. However, due to improper symlink resolution, the service follows symbolic links to their targets, allowing operations on files outside the sandbox.
For detailed technical information, refer to the GitHub Security Advisory GHSA-rqr9-jwwf-wxgj and the Openwall OSS-Security Discussion.
Detection Methods for CVE-2026-40354
Indicators of Compromise
- Unexpected file deletions or files appearing in system trash without user interaction
- Flatpak applications creating symbolic links pointing to sensitive system or user files
- Unusual activity in xdg-desktop-portal logs related to trash operations
Detection Strategies
- Monitor xdg-desktop-portal service logs for trash operations involving symbolic links
- Implement file integrity monitoring on critical system files to detect unauthorized deletions
- Audit installed Flatpak applications for unexpected symlink creation behavior
Monitoring Recommendations
- Enable verbose logging for xdg-desktop-portal to capture detailed information about file operations
- Deploy endpoint detection solutions that can identify symlink-based attacks within sandbox environments
- Regularly review trash contents for files that should not have been deleted by sandboxed applications
How to Mitigate CVE-2026-40354
Immediate Actions Required
- Update xdg-desktop-portal to version 1.20.4 or later for the 1.20.x branch
- Update xdg-desktop-portal to version 1.21.1 or later for the 1.21.x branch
- Review recently installed Flatpak applications for suspicious behavior
- Implement backup procedures for critical files until patching is complete
Patch Information
Security patches are available through the official xdg-desktop-portal releases:
- xdg-desktop-portal version 1.20.4 - Patches the vulnerability for the stable 1.20.x branch
- xdg-desktop-portal version 1.21.1 - Patches the vulnerability for the 1.21.x development branch
Users should update through their distribution's package manager or build from source using the patched releases. For additional details on the security fix, consult the GitHub Security Advisory.
Workarounds
- Limit the use of untrusted Flatpak applications until patched versions are deployed
- Review and restrict Flatpak permissions using tools like Flatseal to minimize filesystem access
- Consider temporarily disabling the trash portal functionality if critical systems are at risk
# Check current xdg-desktop-portal version
pkg-config --modversion xdg-desktop-portal
# Update via package manager (example for Fedora/RHEL-based systems)
sudo dnf update xdg-desktop-portal
# Update via package manager (example for Debian/Ubuntu-based systems)
sudo apt update && sudo apt upgrade xdg-desktop-portal
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

