Closed koo5 closed 3 years ago
Thanks for spotting. Fixed with dfab7f0bbeb00bc7cce467220fcb8f72cbf634a3 (avoid sscanf() in the test and use snprintf() for the message). Note that this is not a real security issue. It only triggers if you have a ridiculously long value for $DISPLAY
. If something manages to manipulate DISPLAY and start swipl the security is already breached.
In practice i agree, but in theory, i can imagine people start using some new fancy cloud linux desktop service that embeds a token in there, for example. Anyway, thanks.
This function doesn't do what it says.
https://www.x.org/archive/X11R6.8.1/doc/X.7.html says:
our sscanf string is:
"%[a-zA-Z0-9.]:%d.%d"
http://www.cplusplus.com/reference/cstdio/scanf/ says:
therefore, our sscanf string requires a host, which is wrong. It's actually usual that host is omitted, and this test leads to misleading error message:
(https://github.com/SWI-Prolog/packages-xpce/blob/master/src/x11/xdisplay.c#L233)
also note that the maximum number of characters read into
host
is not limited by LINESIZE, so this could in theory lead to memory corruption.The original problem is obviously hard to fix with sscanf.
Shall we instead do:
sprintf(problem, "Malformed address: %s, or no permission to contact X-server?", theaddress);