1
Improve RSA key file generation and reads
Source: dani-garcia/vaultwarden#4083 · opened by @zacknewman
Currently [main::check_rsa_keys]( [auth::PRIVATE_RSA_KEY]( and [auth::PUBLIC_RSA_KEY]( rely on a lot of separate I/O calls and a few avoidable assumptions which leads to TOCTOU race conditions and a loss in data integrity (e.g., when the public key file exists, there is no validation done to ensure it matches what it should be based on the private key). The change I propose avoids all of those issues. Additionally, integrating the change is highly localized since there is so little code that relies on the RSA key data. Public keys can be generated from private keys which allows us to avoid the public key file altogether. By _always_ generating the public key from the private key data, we don't have to worry about an invalid public key file. The job is then to read or create/write the private key file using only a single operation avoiding TOCTOU race conditions. The below code relies on std::sync::OnceLock, but it would be trivial to adjust it to use once_cell::sync::Lazy. …
No pledges yet. Be the first to back this.
Comments
Similar requests
separate static config data from working data and temp files
1 vote · 0 comments
Add an "Exclude specific characters" field to the password generator policy
1 vote · 0 comments
Minimal support for external SSO-based keys
1 vote · 0 comments
User account key rotation is not atomic
2 votes · 0 comments
SSO login flow requires redundant email input before IdP redirect
3 votes · 0 comments
No comments yet.