xpra icon indicating copy to clipboard operation
xpra copied to clipboard

xpra shadow :0 fails to connect to X server before user logs into X session :0

Open basilgello opened this issue 3 years ago • 7 comments

I recall I tested this before, but I doubt I did xpra shadow right after system restart.

Issue is, Xsession adds the user currently logged to xauth authorization list. So xpra shadow :0 run as uid 1000 works with uid 1000's MIT-X-Cookie. However, when Xpra remote client asks the Xpra proxy server to start Xpra shadow server under the uid who is not logged into X session at the moment (i.e not in xauth list), Xpra shadow server fails to connect Xvfb to :0 and exits dirty, and remote client times out.

I am not sure how to handle this issue securely. I guess, when user authentication is complete, we need to check if Xpra shadow can attach to X0. If user can not attach, and user is in video group and no other user is logged into target X server session, Xpra must steal the lightdm cookie from /var/lib/lightm and pass it to Xvfb running under user nobody (not root or target user because this can lead to cookie exposure).

@totaam ?

basilgello avatar Aug 24 '21 13:08 basilgello

IIRC, the key problem here is finding the correct $XAUTHORITY to use. We do try to add ourselves to this file: https://github.com/Xpra-org/xpra/blob/8fe130a3c6ed70d32d298ce386c3a0c2856bf1fb/xpra/scripts/server.py#L985-L1011

Perhaps adding or shadowing to this code block would be enough?

totaam avatar Aug 24 '21 14:08 totaam

Perhaps adding or shadowing to this code block would be enough?

Let me try :)

No, does not work. Let me figure out how do I check the correct XAUTHORITY then.

basilgello avatar Aug 24 '21 14:08 basilgello

Did you figure out which XAUTHORITY to use to make this work?

totaam avatar Nov 05 '21 14:11 totaam

Yes! I will need to doing a PoC. The only reliable way is to get pid of process serving the socket and parse its cmdline to get path to xauthority file…

basilgello avatar Nov 05 '21 14:11 basilgello

@basilgello And the answer was? XAUTHORITY=???

totaam avatar Apr 26 '22 15:04 totaam

@totaam /var/run/lightdm/Xauthority-root. But let me explain the detectiin logic or PR it next morning

basilgello avatar Apr 26 '22 16:04 basilgello

Bump

totaam avatar Jul 12 '22 13:07 totaam