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

fix: update handling of ja4 alpn edge cases #4755

Merged
merged 5 commits into from
Sep 9, 2024
Merged

Conversation

lrstewart
Copy link
Contributor

@lrstewart lrstewart commented Sep 5, 2024

Resolved issues:

Related to FoxIO-LLC/ja4#148

Description of changes:

Update s2n-tls's handling of alpn edge cases to reflect the updates to the spec:

Two of the changes (handling of 1-byte alpns and handling of only one of the first or last characters not being alphanumeric) aren't official yet, but I'm implementing the current consensus answer / matching what wireshark does.

Call-outs:

I'll need to update the compliance comments once the spec is finalized. But this change doesn't technically lower our duvet coverage even in the meantime, because the spec didn't cover any of these cases :)

Testing:

Unit tests, and I was able to uncomment the JA4 pcap that didn't work before.

I also added our own pcap with a wide range of questionable alpn values. I had to add exceptions for a few of those alpn values, because wireshark will need to be updated to not allow values like "__". The cases that pcap covers:

  • First alpn is an empty string
  • One invalid byte (0xAB)
  • One valid byte ('z')
  • Two invalid bytes (0xAB, 0xCD)
  • Two bytes, only one invalid ('z', 0xAB)
  • Invalid first and last bytes, other bytes valid (0xAB, 'z', 'y', 0xCD)
  • Valid first and last bytes, other bytes invalid ( 'z', 0xAB, 0xCD, 'y')
  • Valid but not alphanumeric ('-', '+')
  • One valid but not alphanumeric ('_')
  • Multiple alpns
  • Multiple apns, first alpn empty

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 Sep 5, 2024
Comment on lines 166 to 167
*/
S2N_RESULT s2n_hex_digit(uint8_t nibble, uint8_t *hex_digit);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding "stuffer" to the name to match the module makes this confusing, because it doesn't actually take a stuffer. But I'm not sure where else this function should live :/

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with not adding the prefix. Perhaps renaming it to something like nibble_to_hex might clarify its purpose?

@lrstewart lrstewart marked this pull request as ready for review September 5, 2024 22:19
@lrstewart lrstewart requested review from goatgoose and jouho September 5, 2024 22:20
Comment on lines 166 to 167
*/
S2N_RESULT s2n_hex_digit(uint8_t nibble, uint8_t *hex_digit);
Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with not adding the prefix. Perhaps renaming it to something like nibble_to_hex might clarify its purpose?

tests/pcap/tests/s2n_client_hellos.rs Outdated Show resolved Hide resolved
@lrstewart lrstewart requested a review from jouho September 6, 2024 22:42
@lrstewart lrstewart enabled auto-merge (squash) September 9, 2024 17:46
@lrstewart lrstewart merged commit 1accdc4 into aws:main Sep 9, 2024
36 checks passed
@lrstewart lrstewart deleted the ja4_alpn branch September 9, 2024 22:28
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.

3 participants