HSEC-2026-0019

See a problem?
Import Source
https://github.com/haskell/security-advisories/blob/generated/osv-export/2026/HSEC-2026-0019.json
JSON Data
https://api.osv.dev/v1/vulns/HSEC-2026-0019
Published
2026-12-06T21:29:17Z
Modified
2026-12-06T21:45:02Z
Summary
Signed-byte malleability and deferred exception in decodeSignedObject
Details

Signed-byte malleability and deferred exception in decodeSignedObject

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.

Differently encoded copies of a certificate keep a valid signature

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:

  • a non-minimal long-form length, or a high-tag-number tag, on the tbsCertificate SEQUENCE;
  • the outer Certificate SEQUENCE made indefinite-length, given a high-tag-number tag, or preceded by an end-of-contents header;
  • a non-minimal length or high-tag-number tag on the signatureAlgorithm SEQUENCE;
  • a non-minimal length on the signature BIT STRING, or an unused-bits octet of 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 successfully decoded certificate can throw later

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.

Fix

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.

Database specific
{
    "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"
}
References

Affected packages

Hackage / crypton-x509

Package

Name
crypton-x509
Purl
pkg:hackage/crypton-x509

Severity

  • 6.5 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L CVSS Calculator

Affected ranges

Type
ECOSYSTEM
Events
Introduced
1.7.6
Fixed
1.11.1

Affected versions

1.*
1.7.6
1.7.7
1.8.0
1.9.0
1.9.1
1.9.2
1.10.0
1.10.1
1.10.2
1.10.3
1.11.0

Ecosystem specific

{
    "affected_api":  [
        {
            "module":  "Data.X509",
            "name":  "decodeSignedObject"
        },
        {
            "module":  "Data.X509",
            "name":  "decodeSignedCertificate"
        },
        {
            "module":  "Data.X509",
            "name":  "decodeSignedCRL"
        }
    ]
}

Database specific

human_link
"https://github.com/haskell/security-advisories/tree/main/advisories/published/2026/HSEC-2026-0019.md"
osv
"https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export/2026/HSEC-2026-0019.json"
source
"https://github.com/haskell/security-advisories/blob/generated/osv-export/2026/HSEC-2026-0019.json"

Hackage / x509

Package

Name
x509
Purl
pkg:hackage/x509

Severity

  • 6.5 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:L CVSS Calculator

Affected ranges

Type
ECOSYSTEM
Events
Introduced
1.4.0

Affected versions

1.*
1.4.0
1.4.1
1.4.2
1.4.3
1.4.4
1.4.5
1.4.6
1.4.7
1.4.8
1.4.9
1.4.10
1.4.11
1.4.12
1.4.13
1.5.0
1.5.0.1
1.5.1
1.6.0
1.6.1
1.6.2
1.6.3
1.6.4
1.6.5
1.7.0
1.7.1
1.7.2
1.7.3
1.7.4
1.7.5
1.7.6
1.7.7

Ecosystem specific

{
    "affected_api":  [
        {
            "module":  "Data.X509",
            "name":  "decodeSignedObject"
        },
        {
            "module":  "Data.X509",
            "name":  "decodeSignedCertificate"
        },
        {
            "module":  "Data.X509",
            "name":  "decodeSignedCRL"
        }
    ]
}

Database specific

human_link
"https://github.com/haskell/security-advisories/tree/main/advisories/published/2026/HSEC-2026-0019.md"
osv
"https://raw.githubusercontent.com/haskell/security-advisories/refs/heads/generated/osv-export/2026/HSEC-2026-0019.json"
source
"https://github.com/haskell/security-advisories/blob/generated/osv-export/2026/HSEC-2026-0019.json"