Skip to content
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

Documentation: Mention pinning on the Sensitive data page #70

Closed
samuel-lucas6 opened this issue Mar 24, 2024 · 5 comments
Closed

Documentation: Mention pinning on the Sensitive data page #70

samuel-lucas6 opened this issue Mar 24, 2024 · 5 comments
Labels
awaiting reply When we are waiting for response from user documentation Improvements or additions to documentation

Comments

@samuel-lucas6
Copy link

samuel-lucas6 commented Mar 24, 2024

I think it's worth mentioning that sensitive byte arrays/spans should be pinned for their lifetime to avoid copies in memory. There are several ways to do this:

  1. stackalloc expression
  2. GC.AllocateArray()
  3. fixed statement
  4. GCHandle.Alloc()

Otherwise, CryptographicOperations.ZeroMemory() can be useless and give you a false sense of security.

It may also be worth explicitly stating that strings should be avoided if possible because they supposedly can't be wiped without a risk of crashing the runtime, although it seems to be doable in a project I'm working on that calls Monocypher.

Overall though, this library has pretty good documentation, so thank you for that.

// MAINTAINER EDIT
Adding links to the specific documentation article the OP is referring to:
https://github.com/Yubico/../docs/../sensitive-data.md

@DennisDyallo
Copy link
Collaborator

Hi @samuel-lucas6 ! Thanks for the comment. I know this topic has been discussed previously in the team prior to me joining. I'll bring it to the team and see what comes up.

@GregDomzalski GregDomzalski added the documentation Improvements or additions to documentation label Apr 19, 2024
@DennisDyallo
Copy link
Collaborator

Hi @samuel-lucas6!

I want to start off by saying that I'm new to the team and Yubico. But based on the discussions regarding your issue/suggestion I can reply that we generally agree with your suggestions.
The documentation page should be rewritten to address the corncerns you're raising. At the same time, in the topic of "false sense of security", we acknowledge that if an exploiter has access to a memory dump, there are likely bigger problems in your organization than Yubikey pin codes being leaked from memory.

Feel free to add to this discussion.

//Dennis

@DennisDyallo DennisDyallo added the awaiting reply When we are waiting for response from user label Jun 17, 2024
@samuel-lucas6
Copy link
Author

Thanks for discussing it. I agree, but it's considered good practice and better than doing nothing. It's probably more about preventing secrets getting stored on disk than an attacker performing a memory dump, although the latter has been discussed in the context of password managers.

The only trouble is that the library isn't designed for this. For example, I wrote a program supporting challenge-response and noticed that requires using ReadOnlyMemory<byte> for the response.

@DennisDyallo
Copy link
Collaborator

Thanks for the issue @samuel-lucas6
We posted an update to the referred article. This version adresses the concerns you raised. Please take a look and let us know what you think.

@samuel-lucas6
Copy link
Author

Hey @DennisDyallo, thanks for updating the documentation and letting me know.

I have four pieces of feedback:

  1. I think slicing spans should be mentioned to avoid copies. I believe that was there before.
  2. The examples should pin the byte array (e.g., switch to using a span with stackalloc or do GC.AllocateArray()).
  3. The fact that strings are problematic is discussed twice. You could probably get rid of it from the first numbered bullet point and merge bullets 1 and 5.
  4. I think the previous conclusion was clearer about how there's nothing else you can do (but C# is better than some languages) and that sensitive data not ending up on disk is virtually impossible to prevent. Maybe disk encryption could be mentioned as a mitigation if this is a concern.

Otherwise, I like the bullet point approach and discussion of the different risks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting reply When we are waiting for response from user documentation Improvements or additions to documentation
Development

No branches or pull requests

3 participants