fix: JA4_a ALPN handling (non-alphanumeric + single-byte)#9
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aligns JA4_a ALPN handling with the FoxIO JA4 spec by (1) correctly skipping GREASE ALPNs, (2) handling 1-byte ALPNs as valid (non-GREASE), and (3) emitting hex-derived characters when ALPN boundary bytes are not ASCII alphanumeric.
Changes:
- Skip GREASE ALPN entries explicitly and accept 1-byte ALPNs as valid candidates.
- When the first/last ALPN bytes are non-ASCII-alphanumeric, emit the first/last hex characters without encoding the whole string.
- Add/update tests covering non-alphanumeric ALPN bytes and single-character ALPN behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ja4plus.go | Updates ALPN selection and encoding logic to match JA4 spec edge cases; adds isASCIIAlphanumeric. |
| ja4plus_test.go | Adds/updates test cases validating the new ALPN edge-case behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d82b615 to
720a159
Compare
totallyunknown
approved these changes
Jul 6, 2026
Per the JA4 spec, when the first or last byte of the first ALPN value is not ASCII alphanumeric, JA4_a uses the first and last characters of the value's hex representation instead of the raw bytes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
A 1-byte ALPN protocol cannot be a GREASE value, but the previous grease check discarded any proto shorter than 2 bytes, falling back to "00". Such protocols are now used, matching the JA4 spec. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
720a159 to
ba67e62
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes two JA4_a ALPN deviations from the FoxIO JA4 spec.
value isn't ASCII alphanumeric, use the first/last characters of the
value's hex representation instead of emitting the raw bytes.
used (with the single char as both first and last) instead of falling
back to "00".
Tests added/updated for both cases; benchmark unchanged (1 alloc, ~203ns/op).