<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>Quarkslab's blog - mbedtls</title><link href="http://blog.quarkslab.com/" rel="alternate"></link><link href="http://blog.quarkslab.com/feeds/mbedtls.rss.xml" rel="self"></link><id>http://blog.quarkslab.com/</id><updated>2026-10-20T00:00:00+02:00</updated><entry><title>MbedTLS Security Audit</title><link href="http://blog.quarkslab.com/mbedtls-security-audit.html" rel="alternate"></link><published>2026-10-20T00:00:00+02:00</published><updated>2026-10-20T00:00:00+02:00</updated><author><name>Julio Loayza Meneses</name></author><id>tag:blog.quarkslab.com,2026-10-20:/mbedtls-security-audit.html</id><summary type="html">&lt;p&gt;At the request of the &lt;a href="https://ostif.org/"&gt;Open Source Technology Improvement Fund&lt;/a&gt; (OSTIF), Quarkslab performed a security audit of &lt;a href="https://www.trustedfirmware.org/projects/mbed-tls/"&gt;mbedTLS&lt;/a&gt;, evaluating the security of the changes in version 4.0.&lt;/p&gt;</summary><content type="html">&lt;h1 id="introduction"&gt;Introduction&lt;/h1&gt;
&lt;p&gt;&lt;a href="https://www.trustedfirmware.org/projects/mbed-tls/"&gt;Mbed TLS&lt;/a&gt; is a widely deployed open-source TLS, DTLS, and X.509 library maintained by Trusted Firmware, targeting constrained and embedded environments. 
It is used as the cryptographic backbone of products across the IoT, automotive, and industrial sectors, and forms the TLS layer for projects such as the Trusted Firmware family.&lt;/p&gt;
&lt;p&gt;Version 4.0 represents the most significant architectural change in the project's history. 
The cryptographic layer has been extracted into a standalone library, TF-PSA-Crypto, which implements the &lt;a href="https://arm-software.github.io/psa-api/crypto/1.2/"&gt;PSA Cryptography API v1.2&lt;/a&gt; as specified by Arm. 
The Mbed TLS repository now consumes TF-PSA-Crypto as a submodule, and the configuration space has been split across two header files: &lt;code&gt;mbedtls_config.h&lt;/code&gt; for the TLS and X.509 options, and &lt;code&gt;psa/crypto_config.h&lt;/code&gt; for the cryptographic
primitives. 
All RNG callbacks have been removed in favor of a mandatory call to &lt;code&gt;psa_crypto_init()&lt;/code&gt; before any operation.&lt;/p&gt;
&lt;p&gt;The Open Source Technology Improvement Fund (OSTIF) commissioned Quarkslab to perform a security audit of this new architecture. &lt;/p&gt;
&lt;h1 id="scope"&gt;Scope&lt;/h1&gt;
&lt;p&gt;The primary objectives of this audit are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Architectural transition review.&lt;/em&gt; Assess the security implications of the
  Mbed TLS 3.x to 4.0 split, focusing on the trust boundary between the TLS layer
  and TF-PSA-Crypto, the correctness of the PSA API integration, and whether the
  removal of the legacy crypto paths introduces new attack surface.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;PSA API usage correctness.&lt;/em&gt; Verify that key attributes (usage flags, permitted
  algorithms, lifetimes) are correctly set and enforced throughout the TLS and
  X.509 code paths, and that the mandatory &lt;code&gt;psa_crypto_init()&lt;/code&gt; dependency is
  properly documented and enforced.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Memory safety.&lt;/em&gt; Identify memory corruption vulnerabilities in the SSL/DTLS
  context management (in particular, session serialization and resumption), the
  X.509 parsing subsystem, and the PSA key store.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Default configuration posture.&lt;/em&gt; Review the security of the default build
  configuration, including enabled cipher suites, protocol versions, key exchange
  algorithms, and compile-time options that may expose users to risk without
  explicit opt-in.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;em&gt;Protocol compliance.&lt;/em&gt; Identify deviations from the TLS 1.2 (RFC 5246), TLS 1.3
  (RFC 8446), and DTLS specifications that have security consequences.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The engagement covers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Mbed TLS&lt;/em&gt; at commit &lt;code&gt;0fe989b6b514192783c469039edd325fd0989806&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;TF-PSA-Crypto&lt;/em&gt; (integrated submodule) at commit &lt;code&gt;29160dd877d29658279fd683b2ae57b320ddcf09&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The complete technical report, including our findings and recommendations, is available in Quarkslab's &lt;a href="https://github.com/quarkslab/public-reports"&gt;public reports repository&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id="findings"&gt;Findings&lt;/h1&gt;
&lt;p&gt;The table below summarizes the findings of the audit. A total of 5 vulnerabilities were identified: 1 of high severity, 1 of low severity, and 3 informational ones.&lt;/p&gt;
&lt;table class="table table-striped"&gt;
&lt;thead&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;th&gt;Title&lt;/th&gt;
&lt;th&gt;Severity&lt;/th&gt;
&lt;th&gt;Perimeter&lt;/th&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;th class="no-wrap" scope="row"&gt;HIGH-1&lt;/th&gt;
&lt;td&gt;CID Buffer Overflow in `mbedtls_ssl_context_load()`&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;`library/ssl_tls.c:5002`&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th class="no-wrap" scope="row"&gt;LOW-4&lt;/th&gt;
&lt;td&gt;`mbedtls_pk_verify()` accepts BER-encoded signatures&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;`tf-psa-crypto/extras/pk.c`&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th class="no-wrap" scope="row"&gt;INFO-2&lt;/th&gt;
&lt;td&gt;No Anti-Replay Protection for TLS 1.3 0-RTT Early Data&lt;/td&gt;
&lt;td&gt;Info&lt;/td&gt;
&lt;td&gt;`include/mbedtls/ssl.h:5166`&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th class="no-wrap" scope="row"&gt;INFO-3&lt;/th&gt;
&lt;td&gt;Mismatch in CMAC cipher support between the documentation and the implementation.&lt;/td&gt;
&lt;td&gt;Info&lt;/td&gt;
&lt;td&gt;TF-PSA-Crypto documentation&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;th class="no-wrap" scope="row"&gt;INFO-5&lt;/th&gt;
&lt;td&gt;`compat.sh` DTLS 1.2 tests fail on the `mbedtls-test` Docker image due to IPv6 `localhost` resolution&lt;/td&gt;
&lt;td&gt;Info&lt;/td&gt;
&lt;td&gt;mbedtls-test Docker images, `compat.sh`&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;
All relevant findings have since been resolved. &lt;/p&gt;
&lt;/blockquote&gt;
&lt;h1 id="conclusion"&gt;Conclusion&lt;/h1&gt;
&lt;p&gt;The audit identified a few vulnerabilities with only two non-informational ones, and the auditors were overall very satisfied with the quality of the product in general, and this version's changes in particular.&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;high&lt;/em&gt; and &lt;em&gt;low&lt;/em&gt; vulnerabilities are related to a heap buffer overflow and potential signature malleability, respectively, with the second one being identified thanks to the integration of integration of Project Wycheproof test vectors into the test suite.&lt;/p&gt;
&lt;p&gt;An informational finding documents the absence of any anti-replay protection for TLS 1.3 0-RTT early data, a known limitation that is currently not surfaced in the public-facing documentation in a way that prevents inadvertent misuse.
Auditors have proposed improvements to the existing fuzzing harnesses and corpora, along with an integration of the #anv test suite into the CI/CD pipeline.&lt;/p&gt;
&lt;p&gt;We would like to thank the Mbed TLS maintainers for their responsiveness and collaboration throughout the audit process, as well as the OSTIF team for their continuous support.&lt;/p&gt;
&lt;p&gt;Further details can be found in our &lt;a href="https://github.com/quarkslab/public-reports/blob/main/Reports/26-05-2730-REP_v1.0-1.pdf"&gt;report&lt;/a&gt;.&lt;/p&gt;
&lt;h1 id="further-reading"&gt;Further reading&lt;/h1&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ostif.org/mbed-tls-audit-complete/"&gt;OSTIF blog post&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content><category term="Cryptography"></category><category term="audit"></category><category term="OSTIF"></category><category term="TLS"></category><category term="cryptography"></category><category term="vulnerability"></category><category term="mbedtls"></category><category term="software"></category><category term="2026"></category></entry></feed>