feat(mysql): make rsa dependency optional (RUSTSEC-2023-0071) #4186
Open
sylvain-pierrot wants to merge 4 commits intolaunchbadge:mainfrom
Open
feat(mysql): make rsa dependency optional (RUSTSEC-2023-0071) #4186sylvain-pierrot wants to merge 4 commits intolaunchbadge:mainfrom
rsa dependency optional (RUSTSEC-2023-0071) #4186sylvain-pierrot wants to merge 4 commits intolaunchbadge:mainfrom
Conversation
Signed-off-by: Sylvain Pierrot <spierrot@aalyria.com>
Signed-off-by: Sylvain Pierrot <spierrot@aalyria.com>
…uth warnings Signed-off-by: Sylvain Pierrot <spierrot@aalyria.com>
…ssword in CI and tests Signed-off-by: Sylvain Pierrot <spierrot@aalyria.com>
|
That's a great PR i was thinking of doing something like this for my project because sqlx makes my CI fails even if i'm not using mysql. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Does your PR solve an issue?
No related issue. This addresses RUSTSEC-2023-0071 (CVE-2023-49092, "Marvin Attack"), a known timing side-channel in the
rsacrate with no patched release (patched = []in the advisory).Is this a breaking change?
Yes, for users of
sha256_passwordorcaching_sha2_passwordover non-TLS connections: they must now enablefeatures = ["rsa"]onsqlx-mysqlexplicitly. All other users are unaffected.The breakage is intentional and narrow: the
rsacrate has a known, unfixed cryptographic vulnerability. Keeping it as an unconditional dependency silently exposes everysqlxuser to RUSTSEC-2023-0071 in theircargo auditoutput, even those who never enable themysqlfeature. Opting in makes the risk visible and deliberate.Problem
Because Cargo resolves optional dependencies eagerly to produce a lock file valid for all feature combinations,
rsaappears in the lock file of any project that depends onsqlx, even when themysqlfeature is never enabled. This causes every such project to failcargo auditfor a vulnerability that cannot be compiled, let alone reached.Solution
Make
rsaan opt-in feature ofsqlx-mysql.MySQL's
sha256_passwordandcaching_sha2_passwordplugins use RSA only on non-TLS connections. When the connection is already TLS-encrypted the driver sends the password in cleartext over the secure channel and never touches RSA. Users who always connect over TLS (the recommended practice) have no need for thersacrate at all.Changes
sqlx-mysql/Cargo.toml:rsa = "0.9"→rsa = { version = "0.9", optional = true }+rsa = ["dep:rsa"]featuresqlx-mysql/src/connection/auth.rs:use rand::thread_rng,use rsa::{…}, the non-TLS RSA body ofencrypt_rsa, andparse_rsa_pub_keyare all gated with#[cfg(feature = "rsa")]; when the feature is absent a non-TLS RSA attempt returns aprotocolerror directing users to enable itBehaviour
sha256_password/caching_sha2_password,rsafeature enabledsha256_password/caching_sha2_password,rsafeature absentrsafeaturecargo auditwithoutmysqlfeatureNo other auth plugins affected.