Skip to content
Memory corruption Advisory Advanced CVE-2017-2781

InsideSecure MatrixSSL x509 certificate IssuerDomainPolicy Remote Code Execution Vulnerability

The X.509 certificate parser in MatrixSSL allocates a heap array sized from the ASN.1 length of a PolicyMappings OID field, but the OID parser can produce one more element than that length. A crafted certificate therefore writes past the end of the heap buffer, which the report says can lead to remote code execution.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.1 View original

An exploitable heap buffer overflow vulnerability exists in the X509 certificate parsing functionality of InsideSecure MatrixSSL 3.8.7b. A specially crafted x509 certificate can cause a buffer overflow on the heap resulting in remote code execution.

Aleksandar Nikolic, on Cisco Talos

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The code allocates the issuerDomainPolicy array using the ASN.1 field length rather than the number of OIDs actually parsed, and the OID parser can yield one more element than that length because the first byte produces two entries.

Impact

A heap buffer overflow occurs, which the report states can result in remote code execution; the CVSS vector rates confidentiality, integrity and availability as high but attack complexity as high.

What the attacker needed

Attacker-supplied certificate; victim initiates a TLS connection

The fix

The allocation and zeroing should use the parsed OID count instead of the ASN.1 field length, as the proposed patch does.

How it was found

  1. Craft an X.509 certificate whose PolicyMappings extension contains an OID field of N bytes that decodes to N+1 OIDs.
  2. Present that certificate to a client or server application using MatrixSSL when a secure connection is initiated.
  3. The parser allocates an array for N entries but copies N+1, writing past the heap buffer.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

When a program reads a certificate, it first measures how much space a field needs and then reserves exactly that much memory. Here the measuring step and the copying step disagreed: the copy wrote one extra number past the reserved space, corrupting nearby memory. An attacker who can supply a certificate to a program using this library could use that corruption to crash it or possibly run their own code.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More by Aleksandar Nikolic

View all

147 more disclosed reports, best first.

More from Cisco Talos

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.