phuslu / nginx-ssl-fingerprint

high performance ja3 and http2 fingerprint for nginx.
BSD 2-Clause "Simplified" License
138 stars 23 forks source link

TLS 1.3 wrong JA3 values #3

Closed ne4u closed 2 years ago

ne4u commented 2 years ago

when tls 1.3 is negotiated, the JA3 value is truncated therefore the md5 hash is wrong.

phuslu commented 2 years ago

Emmm, this case is well tested internally. so it should be OK. Could you please give a repro of "curl" cli example?

ne4u commented 2 years ago

ssl_protocols TLSv1.2;

/usr/local/opt/curl/bin/curl -v https://tls.bob.com:4443

ssl_protocols TLSv1.3;

/usr/local/opt/curl/bin/curl -v https://tls.bob.com:4443

The expected result for tls 1.3 should be:

JA3: 772,4866-4867-4865-49196-49200-159-52393-52392-52394-49195-49199-158-49188-49192-107-49187-49191-103-49162-49172-57-49161-49171-51-157-156-61-60-53-47-255,0-11-10-13172-16-22-23-49-13-43-45-51-21,29-23-30-25-24, JA3-Hash: b0aca3a3bfcbb345b7e4e397f231dee8

when formats is null truncation occurs

ne4u commented 2 years ago

i'm no c programmer, so to test my theory i added this horribly wrong code which does seem to work:

/* formats */
if (c->ssl->points.len) {
    pdata = c->ssl->points.data;
    pend = pdata + c->ssl->points.len;
    while (pdata < pend) {
        pstr = append_uint8(pstr, *pdata);
        *pstr++ = '-';
        pdata++;
    }
} else {
    /* quick dirty fix for tls 1.3 */
    *pstr++ = ',';
    pdata++;
}

I can confirm with my hack, i'm now getting expected results when compared to: browswerleaks.com/ssl for all tested tls 1.3 clients.

phuslu commented 2 years ago

fix in openssl-31 branch please take a look.