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

Consider using key wrapping - nonce generation to avoid storage on device #4

Open
alphathegeek opened this issue Aug 7, 2019 · 2 comments

Comments

@alphathegeek
Copy link

Since the keys are stored on the device, and indexed by KeyHandle, it might be wise to implement the solution that the YubiKeys implement, which is essentially KeyWrapping. the device basically generates/wraps a hey with the HMAC function, so nothing besides the SecretKey is stored on the device.

This would guard against SD-Card corruption issue, while still ensuring a clonable device.

As a thought, OTP/EEPROM locations 36-43 are available for general purpose usage. This gives 256 bits to play with, good for a key?

Another idea, would be to gpg encrypt the secret key or the keystore , and use the pi-zero camera to provide a password via QR-Codes. The device only becomes unlocked once the correct password is entered. A QR code can be easily read with the camera, and could provide a good pass-phrase ala "Correct-Horse-Battery-Staple!" type, or something more/less innocuous while still being a bit more secure. This also would solve the "user presence verification" part which is currently obviously not imeplemented. The "unlocked" key could be stored in /tmp , ala ramdisk so it gets lost during power-down.

This doesn't solve all the attack vectors, but it's something I'm considering implementing, just to get some practice.

Let me know what you think, Thanks!

@Crystalix007
Copy link
Owner

Thanks for the suggestion.

Just one suggestion first. I have realised that the program starts as the root user, hence if you make the root user the only one capable of reading the file, most attack vectors are nullified immediately. For example, chmod 600 /usr/share/U2F_Priv_Keys.txt. Then, the only potential attacks are physically obtaining the micro sd-card or obtaining root on the device. Corruption is still an issue though.

I do agree that key-wrapping would be a good feature, however, to provide any greater security than a plain text file, only this program should be able to read the secret key. Using OTP/EEPROM would mean that anyone who managed to get the Pi would be able to login, whereas the current situation is that anyone with the micro sd-card would be able to log in. I don't see enough benefit, personally, to implement this myself. The only potential solution to this is the ARM TrustZone technology, which I don't particularly feel like implementing.

However, if you wish to fork and build key-wrapping yourself, successfully, I would be happy to accept the PR. I would have suggested that you use something like a password (passed to main) as the master key, as this way you could theoretically restore a U2F device. However, the keys have counters, so you would be unable to restore unless you knew the counters. I don't actually know the full details about the YuibKey's implementation, so they may have found a way around this, by storing the counter in the key itself perhaps? Otherwise, I fear that key-wrapping would not stop loss of the U2F device.

Regarding the camera idea: I don't feel like this is a great solution, as the camera alone is triple the price of a Pi Zero. The main reason for this project was to have a lower-cost solution than the existing commercial ones. Additionally, interfacing with the camera adds quite a bit more complexity. One thought I had in the past was to use the GPIO pins of the Pi with buttons such as this to implement a numpad. Then, the passcode could do key-wrapping or decrypt the keyfile.

Please don't implement a solution storing the key in /tmp however. This could be readable by any other program. Rather just keep the key in memory somewhere, as then extracting the key would require root.

Overall, feel free to implement key wrapping if you want, and if it's an improvement, I will accept a PR. Personally, I will probably add a vendor U2F command which just shuts down the Pi. That should improve the removal experience (you would just need to send that command to the U2F device rather than logging in via ssh and manually powering off). The command should be able to be sent via a browser, or at worst, a PC-side application.

@alphathegeek
Copy link
Author

alphathegeek commented Aug 10, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants