HSEC-2026-0019: Signed-byte malleability and deferred exception in decodeSignedObject

Published Dec 6, 2026
·
Updated

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.

Affected Software

2 affected componentsFixes available
hackage/crypton-x509>=1.7.6<1.11.1
1.11.1
hackage/x509>=1.4.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade hackage/crypton-x509 to a version that resolves this vulnerability.

    Fixed in 1.11.1
  2. Upgrade

    Upgrade crypton-x509 to a version that resolves this vulnerability.

    Fixed in 1.11.1

Event History

Dec 6, 2026
Advisory Published
via OSV·09:29 PM
Data Sourced
via OSV·09:29 PM
DescriptionSeverityAffected Software

Frequently Asked Questions

1

What must an attacker have to exploit the signature-validation issue?

An attacker needs a genuine certificate or other signed object that they can re-encode. The issue allows multiple encodings of the same signed content to retain a valid signature while producing different raw encodings and fingerprints.

2

Which encodings are relevant to the malleability issue?

Examples include non-minimal long-form lengths or high-tag-number encoding on the tbsCertificate SEQUENCE. The outer Certificate SEQUENCE could also be encoded with indefinite length, a high-tag-number tag, or other accepted non-DER forms outside the signed portion.

3

How could this affect systems that identify certificates by fingerprint?

The same signed certificate content can have a different getFingerprint value after re-encoding, even though getSignedData and signature verification remain identical to the original. Systems that rely on fingerprints as a unique identity or allowlist key may therefore treat a re-encoded copy differently.

4

Which decoding APIs are affected?

The behavior is in decodeSignedObject and therefore also affects decodeSignedCertificate and decodeSignedCRL.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203