Repository navigation
fix(security): sanitize icon candidates and restrict icon sources to trusted directories - #3
Merged
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a security vulnerability where client-controlled Wayland window properties (
app_id/clientClassand windowtitle) could inject arbitrary filesystem paths andfile://URIs into the icon resolution pipeline.When unvalidated candidates were passed to
shellAppLib.iconSource(),file://paths could be returned toWindowTile.qmlandFooterBar.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
Candidate Validation (
isValidIconCandidate):/,\\), URI schemes (:,://), traversal (..), null bytes (\0), control characters, and leading/trailing dots or dashes..png,.svg,.xpm, etc.) because theme candidates must be icon names, not disk filenames./^[a-zA-Z0-9_\-\.]+$/) with a 128-character limit.Trusted Source Verification (
isSafeIconSource):image://icon/...) and Qt resources (qrc:/...).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.)./tmp/,/var/tmp/,/dev/,/proc/,/sys/, and path traversal).Resolver Hardening (
queryPathandsave):queryPathverifies input names and ensures returned paths fromiconIndex,quickshell.iconPath, orshellAppLib.iconSourcesatisfyisSafeIconSource.save()acts as an output gatekeeper, ensuring unverified paths are never cached or returned toImage.source.Automated Security Tests:
Test 20intests/test_logic.jscovering candidate sanitization, path restriction, and verifying that untrusted client inputs (/tmp/exploit.png,file:///..., traversal, etc.) safely fall back toapplication-x-executable. All 20 tests pass.