decodeSignedObject (and so decodeSignedCertificate and decodeSignedCRL)
decoded a signed object with BER and rebuilt the bytes covered by the
signature by re-serialising the decoded ASN.1 events with
Data.ASN1.BinaryEncoding.Raw.toByteString, lazily. It did not take them
from the input. This had two consequences.
The re-serialisation writes long-form lengths with the fewest octets, writes
tags in their short form, and writes nothing for end-of-contents, so several
encodings of the same tbsCertificate produce the same signed bytes. Other
parts that the signature does not cover were accepted in non-DER form too.
Starting from a genuine certificate, each of the following produced a
certificate whose getSignedData and signature were identical to the
original's, so signature verification succeeded, while the encoding and
getFingerprint differed:
tbsCertificate SEQUENCE;signatureAlgorithm
SEQUENCE;0x30 (ASCII '0') instead of 0x00.Anyone holding a certificate can therefore make copies with new fingerprints that pass signature verification. This can defeat fingerprint denylists and deduplication or caching keyed on the encoding. It does not allow changing any signed field (subject, key, validity, extensions, serial number), it does not get past a fingerprint allowlist, SPKI pinning or serial-based revocation, and TLS authentication still needs the private key. RFC 5280 requires DER for certificates for this reason.
A certificate containing a malformed long-form length inside an
indefinite-length construction decoded as Right, but the re-serialisation
could not encode the decoded length. Forcing the signed bytes
(getSignedData, or show of the SignedExact) then threw the pure
exception putLength: long length is negative. No valid signature is needed
to trigger it.
This is an availability issue for programs that force the value outside an
exception handler, for example when logging a received certificate or
loading a certificate store. crypton-x509-validation evaluates signature
verification under tryPure and reports SignatureInvalid, and tls
catches handshake failures, so default TLS clients and servers are not known
to be affected.
crypton-x509 1.11.1 takes the signed bytes from the input as received, so
an altered tbsCertificate header now fails signature verification and
getSignedData no longer throws. It also requires everything the signature
does not cover (the outer SEQUENCE, which must span the whole input, the
signatureAlgorithm and its contents, and the signature BIT STRING) to be
in DER, with an unused-bits octet of 0x00; such variants are now rejected
when decoding.
The unmaintained x509 package has the same code since at least 1.4.0 and
has no fixed release; users should move to crypton-x509 >= 1.11.1.
Reported by José Lorenzo RodrÃguez (Kronor). Fixed by Kazu Yamamoto.
{
"home": "https://github.com/haskell/security-advisories",
"osvs": "https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export",
"repository": "https://github.com/haskell/security-advisories"
}{
"affected_api": [
{
"module": "Data.X509",
"name": "decodeSignedObject"
},
{
"module": "Data.X509",
"name": "decodeSignedCertificate"
},
{
"module": "Data.X509",
"name": "decodeSignedCRL"
}
]
}
"https://github.com/haskell/security-advisories/tree/main/advisories/published/2026/HSEC-2026-0019.md"
"https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export/2026/HSEC-2026-0019.json"
"https://github.com/haskell/security-advisories/blob/generated/osv-export/2026/HSEC-2026-0019.json"
{
"affected_api": [
{
"module": "Data.X509",
"name": "decodeSignedObject"
},
{
"module": "Data.X509",
"name": "decodeSignedCertificate"
},
{
"module": "Data.X509",
"name": "decodeSignedCRL"
}
]
}
"https://github.com/haskell/security-advisories/tree/main/advisories/published/2026/HSEC-2026-0019.md"
"https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export/2026/HSEC-2026-0019.json"
"https://github.com/haskell/security-advisories/blob/generated/osv-export/2026/HSEC-2026-0019.json"