transport protocols · lesson 3 of 8 · sources checked 2026-11-20
tls 1.3: the clienthello and the handshake
This lesson shows the fields of a TLS 1.3 ClientHello, why they are in cleartext, and how a fingerprint method reads them.
status of this lesson: documented in my test systempurpose
Each TLS connection starts with a ClientHello that the server reads before it sends a byte of the page. The TLS stack of the client gives the ClientHello its shape, not the page. Thus a server can name the family of the TLS stack before any page script runs, also when the bytes change on each connection.
objectives
- Identify the fields of a ClientHello that are in cleartext, and explain why they are in cleartext.
- Describe how GREASE and a random extension order change a ClientHello.
- Explain how a fingerprint method makes the ClientHello of one client stable again.
- Read the size of a ClientHello with a hybrid key share from a lab result.
new terms
- benchmark platform
- My test system. It runs browsers and tools against test pages and records the result.
- JA3
- An MD5 hash over the TLS version, cipher suites, extensions, curves, and point formats of a ClientHello, in wire order.
- parse
- To read a document and build a structure from it.
- GREASE
- Random reserved values that a client adds to TLS lists to keep servers tolerant of unknown values (RFC 8701).
- hybrid key exchange
- A TLS key exchange that combines a classic group and a post-quantum method, for example `X25519MLKEM768`.
- parser
- A program that reads HTML or another format and builds a tree or a list of values.
how it works
why the clienthello is in cleartext
The TLS handshake agrees on keys. Before the first message, the client and the server have no shared key. Thus the first message cannot be encrypted.
RFC 9846 states that a client must send the ClientHello as its first TLS message. It also states that all handshake messages after the ServerHello are encrypted RFC Editor, source 1. The ClientHello has these fields, in wire order:
legacy_version, with the value0x0303;random, 32 random bytes;legacy_session_id;cipher_suites, the list of cipher suites;legacy_compression_methods;extensions, for examplesupported_versions,key_share, andsignature_algorithms.
The supported_versions extension gives the TLS versions of the client. The key_share list gives the key shares in the order of preference of the client. Thus each field shows a choice of the TLS stack.
ECH encrypts the ClientHello under a public key of the server RFC Editor, source 2. An outer ClientHello stays in cleartext, because the server must read it first.
the parse rules
The code of the benchmark platform, my test system, reads the first TLS record of a connection before the TLS endpoint completes the handshake.
The code also removes each GREASE value before it computes a JA3 or a JA4 value.
RFC 9846 gives the parts that a tool parses, in this order RFC Editor, source 1:
- The record header: the type 22 (handshake), the version, and the length.
- The handshake header: the type 1 (client_hello) and the length.
- The fixed fields, in wire order.
- Each extension: its type, its length, and its body.
The code example prints GREASE in place of a reserved GREASE value, for example 0x0a0a.
grease
status of this section: from a public sourceRFC 8701 reserves values that a client can put into its lists at random. A server that refuses an unknown value then fails to work with such a client, and the fault shows early IETF, source 3. The values are 0x0A0A, 0x1A1A, and so on to 0xFAFA.
A client can put GREASE values into the cipher suites, the extensions, the groups, the signature algorithms, the versions, and the ALPN list. A server must ignore them and must not select one. Thus a GREASE value changes the bytes of each connection, but not the meaning.
a random order of the extensions
claim of a company In 2023, Google stated in Chrome Platform Status that Chrome 110 put the ClientHello extensions in a random order. The stated aim was less brittleness in the TLS ecosystem Google, source 4.
A fingerprint that reads the extensions in wire order then changes for each connection. The JA3 README gives the fields of JA3: the version, the ciphers, the extensions, the curves, and the point formats, with an MD5 hash. JA3 ignores GREASE values Salesforce, source 5.
how a fingerprint method normalizes
The JA4 method sorts the ciphers and the extensions in hex order before it makes each hash. It ignores GREASE values. It removes the SNI and the ALPN extensions from the extension hash, but it keeps the signature algorithms in their order FoxIO, source 6.
For example, the JA4 page gives the value t13d1516h2_8daaf6152771_e5627efa2ab1. The first part of the value, part a, gives TLS over TCP, version 1.3, an SNI, 15 ciphers, 16 extensions, and ALPN h2. Thus the random order does not change the result, and the set of extensions still names the family of the TLS stack.
The code of the benchmark platform also removes each GREASE value before it computes a JA3 or a JA4 value.
the hybrid key share
A hybrid key exchange adds a post-quantum share to the classic share. RFC 10024 gives a client share of 1,216 bytes: 1,184 bytes for the ML-KEM part and 32 bytes for X25519 RFC Editor, source 7. Thus the ClientHello becomes much larger.
the two sides
| automation side | detection side |
|---|---|
| The TLS stack decides the ClientHello. A random order of the extensions changes some hashes on each connection, but not the set of extensions. | The ClientHello is cleartext and mandatory. It names the family of the TLS stack before the first HTTP byte. GREASE and the random order force the detector to normalize. |
design decisions
| option | gain | cost | when it is correct |
|---|---|---|---|
| Hash the extensions in wire order (JA3) | It is simple, and old records use it. | A random order gives a new hash for each connection. | For a client with a fixed order |
| Sort the lists before the hash (JA4) | The value stays stable for one TLS stack. | It loses the order, which is also a signal. | For each client that sets a random order |
| Keep the raw ClientHello | Each field stays available for a new method. | It costs storage, and it holds the SNI. | For a lab or a short window of records |
| Read only part a of JA4 | It is readable and short. | Different TLS stacks can share one part a. | For a first sort into groups |
diagram
the tcp handshake and the tls 1.3 handshake on one time axis, with one rtt for each exchange
the fields of a clienthello in wire order, with the grease places and the fields that a fingerprint reads
- Record headerType 22 (handshake), version 0x0301, length.
- Handshake headerType 1 (client_hello), length.
- legacy_versionAlways 0x0303. JA4 reads the version from supported_versions.
- random and legacy_session_idRandom bytes. JA3 and JA4 do not read them.
- cipher_suitesCan hold GREASE. JA3 and JA4 read the list.
- legacy_compression_methodsA list of methods. JA3 and JA4 do not read it.
- extensionsCan hold GREASE. The order can change for each connection. JA4 sorts the list.
- server_name (SNI)Cleartext host name. ECH moves it into the encrypted inner ClientHello.
- supported_groups and key_shareCan hold GREASE. The hybrid client share has 1,216 bytes.
- signature_algorithmsCan hold GREASE. JA4 keeps their order.
- alpn and supported_versionsCan hold GREASE. Part a of JA4 shows ALPN characters and the version.
code example
The example parses a synthetic TLS record that holds a ClientHello. It prints the fields in wire order, and it prints each GREASE value as GREASE.
example The record is synthetic. The host name is a reserved example name, and the key share is 32 equal bytes.
Parse a synthetic TLS record and print the ClientHello fields in wire order, with each GREASE value marked.
// Parse one synthetic TLS record that holds a ClientHello. Print the fields in wire order.
// The argument is a hex string. With no argument, the code uses a synthetic record.
const SAMPLE =
"16030100ae010000aa0303000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f" +
"0000080a0a130113021303010000790a0a000000000010000e00000b6578616d706c652e636f6d000a000a" +
"00080a0a11ec001d0017000d000800060403080404010010000e000c02683208687474702f312e31002b00" +
"07060a0a03040303003300260024001d002042424242424242424242424242424242424242424242424242" +
"42424242424242";
const b = Buffer.from((process.argv[2] ?? SAMPLE).replace(/\s/g, ""), "hex");
const EXT: Record<number, string> = { 0: "server_name", 10: "supported_groups",
13: "signature_algorithms", 16: "alpn", 43: "supported_versions", 51: "key_share" };
const isGrease = (v: number) => (v & 0x0f0f) === 0x0a0a && v >> 8 === (v & 0xff);
const hex = (v: number) => (isGrease(v) ? "GREASE" : "0x" + v.toString(16).padStart(4, "0"));
const list16 = (d: Buffer) => {
const out: string[] = [];
for (let i = 0; i + 1 < d.length; i += 2) out.push(hex(d.readUInt16BE(i)));
return out.join(" ");
};
let p = 0;
console.log(`record type ${b[0]}, version ${hex(b.readUInt16BE(1))}, length ${b.readUInt16BE(3)}`);
p = 5;
console.log(`handshake type ${b[p]} (client_hello is 1)`);
p += 4;
console.log(`legacy_version ${hex(b.readUInt16BE(p))}`);
p += 2 + 32; // the random value: 32 bytes, not printed
p += 1 + b[p]; // legacy_session_id
const cLen = b.readUInt16BE(p);
console.log(`cipher_suites ${list16(b.subarray(p + 2, p + 2 + cLen))}`);
p += 2 + cLen;
p += 1 + b[p]; // legacy_compression_methods
const end = p + 2 + b.readUInt16BE(p);
p += 2;
while (p < end) {
const type = b.readUInt16BE(p);
const len = b.readUInt16BE(p + 2);
const d = b.subarray(p + 4, p + 4 + len);
let detail = `${len} bytes`;
if (type === 0) detail = `host ${d.subarray(5).toString("ascii")}`;
if (type === 10 || type === 13) detail = list16(d.subarray(2));
if (type === 43) detail = list16(d.subarray(1));
if (type === 51) detail = `group ${hex(d.readUInt16BE(2))}, share ${d.readUInt16BE(4)} bytes`;
if (type === 16) {
const ids: string[] = [];
for (let i = 2; i < d.length; i += 1 + d[i]) ids.push(d.subarray(i + 1, i + 1 + d[i]).toString("ascii"));
detail = ids.join(" ");
}
const label = isGrease(type) ? "GREASE" : EXT[type] ?? hex(type);
console.log(`extension ${label}: ${detail}`);
p += 4 + len;
}output
The record header, the handshake type, the version, the cipher suites, and one line for each extension.
record type 22, version 0x0301, length 174
handshake type 1 (client_hello is 1)
legacy_version 0x0303
cipher_suites GREASE 0x1301 0x1302 0x1303
extension GREASE: 0 bytes
extension server_name: host example.com
extension supported_groups: GREASE 0x11ec 0x001d 0x0017
extension signature_algorithms: 0x0403 0x0804 0x0401
extension alpn: h2 http/1.1
extension supported_versions: GREASE 0x0304 0x0303
extension key_share: group 0x001d, share 32 bytesI ran the code with the Node runtime and the flag --experimental-strip-types, with no argument. The output shows GREASE in the cipher suites, in the extensions, in the groups, and in the versions. The extension lines come in the order of the bytes.
data
size of the first tls record with and without a hybrid key share
status of this figure: measured by me
source: Lab result of this course: first TLS record of one lab browser on loopback; date 2026-11-18; sample of 168; condition: One lab browser, loopback, a raw TCP listener that reads the first record. The target had no server name.
data table
| series | key share setting | bytes |
|---|---|---|
| With hybrid key share | first TLS record | 1733 |
| Without hybrid key share | first TLS record | 517 |
The chart shows a lab result of this course: the first TLS record of one lab browser, with and without the hybrid key share. The record with the share is much larger. The difference of the two medians is close to the size of the client share in RFC 10024.
In my model, the size of the first record is one more part of the ClientHello shape. For example, a client can claim a browser that sends a hybrid key share and still send a small first record. A detector can read that as a mismatch between the claimed client and its TLS stack.
failure modes
| problem | cause | correction |
|---|---|---|
| One browser gives a new JA3 value on each connection. | The browser sets a random order of the extensions. | Use a method that sorts the lists, for example JA4. |
| A parser reports an unknown extension on each connection. | The extension is a GREASE value. | Mark each reserved GREASE value, and ignore it in the hash. |
| A parser stops at a large ClientHello. | A hybrid key share makes the record larger than the first block that the parser reads. | Read the full record length from the header before you parse. |
| Two different clients give the same JA4 value. | The two clients use the same TLS stack. | Compare the other protocol layers too, for example the HTTP/2 preface. |
| The SNI field does not name the host of the request. | The client uses ECH, and the real SNI is in the inner ClientHello. | Read the outer SNI only as the name of the ECH server. |
check questions
Explain why the ClientHello is in cleartext, and name three of its fields.
sample answer
The ClientHello is the first TLS message, and before it the client and the server have no shared key. Thus it cannot be encrypted. Its fields include legacy_version, cipher_suites, and extensions such as supported_versions and key_share.
Describe how GREASE values and a random extension order change the ClientHello of one browser.
sample answer
GREASE puts reserved values into lists such as the cipher suites and the extensions, and a server must ignore them. A random extension order changes the order of the extensions on each connection. Both change the bytes, but not the set of real values.
Explain how JA4 gives a stable value for a browser that sets a random extension order.
sample answer
JA4 sorts the ciphers and the extensions in hex order before it makes each hash. It ignores GREASE values, and it removes the SNI and ALPN extensions from the extension hash. Thus the order of the extensions does not change the value.
The lab chart gives the first TLS record of one lab browser with and without the hybrid key share. What does the difference of the two medians show?
- The time that the hybrid key share adds to the handshake
- The size that the hybrid client share adds to the record
- The number of connections that used ECH
answer
b. The size that the hybrid client share adds to the record
The chart gives sizes in bytes, not times. The difference of the medians is close to the size of the client share in RFC 10024.
exercise
exercise Do this task in your own lab, with the synthetic record of the code example. Do not send a request to a site.
- Save the code example in an empty folder of your lab.
- Run the code with Node and the flag
--experimental-strip-types. - Write the extension lines in the order of the output.
- Cross out each line that the JA4 extension hash does not use.
- Write the other extensions again in hex order.
sample answer
The answer uses the synthetic record of the code example.
The output gives GREASE, server_name, supported_groups, signature_algorithms, alpn, supported_versions, and key_share. JA4 ignores the GREASE extension, and it removes server_name and alpn from the extension hash. The other extensions in hex order are supported_groups (0x000a), signature_algorithms (0x000d), supported_versions (0x002b), and key_share (0x0033).
sources
- RFC 9846: TLS 1.3, RFC Editor, standard, read 2026-11-20
- RFC 9849: TLS Encrypted Client Hello, RFC Editor, standard, read 2026-11-20
- RFC 8701: GREASE for TLS, IETF, standard, read 2026-11-20
- TLS ClientHello extension permutation, Google, data, read 2026-11-20
- JA3 repository, Salesforce, source code, read 2026-11-20
- JA4 technical details, FoxIO, documentation, read 2026-11-20
- RFC 10024: PQ/T Hybrid Key Agreement Mechanisms for TLS 1.3, RFC Editor, standard, read 2026-11-20
- Lab result of this course: the first TLS record of one lab browser on loopback, with and without the hybrid key share, 2026-11 (not public).
- Benchmark platform, code (my test system): the read of the first TLS record and the removal of GREASE values before a fingerprint, 2026-11 (not public).
- My model of the fields of a ClientHello and the handshakes of one HTTPS request, 2026-11 (not public).