xapp-sn-watcher: Validate client-supplied icon pixmaps - #210
Open
zquestz wants to merge 1 commit into
Open
Conversation
…on a bad IconPixmap type.
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.
Any application on the session bus can crash xapp-sn-watcher (and with it
every tray icon on the panel) by exporting a StatusNotifierItem whose
IconPixmap property has the wrong type.
get_icon_surface()unpacks the property like this:When a client sends any signature other than
a(iiay),g_variant_get()logs a critical and returns without touching
iter, so the NULL check readsan uninitialized stack slot and
g_variant_iter_loop()dereferences garbage.The same applies to AttentionIconPixmap and OverlayIconPixmap, which go
through the same function. The ToolTip handler already checks its type before
unpacking; the pixmap path does not.
This PR:
item and the offending type instead of crashing
(far above any real tray icon, far below anything that can overflow), and
the size arithmetic is done in gsize, so
width * height * 4can neitheroverflow a gint nor be truncated by
g_memdup()'s guint length argumentg_memdup2()on GLib >= 2.68, with the same version guard alreadyused in xapp-gpu-offload-helper.c
Reproduced against master by registering an SNI client whose IconPixmap is
declared and returned as
ay: the stock watcher segfaults as soon as itfetches properties, the patched watcher logs
and keeps running. Verified in a clean Ubuntu 24.04 environment on a private
session bus.
Found while investigating the tray instability Cinnamon users hit when
Signal and Slack shipped Electron 43.3.x/43.4.0 (electron/electron#52674,
signalapp/Signal-Desktop#7992). The Electron regression is fixed upstream in
43.4.1, but it demonstrated that one misbehaving client can take down the
whole tray; this closes the crash half of that. A follow-up PR addresses a
separate defect in how exiting clients' icons are removed.