-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Security improvement #128
Comments
The CCID driver is running in the pcscd process as root. |
It is used not only in the pcscd process. It is also used from SCardTransmit in PCSClite. This is our use case, we are using PCSClite as a library. If you access the process memory you can see the pin there long after all our buffers were cleaned up. |
libpcsclite.so.1 is a library. Exact. |
The buffer being copied was the point 😄. SCardTransmit calls IFDHTransmitToICC. IFDHTransmitToICC calls CmdXfrBlock. CmdXfrBlock calls CCID_Transmit. CCID_Transmit makes a copy of the buffer. |
I agree with you. But the buffer copy occurs on the daemon side run as root. |
Because libpcsclite.so is loaded into the process memory, the buffer is also created in a process memory address. There is no IPC, just a chain of calls. |
Please show me the line of code that creates the buffer in |
It is the one I linked before. This one. |
The buffer declaration is here. |
It is NOT in |
I am not sure what you mean. This code is linked in libpcsclite.so. There is no IPC, just a chain of calls. The call from PCSCLite sources is here. |
Can you share the security audit report? I would like to read it. |
Unfortunately no, sorry. Please note there is no claim of a vulnerability, as secrets in memory are expected if your program manages them. Just trying to reduce the time that secrets (the pin in this case) remains in memory. Trying to minimize exploits of mismanaged memory dumps and the risk when users incorrectly let other users to use their sessions. |
If you are afraid your PIN code can leak I suggest to use a pinpad reader. |
Unfortunately not all users of the program can be told to acquire such a reader. |
Would a PR help to address the issue? |
I would like to be convinced it is a real problem. |
Thank you for your answer. I can create such program. Is there a way I can contact you privately? |
My email is listed at https://blog.apdu.fr/articles/about_me/ |
In the function CCID_Transmit there is a local buffer where the command is copied. The memory assigned for that buffer remains unchanged for a long time after the function exited. In a situation where the command contains the pin, the pin will remain in memory for a long time. New commands will allocate different buffers in the stack. Furthermore, the interesting buffer will be at a fixed memory, so an attacker can find this memory offset using a known pin/card.
This problem was observed when auditing some process memory searching for long standing secrets.
One possible solution is cleaning up the buffer after use. Something like:
An alternative solution is to request extra space in the user provided buffer and avoid a local one. But I guess this will break backward compatibility.
Thank you.
The text was updated successfully, but these errors were encountered: