ory/hydra · error
ciphertext too short
Error message
ciphertext too short
What it means
Returned by openAEAD when a decrypted page token's raw bytes are shorter than the AEAD nonce size. The token is malformed or truncated: it cannot even be split into nonce and ciphertext, so authentication is never attempted.
Source
Thrown at oryx/pagination/keysetpagination_v2/page_token.go:236
}
if err := json.Unmarshal(dec, t); err != nil {
if errors.As(err, new(*herodot.DefaultError)) {
return err
}
return errors.WithStack(herodot.ErrInternalServerError().WithReason("unable to unmarshal page token").WithDebug(err.Error()))
}
return nil
}
func openAEAD(key [32]byte, raw []byte) ([]byte, error) {
a, err := aead.New(key)
if err != nil {
return nil, errors.Wrap(err, "cannot create AEAD")
}
if len(raw) < a.NonceSize() {
return nil, errors.New("ciphertext too short")
}
nonce, ciphertext := raw[:a.NonceSize()], raw[a.NonceSize():]
bs, err := a.Open(nil, nonce, ciphertext, []byte(pageTokenContext))
if err != nil {
return nil, errors.Wrap(err, "cannot open AEAD")
}
return bs, nil
}
View on GitHub (pinned to 4174065ffb)
Solutions
- Treat the token as invalid and return the first/unpaged result set instead of failing the request
- Check token length before calling decrypt and short-circuit to the invalid-token path
- Regenerate a valid token by issuing a fresh first-page request
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at oryx/pagination/keysetpagination_v2/page_token.go:236 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03).
Data as JSON: /api/errors/dddc323e95e4a388.
Report an issue: GitHub.