Repository navigation
Open
Description
DirectConnection.listen() crashes with NPE in SASL.doResponse when peer is sd-bus
Summary
dbus-java server-side direct bus listener crashes with:
java.lang.NullPointerException
at java.text.RuleBasedCollator.compare
at org.freedesktop.dbus.connections.SASL.doResponse(SASL.java:369)
when the connecting peer is native sd-bus (C/libsystemd).
This looks like a null-handling bug in SASL response processing for AUTH EXTERNAL.
Environment
- dbus-java-core:
5.1.1 - dbus-java-transport-junixsocket:
5.1.1 - Java:
21.0.10 - OS: Linux x86_64 (
6.18.7-arch1-1) - Native peer:
libsystemd259
Minimal Reproducer
I created a standalone repro with:
- Java server:
DirectConnectionBuilder.forAddress("unix:path=...,listen=true").build(); connection.listen(); - C client using
sd-bus:sd_bus_newsd_bus_set_address("unix:path=...")sd_bus_start
Run:
./repro/dbus-java-sasl-npe/run-repro.shRepro files:
repro/dbus-java-sasl-npe/server/src/main/java/repro/DbusJavaServer.javarepro/dbus-java-sasl-npe/client/sd_bus_client.crepro/dbus-java-sasl-npe/run-repro.sh
Actual Result
Server exits with:
Exception in thread "main" java.lang.NullPointerException
at java.base/java.text.RuleBasedCollator.compare(RuleBasedCollator.java:359)
at org.freedesktop.dbus.connections.SASL.doResponse(SASL.java:369)
at org.freedesktop.dbus.connections.SASL.auth(SASL.java:625)
at org.freedesktop.dbus.connections.transports.AbstractTransport.authenticate(AbstractTransport.java:254)
at org.freedesktop.dbus.connections.transports.AbstractTransport.internalConnect(AbstractTransport.java:230)
at org.freedesktop.dbus.connections.transports.AbstractTransport.listen(AbstractTransport.java:215)
at org.freedesktop.dbus.connections.impl.DirectConnection.listen(DirectConnection.java:66)
at repro.DbusJavaServer.main(DbusJavaServer.java:47)
Expected Result
DirectConnection.listen() should not crash; it should either authenticate successfully or reject auth without throwing NPE.
Notes
In the D-Bus auth protocol, AUTH initial response is optional. A missing initial payload should be handled safely:
Metadata
Metadata
Assignees
Labels
No labels
Activity
Monkopedia commentedon Feb 15, 2026
I published the complete standalone reproducer as a public gist:
https://gist.github.com/Monkopedia/dbe1a170944c69c592aa2b75c41a019a
It contains the Java server, C sd-bus client, and run script from the issue description.
hypfvieh commentedon Feb 15, 2026
Thanks for the report, the provided details and the code to reproduce.
I updated the SASL code in dbus-java 5.x and 6.x to fix the NPE.
tory-kk commentedon Sep 10, 2026
Hello @hypfvieh,
We are facing the same issue with
github.com/godbus/dbus/v5 v5.2.2client.I can see that PR #295 was merged. However, it has not been released yet. Is there an estimated release date?
hypfvieh commentedon Sep 12, 2026
sorry, I forgot to create the release for 5.x 😢
I did the release now, I hope it works. As usual, it will take some time until it is published by Maven Central...
tory-kk commentedon Sep 21, 2026
Hello @hypfvieh,
Sorry for the delay, just tested version 5.2.1. The new version does not produce NPE, however, it seems incompatible with the newer approach for
AUTH_EXTERNALmessages where clients no longer senddatablock. I am referring togodbus/dbusclient (DBus for Golang) changes introduced in godbus/dbus@31b5df7Logs on the dbus-java side:
Are there any solutions for such a case?
hypfvieh commentedon Sep 21, 2026
I added a patch for 5x and 6x, you may try the most recent snapshot (6x only, sorry) or build the library from source. If this is working for you I can create another release for 5x.
tory-kk commentedon Sep 22, 2026
Tried
5.2.2-SNAPSHOTversion (built locally frommaster-5xbranch) - everything works as expected :)tory-kk commentedon Sep 25, 2026
@hypfvieh Could you please create a new release for the 5.x version?
hypfvieh commentedon Sep 26, 2026
@tory-kk release is on its way (takes some time as usual)