Skip to main content
CVE Vulnerability Database
Vulnerability Database/CVE-2026-40354

CVE-2026-40354: Flatpak Path Traversal Vulnerability

CVE-2026-40354 is a path traversal flaw in Flatpak xdg-desktop-portal that allows apps to trash host files via symlink attacks. This article covers the technical details, affected versions, security impact, and patches.

Published:

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:

  1. Creates a symbolic link within its sandbox pointing to a target file on the host filesystem
  2. Requests the xdg-desktop-portal service to trash the symbolic link
  3. 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:

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
bash
# 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.

Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

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.