https://bugs.kde.org/show_bug.cgi?id=529244
Bug ID: 529244
Summary: D-Bus QKeySequence demarshaller reads 4 ints unchecked
— a short (ai) aborts kglobalaccel (and kwin_wayland
on Plasma 6)
Classification: Frameworks and Libraries
Product: frameworks-kglobalaccel
Version First unspecified
Reported In:
Platform: Ubuntu
OS: Linux
Status: REPORTED
Severity: crash
Priority: NOR
Component: general
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
Target Milestone: ---
ADDITIONAL INFORMATION
Note: this report was investigated and written by an AI assistant (Claude, via
Claude Code) and is submitted by me, Hugh Eisenman. I am happy to answer
follow-up questions or test patches.
SUMMARY
`operator>>(const QDBusArgument &, QKeySequence &)` in KGlobalAccel reads
exactly four ints from the `(ai)` struct without checking `atEnd()`. If a D-Bus
client sends a key sequence with fewer than 4 elements, which is valid per the
introspected signature `(ai)`, libdbus hits a check failure ("type invalid 0
not a basic type") and aborts the process. On Plasma 6 Wayland, kglobalacceld
runs inside kwin_wayland (libKGlobalAccelD imports this operator from
libKF6GlobalAccel), so a single unprivileged session-bus call takes down the
compositor and the whole session.
STEPS TO REPRODUCE (WARNING: this crashes kwin_wayland on a Plasma 6 Wayland
session)
gdbus call --session --dest org.kde.kglobalaccel --object-path /kglobalaccel
\
--method org.kde.KGlobalAccel.globalShortcutsByKey "([335544404],)" "(0,)"
OBSERVED
kwin_wayland (or standalone kglobalaccel5) prints:
dbus[PID]: type invalid 0 not a basic type
D-Bus not built with -rdynamic so unable to print a backtrace
and aborts with SIGABRT. The caller gets org.freedesktop.DBus.Error.NoReply.
EXPECTED
Either accept 1–4 element arrays (pad missing keys with 0), or reject the call
with a D-Bus error. Never abort.
WORKAROUND
Padding to four ints works: "([335544404,0,0,0],)". That is also the form the
daemon itself uses in replies, e.g. shortcutKeys returns ([k, 0, 0, 0],).
ANALYSIS
- Disassembly of `operator>>(QDBusArgument const&, QKeySequence&)` in both
libKF5GlobalAccel.so.5 (5.116.0) and libKF6GlobalAccel.so.6 (6.24.0) shows:
beginStructure, beginArray, then 4x QDBusArgument::operator>>(int&),
QKeySequence(int,int,int,int), endArray, endStructure. There is no atEnd()
loop.
- `nm -D libKGlobalAccelD.so.0` (6.6.5) shows that `operator>>(QDBusArgument
const&, QKeySequence&)` is imported (U), i.e. kwin's in-process daemon uses the
same code.
- Symbolized backtrace (kglobalaccel5, sandboxed reproduction on a private
dbus-run-session):
#10 abort()
#11 ?? libdbus-1.so.3
#12 _dbus_warn_check_failed() libdbus-1.so.3
#13 ?? libdbus-1.so.3
#14 QDBusArgument::operator>>(int&) const libQt5DBus.so.5
#15 operator>>(QDBusArgument const&, QKeySequence&) libKF5GlobalAccel.so.5
#16 QDBusMetaType::demarshall(QDBusArgument const&, int, void*)
libQt5DBus.so.5
... QDBusConnection dispatch / QCoreApplication::notifyInternal2
- The same call aborted the live kwin_wayland 6.6.6 (systemd-coredump, SIGABRT,
identical libdbus message). In a sandboxed test the 4-int form returned
normally and the 1-int form aborted.
- Any method taking QKeySequence / QList<QKeySequence> (globalShortcutsByKey,
setShortcutKeys, setForeignShortcutKeys, globalShortcutAvailable, ...) is
presumably affected.
SUGGESTED FIX
Read ints in a `while (!argument.atEnd())` loop inside beginArray/endArray,
keep at most 4 (ignore or reject extras), and default the rest to 0.
IMPACT
Same-user only (session bus), so not a privilege boundary. But on Plasma 6
Wayland any misbehaving or buggy session client, including scripts using
qdbus/gdbus by hand, can kill the compositor and lose unsaved work in every
application.
SOFTWARE/OS VERSIONS
Ubuntu 26.04.1 LTS (Kubuntu packages), Linux 7.0.0-38-generic, Wayland
KDE Plasma: kwin 6.6.6 (crash) / 6.6.7 (current); kglobalacceld 6.6.5
KDE Frameworks: 6.24.0 (libkf6globalaccel6 6.24.0-0ubuntu1); KF5 compat 5.116.0
Qt: 6.10.2
--
You are receiving this mail because:
You are watching all bug changes.