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

Leaking pins: memcpy != memset #13

Closed
FlorianUekermann opened this issue Jul 31, 2016 · 5 comments
Closed

Leaking pins: memcpy != memset #13

FlorianUekermann opened this issue Jul 31, 2016 · 5 comments
Labels
Milestone

Comments

@FlorianUekermann
Copy link
Contributor

memcpy (card_password, 0, sizeof (card_password));

I suspect that this is supposed to zero the card_password (memset?). It doesn't. This is undefined behavior. If you are lucky the compiler doesn't generate any code for this.

A quick regex search finds 10 of these just in report_protocol.c. I didn't look further.
Also, if this is used with a nonzero second argument the compiler will actually have to generate code for this afaik, so that might be better, or even worse, depending on the situation. Since it is a bit harder to search for, I didn't. Make sure to look for that as well.

The compiler issues a warning every time this pattern is used!

@szszszsz
Copy link
Member

szszszsz commented Aug 1, 2016

Hi @MaVo159 !
I agree - this looks like obvious typo, it should be memset instead.
Reference: memset memcpy.

@szszszsz szszszsz added this to the v0.8 milestone Sep 12, 2016
@szszszsz
Copy link
Member

szszszsz commented Sep 13, 2016

Note: clearing is already correctly implemented in Storage firmware (checking same file, that is report_protocol.c)
Edit: Other files seems OK in both projects. Searched with memcpy.*0 regexp.

szszszsz added a commit that referenced this issue Sep 13, 2016
szszszsz added a commit that referenced this issue Sep 13, 2016
Issue #13. Checked on Ubuntu 16.04 with both nitrokey-app and libnitrokey py.test test suite.
@FlorianUekermann
Copy link
Contributor Author

FlorianUekermann commented Sep 13, 2016

Just checking that my logic isn't off. The nk hsm doesn't use this protocol at all, so these bugs don't matter on the temporary hsm branch. Actually, someone could still use it, but we would never expect a sane user to actually generate reports with sensitive info on an hsm...
Correct?
Otherwise we should remove the corresponding USB callbacks on the hsm branch to make sure this code is dead on hsm.

@szszszsz
Copy link
Member

The functions listed in report_protocol.c (HID protocol) are not used anywhere else. I believe HSM is officially not supporting HID, so we can safely skip porting these changes to hsm branch.

@FlorianUekermann
Copy link
Contributor Author

Well, I believe the protocol is still exposed on an hsm, we just don't advertise it in the descriptor. So if any illegitimate use of the protocol can lead to sensitive leaks, we need to deactivate it. But I don't have a scenario.
Well... even if it is a problem, which I doubt, the protocol will be properly deactivated once the hsm branch goes away.

@szszszsz szszszsz added the bug label Nov 19, 2016
szszszsz added a commit that referenced this issue May 19, 2018
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
szszszsz added a commit that referenced this issue May 19, 2018
Signed-off-by: Szczepan Zalega <szczepan@nitrokey.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants