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

RSA decoding crash #1173

Closed
AgeManning opened this issue Jun 13, 2019 · 3 comments

Comments

3 participants
@AgeManning
Copy link
Contributor

commented Jun 13, 2019

We've started doing some fuzz testing on the protocols we're building into libp2p.

One test demonstrates that RSA decoding can cause memory crashes (tries to allocate an unreasonably large vec). It can be reproduced by adding the the following test to /core/src/identity/rsa.rs:

    #[test]
    fn rsa_x509_decode_bytes() {
        let bytes = [
            157, 247, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 157, 67, 157, 1,
            0, 0, 0, 157, 157, 157, 157, 157, 157, 157, 157,
        ];
        let _ = PublicKey::decode_x509(&bytes);
    }

This is an issue with the ans1_der library, not libp2p. Anyway, if there are protocols that decode public keys from external sources, be aware of the above.

This is related to: KizzyCode/asn1_der#1

@tomaka tomaka added the bug label Jun 13, 2019

@tomaka

This comment has been minimized.

Copy link
Member

commented Jun 13, 2019

It might be a good idea to allow disabling RSA at compile-time with a feature.
It would generally decrease the size of the binary as well. (cc #1051)

@KizzyCode

This comment has been minimized.

Copy link

commented Jun 13, 2019

Ok, the bug has been fixed in 0.6.2; thank you for raising this issue 😊

@AgeManning

This comment has been minimized.

Copy link
Contributor Author

commented Jun 26, 2019

This has been fixed :). Thanks @KizzyCode

@AgeManning AgeManning closed this Jun 26, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.