XRDP smartcard passthrough via windows RDP client #2625
Replies: 25 comments 38 replies
-
Couple of things:-
|
Beta Was this translation helpful? Give feedback.
-
I've been researching xrdp smartcard support, and I'm a bit confused about what's being asked here. My current understanding is: xrdp does have smartcard support -- if I dig into the codebase I see what looks like an implementation of MS-RDPESC. However I also see questions like this, and long-open PRs like #963 and #1825. From what I can tell, these are asking for support for passing smartcard through to/from PCSC over a socket. Is this understanding correct? Or is there some important context that I'm missing? Thanks in advance for anybody who can help to clarify. |
Beta Was this translation helpful? Give feedback.
-
Funnily enough I'm just starting to look at this. I wasn't involved with the original development, but my understanding of the situation is as follows:-
That's the history. Here are some other points:-
While I'm waiting for some other changes to get merged I'll pick this up and see how far I can get with it. |
Beta Was this translation helpful? Give feedback.
-
I am not sure to understand what you are trying to do. Maybe I can help? |
Beta Was this translation helpful? Give feedback.
-
@matt335672 ASCII should be enough. |
Beta Was this translation helpful? Give feedback.
-
Small update - there are a few dragons around using the LD_LIBRARY_PATH in a session. See for example, Debian BTS #711623. There are, as ever, workarounds but they may be quite specific. For now, I'm providing an I see also from this bug report that other commercial software is using this approach. |
Beta Was this translation helpful? Give feedback.
-
In another discussion I proposed that the RDP server implements and replaces libpcsclite.so.1 to solve this problem. The side effect is that it would not be possible to install xrdp and libpcsclite (from pcsc-lite) at the same time on the system. The 2 packages would conflict with each other. I don't know if you have a use case with a RDP server that have a locally connected smart card reader and would need pcsc-lite installed on the server. |
Beta Was this translation helpful? Give feedback.
-
OK I see the use case. For example see how the PC/SC spy works https://blog.apdu.fr/posts/2022/06/pcsc-api-spy-update/ |
Beta Was this translation helpful? Give feedback.
-
That looks really useful - thanks. I can see what's happening there. xrdp has to support a large number of combinations of desktops and their supporting environments. Because using LD_LIBRARY_PATH has security implications, I can see that using LD_LIBRARY_PATH is going to result in a steady trickle of support calls as security postures and attitudes evolve over time. I think your approach is more complex to implement, but it's going to be a lot easier to support in the long run. That's just my opinion though. Anyone else got any comments? @CendioOssman - is any of this any use to you? I see you have some experiences in this area. |
Beta Was this translation helpful? Give feedback.
-
I have not been involved with any xrdp stuff, so I'm not sure how I got connected here. :) But we do something similar to what you discuss here in ThinLinc, using LD_LIBRARY_PATH. Having a more clean multiplexer between PC/SC libraries would definitely be interesting to us. |
Beta Was this translation helpful? Give feedback.
-
I opened an issue at PCSC project to discuss what can be done in pcsc-lite: Delegate WinSCard calls to another libray (for a RDP server for example) #161 |
Beta Was this translation helpful? Give feedback.
-
My comments here as I did most of the work on what we have now. No one likes the replace method so I worked on the pcscd standin. To describe how the pcscd standin works, I’ll define "pcscd com." This is the private pcscd – libpcsclite unix domain socket communication. The one that is not publicly documented or supported. It’s true, the pcscd com is not 1 to 1 mapping of the PCSC calls. I works in a way that is actually beneficial to xrdp. Most of the calls like connect, transmit, control are direct calls but the way list readers and get status change difffer. There is a map of 16 readers that pcscd returns to libpcsclite. We do already "unsupported" things like the out of tree modules for pulseaudio. Maybe another solution is pcscd could add support for drivers or modules. I think projects like pcsclite and pulseaudio don’t want to support these plugable modules because it is of course more work for them. It’s perfectly understandable. |
Beta Was this translation helpful? Give feedback.
-
@jsorg71 what do you mean by "pcscd could add support for drivers or modules"? |
Beta Was this translation helpful? Give feedback.
-
@jsorg71 - can you tell me how you see the user experience for disconnect/reconnect working? At the moment devredir.c doesn't seem to have any visibility of client disconnects. As a result, active IRPs will hang if a client goes away unexpectedly. This would include any active SCardGetStatusChange calls. It's easy enough to add the plumbing to chansrv so that devredir.c can clear up active IRPs on a disconnect, but it's not clear to me what we're aiming for from a user perspective. At the moment I'm playing with option 2) above. I'm using your xrdp_pcsc.c code with a few changes to talk to a re-worked chansrv which just passes the calls up though the RDPDR channel. It's got the advantage that there's not a lot of state information to keep track of so it should be easy enough to get working and get the code reasonably well structured. The current disadvantages I'm aware of:-
Some or all of these disadvantages can be addressed by adding more state data to chansrv, but as I said, it's not clear to me exactly what we're aiming for. From a maintenance perspective I quite like the idea of resurrecting |
Beta Was this translation helpful? Give feedback.
-
Yes, on disconnect, the IRPs need to fail. I think when an IRP is sent to client, it's put in a list to use when it returns. We should use them on disconnect to error out. There was something in there for this but maybe only for the smart card calls. I did bring up the issue at RDPIO. What should happen when the client disconnects? Do you lose all the cards? Do you lose all the card reader? Are they still there but just error out until reconnect? I did not get an answer and I didn't test on MS to MS RDP session to find out. So there is some unknowns here. |
Beta Was this translation helpful? Give feedback.
-
@matt335672 @jsorg71 has there been any further development for this feature? |
Beta Was this translation helpful? Give feedback.
-
@ibeckermayer - I've been looking at re-engineering a replacement for libpcsclite.so, but it's fairly slow work, and at the moment we've got a sponsored activity we're all busy with. It's something I'll be coming back to as soon as I can get to it. |
Beta Was this translation helpful? Give feedback.
-
with the risk of being too late to the party: at xrdp, have you thought about deploying a virtual smart card reader at the server side instead of replacing the existing The only limitation would be that you cannot adjust the name of the virtual reader to match the name of the read smart card reader, because that is defined at the time when the driver of the virtual reader is loaded. |
Beta Was this translation helpful? Give feedback.
-
@frankmorgner- thanks for joining the discussion and providing the (interesting) link. Up until now I hadn't considered such an approach. There's been some progress on LudovicRousseau/PCSC/#161. I'm currently using a pre-release of this to test my own developments, which are reasonably encouraging so far. The current architecture we've got is that The advantage of this technique is that the smartcard redirection can be fairly easily restricted to a single session - it's not clear to me that this would be the case for a virtual smartcard(?) - xrdp can support multiple sessions per user on non-systemd systems. As you point out, a disadvantage of this technique is that MacOS support is dependent of the user compiling a later version of PCSC-Lite. In practice, on Linux systems, this may well be the case as well, at least in the short-term. I'm planning on documenting the socket interface, so it should be a simple matter to provide a virtual reader which would use this interface, giving us the best of both worlds. If we did things this way, your use of GPL and our use of ASL shouldn't pose any problems. |
Beta Was this translation helpful? Give feedback.
-
@LudovicRousseau work was what let me here in the first place. Although the modifications of PCSC-debug look fairly simple, I was in doubt if we really need a different way of debugging PCSC-Lite, let alone the problem that modifying an environment variable to gain access to PIN APDUs for a smart card seems to be fairly easy from an attacker's point of view... I assume that when and if A virtual reader on the server's side allows using the PC/SC framework of the server's machine without any modifications, that's why you could use the server also on macOS and even on Windows (vpcd from above also has a Windows implementation). The virtual reader would appear as if it was physically connected to the server's machine. I don't know if it is possible to limit a (virtual hardware) device's usage to a specific user, but I would assume it is possible. The TCP/IP interface to my virtual driver is very simple, which is why it has been used for different other applications as well and why it has found its way into some distributions. Yes, using my interface imposes no licensing requirement on your side. But actually, you don't necessarily need to use my driver, but you could also implement the interface in |
Beta Was this translation helpful? Give feedback.
-
Using a virtual reader is a nice idea. @frankmorgner Please confirm I understand correctly.
So it is not easy to dynamically add/remove virtual readers. You need to edit Did I missed something? |
Beta Was this translation helpful? Give feedback.
-
I've been looking at the code for PCSC-Lite, and (if I understand it correctly) one way to make this work with separation of sessions would be to start a session-specific Does that sound right @LudovicRousseau or have I missed something too? Once again, thanks @frankmorgner for provoking an interesting discussion. |
Beta Was this translation helpful? Give feedback.
-
It may be possible to start one It is more complex than using |
Beta Was this translation helpful? Give feedback.
-
It is now the job of the xrdp project to use this new pcsc-lite feature. Unfortunately there is no easy way to know if
|
Beta Was this translation helpful? Give feedback.
-
@matt335672 is there any update on this topic? We have a lot of demand for this feature. We'd be happy to sponsor the effort. |
Beta Was this translation helpful? Give feedback.
-
Base setup of xrdp with all passthrough options selected in the Windows 10 RDP client.
Remote host Ubuntu 20.04
xrdp version 0.9.12
Perhaps I missed something in setup but I didn't see any options for including RDP devices, when I remote into the client the system is unable to read any mapped devices or drives.
Beta Was this translation helpful? Give feedback.
All reactions