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

Securely generate network key when resetting adapters #5833

Merged
merged 3 commits into from
Feb 27, 2022

Conversation

puddly
Copy link
Contributor

@puddly puddly commented Feb 26, 2022

qrand() is not suitable for generating the network key when factory resetting an adapter.

The first call to qrand() sets the public PAN ID. This leaks enough RNG state to make bruteforcing the full state feasible from a single captured packet and thus allows the network key to be easily computed.

Unoptimized PoC: https://github.com/puddly/deconz-network-key-leak-poc


I can't figure out how to test this branch with the deCONZ Docker image so while the code compiles, I'm not certain of its correctness. Feel free to close this PR and re-implement it yourself, the changes are pretty minor.

`qrand` is a wrapper around `rand`, which is entirely unsuitable for
generating cryptographic keys.
No more than 16 sequential bytes are ever generated by `fallbackRandom`
so this is probably an inconsequential change but the Mersenne Twister
is not cryptographically secure, while `std::random_device` is pulling
from a high-quality source on all platforms.  This is "good enough" for
a fallback.
@manup
Copy link
Member

manup commented Feb 27, 2022

Thanks, very nice good spot on the Mersenne Twister use. The fallback is likely not used much as in most installations OpenSSL should be available.

@manup manup added this to the v2.15.0-beta milestone Feb 27, 2022
@manup manup merged commit 564744c into dresden-elektronik:master Feb 27, 2022
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

Successfully merging this pull request may close these issues.

3 participants