Skip to content

Conversation

@costela
Copy link
Member

@costela costela commented Jul 18, 2025

This pull request fixes the JA4 fingerprinting implementation by also filtering out GREASE values in SupportedProtos. It also does a minor optimization of extension hashing by skipping one unnecessary copy.

Improvements to GREASE filtering and extension handling:

  • ja4plus.go: Updated the JA4 function to filter GREASE values when determining the first ALPN and to use filteredExtensions in the extension hash computation. This ensures GREASE values are excluded from both the ALPN and extension hash logic. [1] [2]
  • ja4plus.go: Modified the extensionHash function to explicitly require filtered extensions and clarified its documentation. The function now sorts extensions in-place and excludes GREASE values, SNI, and ALPN from the hash computation.

Test coverage enhancements:

  • ja4plus_test.go: Added new test cases in TestJA4 to verify behavior with all-GREASE inputs and ensure the function handles invalid protocol versions defensively without panicking.
  • ja4plus_test.go: Removed redundant test cases for GREASE-only extensions in TestExtensionHash since GREASE filtering is now integrated into the core logic.

Minor updates:

  • ja4plus.go: Added the encoding/binary import to support GREASE filtering logic.

@costela costela requested a review from Copilot July 18, 2025 10:12

This comment was marked as outdated.

@costela costela force-pushed the leo.antunes/filter-grease-in-supported-protos branch from c8a8791 to ddffbea Compare July 18, 2025 10:36
@costela costela requested a review from Copilot July 18, 2025 10:37

This comment was marked as outdated.

@costela costela force-pushed the leo.antunes/filter-grease-in-supported-protos branch from ddffbea to 0a0b757 Compare July 18, 2025 10:37
@costela costela requested a review from Copilot July 18, 2025 10:38
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the JA4 fingerprinting algorithm to filter out GREASE values from SupportedProtos when determining the first ALPN value, improving consistency with how GREASE values are handled in other parts of the codebase.

  • Adds GREASE filtering logic for protocol selection in the JA4 function
  • Updates extension hash computation to use pre-filtered extensions and avoid redundant GREASE filtering
  • Adds comprehensive test coverage for GREASE handling scenarios and edge cases

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
ja4plus.go Implements GREASE filtering for SupportedProtos and optimizes extensionHash function
ja4plus_test.go Adds test cases for GREASE filtering and invalid protocol handling

@costela costela force-pushed the leo.antunes/filter-grease-in-supported-protos branch from 0a0b757 to 3939be0 Compare July 24, 2025 07:09
@costela costela merged commit 999c677 into main Jul 24, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants