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

Add JA3 fingerprinting #3817

Merged
merged 5 commits into from
Feb 11, 2023
Merged

Add JA3 fingerprinting #3817

merged 5 commits into from
Feb 11, 2023

Conversation

lrstewart
Copy link
Contributor

Description of changes:

Add JA3 fingerprinting functionality. For now, it's not publicly accessible.

JA3 is a method for identifying clients. See this blog post from its creator: https://engineering.salesforce.com/tls-fingerprinting-with-ja3-and-ja3s-247362855967/

We provide two methods, one to retrieve the full JA3 string and one to retrieve just the hash of the JA3 string. While the hash should be sufficient to identify a client, some customers have requested access to the full JA3 string.

Callouts

  • For now, the API will error for SSLv2 ClientHellos. Clients would only send SSLv2 ClientHellos if they're unsure whether a server supports SSLv3 or higher. Since SSLv3 was released in 1996 and deprecated in 2015, I imagine we can live without SSLv2 support. If not, we can add it, but it complicates some of the parsing. SSLv2 JA3s also likely won't be particularly useful, since the only fields available are the protocol version and the cipher suites.
  • If a customer wants both the full string and the hash, we calculate the JA3 string twice, once for each API call. But at least there's some benefit from this duplicate work: we can calculate the length of the JA3 string while calculating the hash, allowing a customer to allocate the correct amount of memory for the variable-length JA3 string.
  • I didn't end up managing to reuse nearly as much of our parsing as I'd hoped. Luckily, most of the parsing we do is pretty simple.

Testing:

I wrote unit tests and a small number of known value tests.

In the future, I'd like to add fuzzing and call the API in s2nd so that it gets run for all the integration tests. Let me know if you have other testing ideas!

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@github-actions github-actions bot added the s2n-core team label Feb 8, 2023
@lrstewart lrstewart marked this pull request as ready for review February 8, 2023 23:07
Copy link
Contributor

@goatgoose goatgoose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still reading the tests!

Comment on lines 35 to 40
const bool s2n_grease_values[] = {
[0x0A] = true, [0x1A] = true, [0x2A] = true, [0x3A] = true,
[0x4A] = true, [0x5A] = true, [0x6A] = true, [0x7A] = true,
[0x8A] = true, [0x9A] = true, [0xAA] = true, [0xBA] = true,
[0xCA] = true, [0xDA] = true, [0xEA] = true, [0xFA] = true,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need a table for this? https://godbolt.org/z/4dcro7MK3

You should be able to just

ENSURE_EQ((byte1 | 0xF0), 0xFA);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://www.rfc-editor.org/rfc/rfc8701.html

These values were allocated sparsely to discourage server implementations from conditioning on them.

You're messing up the GREASE strategy Cameron, they're supposed to be hard to match on :)

@lrstewart lrstewart added this pull request to the merge queue Feb 10, 2023
@lrstewart lrstewart removed this pull request from the merge queue due to a manual request Feb 10, 2023
@lrstewart lrstewart added this pull request to the merge queue Feb 10, 2023
@lrstewart lrstewart removed this pull request from the merge queue due to the queue being cleared Feb 10, 2023
@lrstewart lrstewart enabled auto-merge (squash) February 10, 2023 21:39
@lrstewart lrstewart merged commit ca5a4b8 into aws:main Feb 11, 2023
@lrstewart lrstewart deleted the ja3 branch February 11, 2023 00:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants