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

Apple OS X and iOS x509 certificate parsing Name Constraints Remote Code Execution Vulnerability

A use-after-free flaw in Apple's x509 certificate parsing of the nameConstraints extension means a specially crafted certificate causes a freed memory buffer to be released again. An attacker could serve such a certificate over HTTPS or deliver it as a file, potentially leading to remote code execution or a crash loop that makes the system unusable.

Aleksandar Nikolic Follow

Originally disclosed on Cisco Talos

High 8.8 View original

An exploitable use-after-free vulnerability exists in the x509 certificate validation functionality in Apple macOS Sierra (10.12.3 release and 10.12.4 public beta versions) and iOS 10.2.1. A specially crafted x509 certificate can trigger a use-after-free vulnerability potentially 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

Likely a stale pointer: when DER sequence decoding of the nameConstraints general subtrees fails, the newly allocated array is stored in the certificate structure and then released, leaving a dangling reference that is freed again later.

Impact

The crafted certificate causes a crash and undefined behaviour that could potentially lead to remote code execution; a crashing certificate imported into the keychain can also loop the trust agent and render the system unable to connect to any TLS server.

What the attacker needed

Victim visits a malicious HTTPS site; or victim opens a certificate file; or connects to a malicious mail server

How it was found

  1. Create a sample certificate with a nameConstraints extension using openssl.
  2. Modify the certificate's nameConstraints sequence so that decoding fails.
  3. Run the security verify-cert command against the crafted certificate to observe the crash.
  4. Alternatively, serve the crafted certificate from a test TLS server and visit it in a browser to see the networking process crash.

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 your device connects to a secure website, the server sends a certificate that the device must check. A bug in that checking code meant a malformed certificate could make the device free a piece of memory and then use it again, which can crash programs or, in theory, let an attacker run their own code. The victim only had to visit a malicious site or open a certificate file.

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.