Unsupported state or unable to authenticate data: AES-GCM
Unsupported state or unable to authenticate data is OpenSSL's one-line verdict that a GCM tag did not match, and it deliberately refuses to say which of your inputs was wrong. A wrong key, a wrong AAD, a single flipped byte in the tag, a missing AAD on the decrypt side and a truncated ciphertext all produce that exact sentence in Node — and the same code ported to Cloudflare Workers prints Authentication failed instead, or No auth tag provided when the tag is provided. This post puts both runtimes side by side, shows the seven cases I ran against each, and ends with a decrypt helper that produces one predictable failure mode in both.
TL;DR: the string names a state machine, not a bug. In Node, the order of update() and setAuthTag() does not matter; in workerd it does, and the wrong order reports a missing tag. In Node, update() hands back plaintext before final() has verified anything, while workerd refuses at the first call with No auth tag provided. Node rejects a 96-bit tag unless you opt in with authTagLength; workerd accepts it with no option at all. Same algorithm, same inputs, three different strings.
What the message is actually telling you
AES-GCM is an AEAD mode: encryption produces ciphertext plus a 16-byte authentication tag, and decryption recomputes that tag over the ciphertext, the nonce and the additional authenticated data. If the recomputed tag differs from the one you supplied, OpenSSL raises the same error for every cause, because telling an attacker which input was wrong would leak information about the key. OpenSSL 3 spells it Unsupported state or unable to authenticate data, and Node surfaces that string unchanged.
So the string is not diagnostic. The diagnosis has to come from the cases you can enumerate: is the key the one used to encrypt, is the AAD byte-identical on both sides, is the tag the full 16 bytes, is the ciphertext complete, and did the runtime even receive the tag you set? Each of those is testable, and each produces a different state inside the cipher object before the string appears.
The state machine explains where the message lands. update() decrypts as it goes and returns plaintext immediately; final() is where the tag comparison happens and where the exception is raised. That ordering decides whether an exception can arrive after output has already left the process — the subject of a later section.
A reuse attempt produces a third message that has nothing to do with cryptography: empty final after final => Error: Invalid state. Cipher objects are single-use, so retry logic that holds a Decipheriv in a variable and calls final() again after a caught failure reports a state error instead of the authentication failure that started it, and the original cause disappears from the logs.
The two runtimes I measured are node v26.12.1 on Linux/aarch64, and the workerd build bundled with wrangler 4.157.0 running wrangler dev locally with compatibility_date: 2026-10-30 and the nodejs_compat flag. Same key material, same 12-byte nonce, same AAD hdr, same 14-byte plaintext attack at dawn. Every line quoted below is pasted from those runs.
Seven failures, two runtimes: the table
The first transcript is Node. Each line creates a fresh decipher, sets the AAD, decrypts and finishes; the label says which input I changed. The "tag after update" line is the order most Node code writes, because setAuthTag() reads naturally just before final().
node v26.12.1
correct => OK "attack at dawn"
tag after update => OK "attack at dawn"
tag before update => OK "attack at dawn"
flipped tag byte => Error: Unsupported state or unable to authenticate data
wrong aad => Error: Unsupported state or unable to authenticate data
wrong key => Error: Unsupported state or unable to authenticate data
12-byte tag => TypeError: Invalid authentication tag length: 12
no setAuthTag, update only => OK "attack at dawn"
no setAuthTag, final called => Error: Unsupported state or unable to authenticate data
setAuthTag twice => Error: Invalid state for operation setAuthTag
no aad on decrypt => Error: Unsupported state or unable to authenticate data
empty final after final => Error: Invalid state
Four separate inputs — flipped tag, wrong AAD, wrong key, AAD omitted on decrypt — collapse into one string, which is why the message tells you nothing on its own. Two lines matter more than the rest and neither is the obvious one: tag after update succeeded, and no setAuthTag split into two results depending on how far the decrypt got. I will come back to both.
The same code path inside a Worker, with the tag set before the update, gives a different vocabulary:
A correct (tag before update) => OK "attack at dawn"
B flipped tag => Error: Authentication failed
C wrong aad => Error: Authentication failed
D no aad => Error: Authentication failed
E 12-byte tag => OK "attack at dawn"
F truncated ciphertext => Error: Authentication failed
G wrong key => Error: Authentication failed
Same seven causes, one string that is shorter and easier to grep for, and two rows that contradict Node: row E accepted a 96-bit tag that Node rejects by default, and the corresponding "tag after update" case — run separately, quoted in the next section — throws instead of decrypting.
The order of setAuthTag() is a portability bug
In Node, update() before setAuthTag() works because the tag is consumed when final() runs. In workerd's node:crypto implementation the tag is bound at the moment you call setAuthTag(), and a call made after the first update() is dropped. The error does not say "set the tag earlier"; it says the tag is missing, which sends you looking for the wrong bug entirely:
correct => Error: No auth tag provided
tag after update => Error: No auth tag provided
tag before update => OK "attack at dawn"
no setAuthTag => Error: No auth tag provided
setAuthTag twice => Error: Auth tag is already set
Note the first line. In that probe the "correct" case used the same fresh() helper that decrypted before setting the tag, so even a byte-perfect ciphertext reported a missing tag. That is the shape of the bug in production: the ciphertext and key are fine, the code looks right, and the runtime blames an input you can see in the source. If you port a Node decrypt function to Workers and see No auth tag provided with a tag literal two lines above the failing call, reorder the calls before you touch the key.
The documented Node requirement is that setAuthTag() is called once before final(); the measured behaviour above shows that both orders satisfy it, and that workerd only honours the earlier one. A runtime is free to bind the tag when it is handed over. Writing the tag before the first update() costs nothing in Node and makes the same module correct in both runtimes — which is what the helper at the end of this post does.
update() hands you plaintext before the tag is checked
Node binds the tag at final(). Until then the cipher is decrypting the keystream and returning bytes, and the tag comparison only happens when you call final() — which is where Unsupported state or unable to authenticate data comes from when no tag was ever set. The two measured lines from the Node transcript make the split explicit: update only returned the plaintext, and final called then threw.
workerd binds earlier. The same omission fails at the first call:
# wrangler dev, compatibility_date 2026-10-30, nodejs_compat
no setAuthTag, update only => Error: No auth tag provided
no setAuthTag, final called => Error: No auth tag provided
12-byte tag, no options => OK "attack at dawn"
12-byte tag, authTagLength 12 => OK "attack at dawn"
16-byte tag, authTagLength 12 => OK "attack at dawn"
So neither runtime decrypts without verification silently in the end — but only one of them refuses before the plaintext exists. In Node, a handler that writes each update() chunk to a socket or a file has emitted unverified bytes by the time final() throws, and a catch that keeps the buffer it already wrote turns a failed authentication into a successful response. In workerd that sequence cannot happen: the first update() throws, and the buffer is empty.
This is the difference that survives a migration. A Node service with a try/catch wrapped around the decrypt loop, returning whatever it accumulated, can pass its tests today — the throw is caught, the response is built from the bytes update() produced, and nothing in the response says the tag was never compared. The same code in Workers fails hard. The new error is not a regression: it is the first time the omission was reported.
Which is why the test worth writing is not "does the happy path work" but "does a corrupted tag change the outcome": encrypt, flip one byte of the tag, decrypt, and assert that the response is not built. A path that still returns plaintext for a corrupted tag is decoding, not decrypting.
96-bit tags: Node needs an option, workerd needs none
GCM permits truncated tags; NIST SP 800-38D allows any tag length of 96 bits or more, with 128 bits recommended, and every 32 bits you drop lowers forgery resistance by 2^32. Node defaulted to the recommended length and rejects anything shorter at the API boundary, but the length is configurable — measured in the same runtime:
12-byte tag default opts => TypeError: Invalid authentication tag length: 12
12-byte tag with authTagLength 12 => OK "attack at dawn"
12-byte tag from full-tag ciphertext, authTagLength 12 => TypeError: Invalid authentication tag length: 16
So Node supports 96-bit tags if you ask: createDecipheriv('aes-256-gcm', key, iv, { authTagLength: 12 }). The option is a strict contract, not a maximum — the third line shows a 16-byte tag rejected because the cipher was told to expect 12.
workerd accepted a 12-byte tag with no option at all, and took a 16-byte tag while authTagLength: 12 was set (rows three to five of the previous transcript), so the option is advisory there. Neither behaviour is a bug: one runtime treats the tag length as part of the cipher's configuration, the other as a property of the tag it is handed. The consequence is practical rather than academic — the same decrypt call is a hard failure in Node and a success in Workers when a tag arrives short, so a truncated tag can pass through a Workers service that would have stopped it one layer earlier. Fix the length in your storage format and check it before the cipher sees it, which is the first thing the helper does.
crypto.subtle prints a third string, and it is longer
Workers code usually reaches for WebCrypto rather than node:crypto, and the failure text there is different again — an OperationError with an explanation attached. Measured in the same Worker:
subtle correct => OK "attack at dawn"
subtle flipped tag => OperationError: Decryption failed. This could be due to a ciphertext authentication failure, bad padding, incorrect CryptoKey, or another algorithm-specific reason. Input length was 14, output length expected to be 14 for AES-GCM
subtle missing aad => OperationError: Decryption failed. This could be due to a ciphertext authentication failure, bad padding, incorrect CryptoKey, or another algorithm-specific reason. Input length was 14, output length expected to be 14 for AES-GCM
The trailing sentence — input length, expected output length — is the useful part and the reason to prefer this path for new code: it reports the ciphertext length it actually received. A GCM ciphertext is the same length as its plaintext, so both numbers matching tells you the buffer is whole and the tag is accounted for separately, narrowing the fault to the key, the nonce or the AAD. The same message appears when the nonce differs between encrypt and decrypt, which is the most common real cause in Workers code: the nonce was regenerated instead of stored.
Note what the WebCrypto path does not have: an ordering hazard. There is no setAuthTag(); the tag is the last 16 bytes of the buffer you pass, so the whole class of "tag set too late" bugs disappears. If your Workers code does not need a streaming Node API, this is the safer interface to write against, and it fails closed the same way under both runtimes.
A decrypt helper that behaves the same in both runtimes
The helper below is the one I ran in Node and in the Worker. It does three things that the naive version does not: it validates the tag length before touching the cipher (so the 96-bit case becomes your error, not the runtime's), it sets the tag before the first update() (so workerd binds it), and it never wraps final() in a catch that discards the buffer.
import crypto from 'node:crypto';
const MIN_TAG = 16;
export function openGcm(sealed, key, iv, aad) {
const tag = sealed.tag;
if (tag.length !== MIN_TAG) {
throw new Error('tag must be ' + MIN_TAG + ' bytes, got ' + tag.length);
}
const d = crypto.createDecipheriv('aes-256-gcm', key, iv);
if (aad !== undefined) d.setAAD(aad);
d.setAuthTag(tag);
const plain = Buffer.concat([d.update(sealed.ct), d.final()]);
return plain;
}
Its behaviour, with the same three test cases run in each runtime:
# node v26.12.1
round trip => OK "attack at dawn"
truncated tag => Error: tag must be 16 bytes, got 12
wrong aad => Error: Unsupported state or unable to authenticate data
# wrangler dev, compatibility_date 2026-10-30, nodejs_compat
round trip => OK "attack at dawn"
truncated tag => Error: tag must be 16 bytes, got 12
wrong aad => Error: Authentication failed
The first two lines are now identical in both runtimes, which is the point: the length contract is yours, so the message is yours. The third line still differs, and it always will, because the runtime owns that string. Which is why the caller should not match on the text at all — catch the error, treat any thrown value as "do not use this plaintext", and log the type name plus the length of the tag you received. Unsupported state or unable to authenticate data and Authentication failed mean the same thing, and code that greps for either one breaks on the next runtime.
The diagnostic order that resolves this in five checks
When the string appears in a service you did not write, the causes are not equally likely, and two of them can be ruled out without a debugger:
1. Is the tag present at all? Log tag.length at the call site. Zero or undefined means the tag never made it out of storage: in Workers that surfaces as No auth tag provided at the first update(), in Node as plaintext from update() followed by a throw from final() — and any code that caught the throw and kept the buffer has served unverified bytes.
2. Is it 16 bytes? Base64url-encoded tags are 22 characters; hex is 32. A tag that survived a JSON round trip through a lossy encoder can arrive at 12 bytes, which Node rejects as a type error and workerd accepts silently.
3. Is the AAD byte-identical? An empty string is not the same as undefined: passing '' sets AAD to zero bytes, omitting it sets none, and in most bindings those produce different tags. Compare the AAD on both sides as hex, not as a string read by eye.
4. Is the nonce the one used to encrypt? GCM fails authentication, not decryption, when the nonce differs, so a regenerated nonce is indistinguishable from a corrupted ciphertext until you compare the stored bytes.
5. Is the ciphertext complete? A truncated body — a proxy limit, a stream cut short, a column sized for the old plaintext — fails the same way. The WebCrypto message prints the input length, which makes this the one case where a runtime tells you something concrete.
Order matters because checks 1 and 2 are free and eliminate the two cases where the system is quietly unauthenticated. If both pass, the fault is in the inputs, and no amount of reading the error text will name which one.
What this does not cover
Nothing here addresses key management: where the key lives, who can read it, or how it rotates. That is a different problem with a different threat model, and a post that hand-waves it would be worse than no post. The scope is narrower and fully measured: the three strings a GCM decrypt produces in two runtimes, the seven input mutations that trigger them, and the two API-shape differences — tag ordering and tag length — that decide which string you see.
Two related pieces on this site cover the neighbouring failure: importKey on a PEM secret for the import side of the same WebCrypto surface, and JWT InvalidSignatureError for the same "one string, five causes" shape in signature verification. The pattern repeats across crypto APIs: the runtime collapses every integrity failure into one message, and the work is enumerating the inputs it refuses to name.