Browser Fingerprint Consistency: Auditing TLS, HTTP/2 and JavaScript Signals with Playwright
A scraper can send clean HTTP headers and still get challenged if its network stack and browser properties disagree. Sending a Chrome User-Agent from Python’s requests or curl does not give the connection Chromium’s TLS handshake or HTTP/2 settings. Launching headless Chrome through Playwright with a Firefox User-Agent creates the opposite problem: the browser still sends Chromium Client Hints and opens connections with a Chromium TLS profile.
In this guide, we build a small probe and cross-layer auditor with Python and Playwright against tls.peet.ws, test it on Chrome 158 pretending to be Firefox 140, and turn the check into a CI gate that fails when signals contradict each other.
What websites compare across layers
Anti-bot systems rarely rely on one hash. They compare clues gathered before HTTP headers are parsed, inside HTTP/2 framing, and later inside the page DOM:

| Layer | Where it comes from | What triggers suspicion |
|---|---|---|
| TLS handshake | ClientHello cipher suites, extensions, and ALPN (ja3_hash, ja4) |
A client claiming Chrome sends TLS parameters from curl or Python OpenSSL |
| HTTP/2 transport | SETTINGS frame order, window size, pseudo-header order, sec-ch-ua* headers |
HTTP/2 framing stays fixed while the claimed browser family flips |
| Browser JavaScript | navigator.userAgent, navigator.platform, navigator.userAgentData |
navigator.userAgent claims Firefox while navigator.userAgentData reports Chromium |
In our own capture, running curl with a Chrome 158 User-Agent header produced a ja4 fingerprint of t13d497h2_0d8feac7bc37_7395dae3b2f3 and an Akamai HTTP/2 string of 3:100;4:10485760;2:0|1048510465|0|m,s,a,p. Real headless Chrome 158 on macOS sent t13d1517h2_8daaf6152771_cb7bf5808d99 and 1:65536;2:0;4:6291456;6:262144|15663105|0|m,a,s,p. Matching the header string did not alter the wire protocol.
Consistency checks also avoid false alarms. Missing navigator.userAgentData is normal outside Chromium, and two fresh runs of the same Chrome binary often emit different JA3 hashes because Chromium shuffles TLS extension order. Starting from a baseline captured in your own environment beats hardcoding static hashes copied from another machine.
Setting up the Playwright probe
Create a clean Python environment with playwright installed:
python3 -m venv .venv
source .venv/bin/activate
pip install playwright
playwright install chromium
Write probe.py to launch Chromium, open https://tls.peet.ws/api/all with page.goto(), collect HTTP/2 SETTINGS and sec-ch-ua* headers from sent_frames, and read navigator properties inside the same page:
import argparse
import json
from pathlib import Path
from playwright.sync_api import sync_playwright
URL = "https://tls.peet.ws/api/all"
def capture(user_agent=None):
with sync_playwright() as p:
browser = p.chromium.launch()
try:
page = browser.new_page(user_agent=user_agent) if user_agent else browser.new_page()
response = page.goto(URL, wait_until="domcontentloaded")
if response is None or not response.ok:
raise RuntimeError("Failed to fetch fingerprint data")
data = response.json()
browser_data = page.evaluate(
"""() => {
const uaData = navigator.userAgentData;
return {
user_agent: navigator.userAgent,
platform: navigator.platform,
language: navigator.language,
languages: [...navigator.languages],
webdriver: navigator.webdriver,
user_agent_data: uaData ? {
brands: uaData.brands,
mobile: uaData.mobile,
platform: uaData.platform
} : null
};
}"""
)
finally:
browser.close()
tls = data.get("tls") or {}
http2 = data.get("http2") or {}
sent_frames = http2.get("sent_frames", [])
settings = next(
(frame.get("settings", []) for frame in sent_frames if frame.get("frame_type") == "SETTINGS"),
[],
)
client_hints = {}
for frame in sent_frames:
if frame.get("frame_type") != "HEADERS":
continue
for header in frame.get("headers", []):
name, sep, value = header.partition(":")
if sep and name.lower() in ("sec-ch-ua", "sec-ch-ua-mobile", "sec-ch-ua-platform"):
client_hints[name.lower()] = value.strip()
break
return {
"network": {
"user_agent": data.get("user_agent"),
"client_hints": client_hints,
"http_version": data.get("http_version"),
"tls": {
"ja3_hash": tls.get("ja3_hash"),
"ja4": tls.get("ja4"),
},
"http2": {
"akamai_fingerprint": http2.get("akamai_fingerprint"),
"settings": settings,
},
},
"browser": browser_data,
}
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--user-agent")
parser.add_argument("--out", type=Path, default=Path("fingerprint.json"))
args = parser.parse_args()
result = capture(args.user_agent)
args.out.write_text(json.dumps(result, indent=2) + "\n", encoding="utf-8")
print(f"Wrote {args.out}")
Using page.goto() here matters. Playwright’s page.request.get() uses an isolated HTTP request context, so it skips Chromium’s browser networking stack and hides the browser’s true TLS or HTTP/2 settings.
Run the probe once and save the output as baseline.json:
python3 probe.py --out baseline.json

On headless Chrome 158 on macOS, the capture shows three details worth noting before writing the checker:
navigator.platformreturns"MacIntel"whilenavigator.userAgentData.platformreturns"macOS". Both describe the same operating system, so our checker normalizes OS names before comparing them.- The
brandslist includes{ "brand": "Not.A/Brand", "version": "24" }. That is a Chromium GREASE brand inserted to prevent rigid user-agent sniffing, and our checker filters it out when comparing browser brands. navigator.webdriveristrue. Sites can detect automation from that flag, though it is not a cross-layer contradiction by itself.
Building the cross-layer auditor
Save the following script as audit.py. It checks User-Agent parity, OS agreement across HTTP and JS, browser family and major version against Client Hints, HTTP vs. JavaScript Client Hints, baseline family changes without a network change, and independent JA4/HTTP/2 drift:
import argparse
import json
import re
from pathlib import Path
def browser_family(user_agent):
if "Firefox/" in user_agent:
return "Firefox"
if any(name in user_agent for name in ("HeadlessChrome/", "Chrome/", "Chromium/", "Edg/")):
return "Chromium"
return None
def platform_name(value):
value = (value or "").lower()
if "windows" in value or value.startswith("win"):
return "Windows"
if "android" in value:
return "Android"
if "iphone" in value or "ipad" in value or "ios" in value:
return "iOS"
if "mac" in value:
return "macOS"
if "linux" in value or "x11" in value:
return "Linux"
return None
def relevant_brands(pairs):
known = {"Chromium", "HeadlessChrome", "Google Chrome", "Microsoft Edge"}
return {(name, version) for name, version in pairs if name in known}
def audit(current, baseline=None):
network = current.get("network", {})
browser = current.get("browser", {})
hints = browser.get("user_agent_data") or {}
ua = network.get("user_agent") or ""
js_ua = browser.get("user_agent") or ""
results = []
def record(level, message):
results.append((level, message))
if ua and js_ua:
matches = ua == js_ua
record(
"PASS" if matches else "WARN",
"HTTP and JavaScript User-Agents match"
if matches else "HTTP and JavaScript User-Agents differ",
)
else:
record("INFO", "User-Agent missing from one of the layers")
platforms = [p for p in (platform_name(ua), platform_name(browser.get("platform")), platform_name(hints.get("platform"))) if p]
if len(platforms) >= 2:
matches = len(set(platforms)) == 1
record("PASS" if matches else "WARN", "Reported platforms agree" if matches else f"Platform mismatch: {', '.join(platforms)}")
brands = hints.get("brands") or []
has_chromium_brand = any("Chromium" in item.get("brand", "") or "Chrome" in item.get("brand", "") for item in brands)
family = browser_family(ua)
if family == "Firefox" and has_chromium_brand:
record("WARN", "User-Agent claims Firefox, but Client Hints identify Chromium")
elif family == "Chromium" and has_chromium_brand:
record("PASS", "User-Agent family agrees with Client Hints")
elif hints:
record("INFO", "Browser family could not be checked reliably")
if family == "Chromium":
match = re.search(r"(?:HeadlessChrome|Chrome|Chromium|Edg)/(\d+)", ua)
chromium_versions = {item.get("version") for item in brands if item.get("brand") in ("Chromium", "HeadlessChrome", "Google Chrome")}
if match and chromium_versions:
major = match.group(1)
matches = major in chromium_versions
record("PASS" if matches else "WARN", f"Chromium major version {'matches' if matches else 'differs from'} Client Hints ({major})")
http_hints = network.get("client_hints") or {}
if not http_hints or not hints:
record("INFO", "HTTP or JavaScript Client Hints unavailable")
else:
http_platform = http_hints.get("sec-ch-ua-platform")
if http_platform is not None and hints.get("platform") is not None:
matches = http_platform.strip('"') == hints["platform"]
record("PASS" if matches else "WARN", "HTTP and JavaScript Client Hint platforms match" if matches else "HTTP and JavaScript Client Hint platforms differ")
http_mobile = http_hints.get("sec-ch-ua-mobile")
if http_mobile in ("?0", "?1") and isinstance(hints.get("mobile"), bool):
matches = (http_mobile == "?1") == hints["mobile"]
record("PASS" if matches else "WARN", "HTTP and JavaScript mobile indicators match" if matches else "HTTP and JavaScript mobile indicators differ")
http_ua = http_hints.get("sec-ch-ua")
if http_ua:
http_brands = relevant_brands(re.findall(r'"([^"]+)";v="([^"]+)"', http_ua))
js_brands = relevant_brands((item.get("brand"), item.get("version")) for item in hints.get("brands", []))
if http_brands and js_brands:
matches = http_brands == js_brands
record("PASS" if matches else "WARN", "HTTP and JavaScript browser brands match" if matches else "HTTP and JavaScript browser brands differ")
http2 = network.get("http2") or {}
if network.get("http_version") == "h2":
if http2.get("akamai_fingerprint") and http2.get("settings"):
record("PASS", "HTTP/2 negotiated and fingerprint details captured")
else:
record("INFO", "HTTP/2 negotiated, but some diagnostic fields are missing")
if network.get("tls", {}).get("ja4"):
record("INFO", "JA4 captured; browser family cannot be inferred from it alone")
if browser.get("webdriver") is True:
record("INFO", "Browser reports automation via navigator.webdriver")
if baseline:
base_network = baseline.get("network", {})
base_family = browser_family(base_network.get("user_agent") or "")
if base_family and family and base_family != family:
ja4 = network.get("tls", {}).get("ja4")
h2 = http2.get("akamai_fingerprint")
if bool(ja4) and ja4 == base_network.get("tls", {}).get("ja4") and bool(h2) and h2 == (base_network.get("http2") or {}).get("akamai_fingerprint"):
record("WARN", f"User-Agent changed from {base_family} to {family}, while JA4 and HTTP/2 fingerprints still match the {base_family} baseline")
else:
record("INFO", "Browser family changed, but network fingerprints do not both match the baseline")
for name, current_value, old_value in (
("JA4", network.get("tls", {}).get("ja4"), (base_network.get("tls") or {}).get("ja4")),
("HTTP/2 fingerprint", http2.get("akamai_fingerprint"), (base_network.get("http2") or {}).get("akamai_fingerprint")),
):
if current_value and old_value and current_value != old_value:
record("INFO", f"{name} changed from baseline")
for level, message in results:
print(f"[{level}] {message}")
warnings = sum(level == "WARN" for level, _ in results)
print(f"\nWarnings: {warnings}")
return warnings
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--input", type=Path, default=Path("fingerprint.json"))
parser.add_argument("--baseline", type=Path)
parser.add_argument("--fail-on-warn", action="store_true")
args = parser.parse_args()
current = json.loads(args.input.read_text(encoding="utf-8"))
baseline = json.loads(args.baseline.read_text(encoding="utf-8")) if args.baseline else None
warning_count = audit(current, baseline)
if args.fail_on_warn and warning_count:
raise SystemExit(1)
Checking baseline.json against itself produces 8 [PASS] lines, 2 [INFO] lines, and Warnings: 0.
Testing a spoofed Firefox User-Agent
Now override only the User-Agent to Firefox 140 while keeping the exact same Chromium launch:
python3 probe.py \
--user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:140.0) Gecko/20100101 Firefox/140.0" \
--out spoofed-firefox.json
python3 audit.py --input spoofed-firefox.json --baseline baseline.json --fail-on-warn

Both the HTTP header and navigator.userAgent switched to Firefox/140.0. Everything underneath stayed on Chromium:

[PASS] HTTP and JavaScript User-Agents match
[PASS] Reported platforms agree
[WARN] User-Agent claims Firefox, but Client Hints identify Chromium
[PASS] HTTP and JavaScript Client Hint platforms match
[PASS] HTTP and JavaScript mobile indicators match
[PASS] HTTP and JavaScript browser brands match
[PASS] HTTP/2 negotiated and fingerprint details captured
[INFO] JA4 captured; browser family cannot be inferred from it alone
[INFO] Browser reports automation via navigator.webdriver
[WARN] User-Agent changed from Chromium to Firefox, while JA4 and HTTP/2 fingerprints still match the Chromium baseline
Warnings: 2
Notice two subtle points in that output. First, checking HTTP and JavaScript User-Agents match alone would have passed, because Playwright updated both strings to Firefox. Second, HTTP and JavaScript browser brands match also passed because both sec-ch-ua and navigator.userAgentData.brands continued reporting Chromium 158. Only the cross-layer rules comparing the claimed family against Client Hints and against the baseline JA4/HTTP/2 profile raised warnings and exited with code 1.
Meanwhile, the TLS ja3_hash shifted across every launch (4d6c7883654b2fd351caf9d95ac221d4 on baseline run 1, 6db4e10a3cb82dddbf06bc21a17486ac on a second identical Chrome run, and 341a1e419230d27f4c96ff023e7eb3e1 on the Firefox override) while ja4 stayed locked at t13d1517h2_8daaf6152771_cb7bf5808d99. That instability is why audit.py tracks JA4 and leaves JA3 out of baseline checks.
Keeping fingerprints consistent in production

- Pin your Playwright package version and install the matching Chromium build (
pip freezeoruv sync --frozenplusplaywright install chromium) so upgrades do not shift Client Hints or TLS extensions unexpectedly. - Keep one baseline file per OS, headless mode, and proxy configuration. A Linux container running headless Chromium will not match a local macOS browser, and a TLS-terminating proxy alters what diagnostic endpoints see.
- Gate deploys and browser upgrades with
--fail-on-warn. Only[WARN]contradictions fail the build;[INFO]drift notifications prompt a manual baseline review after legitimate browser updates.
When consistency checks are not enough
Zero warnings from audit.py confirm that TLS, HTTP/2, Client Hints, and basic navigator fields agree. Anti-bot defenses still evaluate IP reputation, request cadence, TLS/browser timing, Canvas and WebGL telemetry, and navigator.webdriver.
If keeping headless browsers consistent on targets like TikTok or X takes more time than building the data pipeline itself, managed scrapers handle the request layer for you. You can pull structured TikTok data with Ultimate TikTok Scraper or collect X tweets and search results through Advanced X.com Twitter API without maintaining Playwright pools or proxy rotations. Both run on Apify, which includes free monthly credit to test small runs first.