Skip to content

fix(security): sanitize icon candidates and restrict icon sources to trusted directories - #3

Merged
Codesmith28 merged 1 commit into
masterfrom
fix/sanitize-icon-candidates
Oct 16, 2026
Merged

Codesmith28 merged 1 commit into
masterfrom
fix/sanitize-icon-candidates

Conversation

@Codesmith28

Copy link
Copy Markdown
Owner

Description

This PR fixes a security vulnerability where client-controlled Wayland window properties (app_id / clientClass and window title) could inject arbitrary filesystem paths and file:// URIs into the icon resolution pipeline.

When unvalidated candidates were passed to shellAppLib.iconSource(), file:// paths could be returned to WindowTile.qml and FooterBar.qml, triggering Qt's image decoders to decode untrusted files. Opening the switcher could thereby decompress client-crafted PNG files with unbounded ancillary text chunks (zTXt / iTXt), causing memory exhaustion and crashing the shared desktop shell process.

Changes

  1. Candidate Validation (isValidIconCandidate):

    • Rejects directory separators (/, \\), URI schemes (:, ://), traversal (..), null bytes (\0), control characters, and leading/trailing dots or dashes.
    • Rejects image file extensions (.png, .svg, .xpm, etc.) because theme candidates must be icon names, not disk filenames.
    • Enforces FreeDesktop identifier character constraints (/^[a-zA-Z0-9_\-\.]+$/) with a 128-character limit.
  2. Trusted Source Verification (isSafeIconSource):

    • Permits internal QML image providers (image://icon/...) and Qt resources (qrc:/...).
    • Validates that file:// URIs and disk paths point exclusively to trusted system/user icon locations (/usr/share/icons/, /usr/share/pixmaps/, ~/.local/share/icons/, Flatpak/Snap icon paths, etc.).
    • Explicitly blocks dangerous locations (/tmp/, /var/tmp/, /dev/, /proc/, /sys/, and path traversal).
  3. Resolver Hardening (queryPath and save):

    • queryPath verifies input names and ensures returned paths from iconIndex, quickshell.iconPath, or shellAppLib.iconSource satisfy isSafeIconSource.
    • Native theme probing in Step 5 skips any non-candidate string.
    • save() acts as an output gatekeeper, ensuring unverified paths are never cached or returned to Image.source.
  4. Automated Security Tests:

    • Added Test 20 in tests/test_logic.js covering candidate sanitization, path restriction, and verifying that untrusted client inputs (/tmp/exploit.png, file:///..., traversal, etc.) safely fall back to application-x-executable. All 20 tests pass.

…trusted directories

- Validate icon candidates in js/Icons.js using isValidIconCandidate to reject path traversal, directory separators, URI schemes, and file extensions
- Validate icon sources in isSafeIconSource to restrict filesystem paths to trusted system and user icon directories
- Harden queryPath and fallback icon probing to avoid passing unvalidated candidates to shellAppLib.iconSource
- Add Test 20 to tests/test_logic.js to verify candidate sanitization and decompression bomb defense
Copilot AI balanced review requested due to automatic review settings October 16, 2026 05:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Codesmith28
Codesmith28 merged commit cc723ef into master Oct 16, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants