Repository navigation
fix(rust): handle single-character ALPN according to spec (#325) - #327
Merged
vlvkobal merged 2 commits intoOct 6, 2026
Merged
Conversation
…LLC#325) For a one-character ALPN, the JA4 spec dictates that a single character should supply both first and last positions (e.g. 'x' -> 'xx'), mirroring the Python fix in FoxIO-LLC#322. Closes FoxIO-LLC#325
Member
|
I removed the changelog entry since |
vlvkobal
approved these changes
Oct 6, 2026
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.
Summary
According to the JA4 specification, a single-character ALPN value should use that character for both the first and last positions (e.g.,
"x"->"xx"instead of"x0").This aligns the Rust implementation with the Python fix implemented in #322.
Changes
rust/ja4/src/tls.rs(first_last), whenchars.next_back()returnsNonefor single-character strings, fall back tofirstusing.or(first).test_first_last()andtest_first_last_non_ascii()to verify single-character ASCII and non-ASCII ALPN behavior.test_single_char_alpn_fingerprints()to verify that both client (PartsOfClientFingerprint) and server (ServerStats) JA4 outputs format single-character ALPN as"xx".rust/CHANGELOG.mdunder[Unreleased].Verification
Local test verification passed with zero failures or warnings:
cargo fmt --check --all(Clean)cargo clippy --all-features --workspace -- -D warnings(Clean, 0 warnings)cargo test --locked --all-features --all-targets --workspace(All 25 tests passed)cargo test --locked --all-features --doc --workspace(Passed)cargo doc --no-deps --all-features --document-private-items --workspace(Passed)Closes #325