132b31808SJens Wiklander## Reporting Vulnerabilities 27901324dSJerome Forissier 37901324dSJerome ForissierIf you think you have found an Mbed TLS security vulnerability, then please 47901324dSJerome Forissiersend an email to the security team at 57901324dSJerome Forissier<mbed-tls-security@lists.trustedfirmware.org>. 67901324dSJerome Forissier 77901324dSJerome Forissier## Security Incident Handling Process 87901324dSJerome Forissier 9039e02dfSJerome ForissierOur security process is detailed in our 107901324dSJerome Forissier[security 117901324dSJerome Forissiercenter](https://developer.trustedfirmware.org/w/mbed-tls/security-center/). 127901324dSJerome Forissier 137901324dSJerome ForissierIts primary goal is to ensure fixes are ready to be deployed when the issue 147901324dSJerome Forissiergoes public. 157901324dSJerome Forissier 167901324dSJerome Forissier## Maintained branches 177901324dSJerome Forissier 187901324dSJerome ForissierOnly the maintained branches, as listed in [`BRANCHES.md`](BRANCHES.md), 197901324dSJerome Forissierget security fixes. 207901324dSJerome ForissierUsers are urged to always use the latest version of a maintained branch. 2132b31808SJens Wiklander 2232b31808SJens Wiklander## Threat model 2332b31808SJens Wiklander 2432b31808SJens WiklanderWe classify attacks based on the capabilities of the attacker. 2532b31808SJens Wiklander 2632b31808SJens Wiklander### Remote attacks 2732b31808SJens Wiklander 2832b31808SJens WiklanderIn this section, we consider an attacker who can observe and modify data sent 2932b31808SJens Wiklanderover the network. This includes observing the content and timing of individual 3032b31808SJens Wiklanderpackets, as well as suppressing or delaying legitimate messages, and injecting 3132b31808SJens Wiklandermessages. 3232b31808SJens Wiklander 3332b31808SJens WiklanderMbed TLS aims to fully protect against remote attacks and to enable the user 3432b31808SJens Wiklanderapplication in providing full protection against remote attacks. Said 3532b31808SJens Wiklanderprotection is limited to providing security guarantees offered by the protocol 3632b31808SJens Wiklanderbeing implemented. (For example Mbed TLS alone won't guarantee that the 3732b31808SJens Wiklandermessages will arrive without delay, as the TLS protocol doesn't guarantee that 3832b31808SJens Wiklandereither.) 3932b31808SJens Wiklander 4032b31808SJens Wiklander**Warning!** Block ciphers do not yet achieve full protection against attackers 4132b31808SJens Wiklanderwho can measure the timing of packets with sufficient precision. For details 4232b31808SJens Wiklanderand workarounds see the [Block Ciphers](#block-ciphers) section. 4332b31808SJens Wiklander 4432b31808SJens Wiklander### Local attacks 4532b31808SJens Wiklander 4632b31808SJens WiklanderIn this section, we consider an attacker who can run software on the same 4732b31808SJens Wiklandermachine. The attacker has insufficient privileges to directly access Mbed TLS 4832b31808SJens Wiklanderassets such as memory and files. 4932b31808SJens Wiklander 5032b31808SJens Wiklander#### Timing attacks 5132b31808SJens Wiklander 5232b31808SJens WiklanderThe attacker is able to observe the timing of instructions executed by Mbed TLS 5332b31808SJens Wiklanderby leveraging shared hardware that both Mbed TLS and the attacker have access 5432b31808SJens Wiklanderto. Typical attack vectors include cache timings, memory bus contention and 5532b31808SJens Wiklanderbranch prediction. 5632b31808SJens Wiklander 5732b31808SJens WiklanderMbed TLS provides limited protection against timing attacks. The cost of 5832b31808SJens Wiklanderprotecting against timing attacks widely varies depending on the granularity of 5932b31808SJens Wiklanderthe measurements and the noise present. Therefore the protection in Mbed TLS is 6032b31808SJens Wiklanderlimited. We are only aiming to provide protection against **publicly 6132b31808SJens Wiklanderdocumented attack techniques**. 6232b31808SJens Wiklander 6332b31808SJens WiklanderAs attacks keep improving, so does Mbed TLS's protection. Mbed TLS is moving 6432b31808SJens Wiklandertowards a model of fully timing-invariant code, but has not reached this point 6532b31808SJens Wiklanderyet. 6632b31808SJens Wiklander 6732b31808SJens Wiklander**Remark:** Timing information can be observed over the network or through 6832b31808SJens Wiklanderphysical side channels as well. Remote and physical timing attacks are covered 6932b31808SJens Wiklanderin the [Remote attacks](remote-attacks) and [Physical 7032b31808SJens Wiklanderattacks](physical-attacks) sections respectively. 7132b31808SJens Wiklander 7232b31808SJens Wiklander**Warning!** Block ciphers do not yet achieve full protection. For 7332b31808SJens Wiklanderdetails and workarounds see the [Block Ciphers](#block-ciphers) section. 7432b31808SJens Wiklander 7532b31808SJens Wiklander#### Local non-timing side channels 7632b31808SJens Wiklander 7732b31808SJens WiklanderThe attacker code running on the platform has access to some sensor capable of 7832b31808SJens Wiklanderpicking up information on the physical state of the hardware while Mbed TLS is 7932b31808SJens Wiklanderrunning. This could for example be an analogue-to-digital converter on the 8032b31808SJens Wiklanderplatform that is located unfortunately enough to pick up the CPU noise. 8132b31808SJens Wiklander 8232b31808SJens WiklanderMbed TLS doesn't make any security guarantees against local non-timing-based 8332b31808SJens Wiklanderside channel attacks. If local non-timing attacks are present in a use case or 8432b31808SJens Wiklandera user application's threat model, they need to be mitigated by the platform. 8532b31808SJens Wiklander 8632b31808SJens Wiklander#### Local fault injection attacks 8732b31808SJens Wiklander 8832b31808SJens WiklanderSoftware running on the same hardware can affect the physical state of the 8932b31808SJens Wiklanderdevice and introduce faults. 9032b31808SJens Wiklander 9132b31808SJens WiklanderMbed TLS doesn't make any security guarantees against local fault injection 9232b31808SJens Wiklanderattacks. If local fault injection attacks are present in a use case or a user 9332b31808SJens Wiklanderapplication's threat model, they need to be mitigated by the platform. 9432b31808SJens Wiklander 9532b31808SJens Wiklander### Physical attacks 9632b31808SJens Wiklander 9732b31808SJens WiklanderIn this section, we consider an attacker who has access to physical information 9832b31808SJens Wiklanderabout the hardware Mbed TLS is running on and/or can alter the physical state 9932b31808SJens Wiklanderof the hardware (e.g. power analysis, radio emissions or fault injection). 10032b31808SJens Wiklander 10132b31808SJens WiklanderMbed TLS doesn't make any security guarantees against physical attacks. If 10232b31808SJens Wiklanderphysical attacks are present in a use case or a user application's threat 10332b31808SJens Wiklandermodel, they need to be mitigated by physical countermeasures. 10432b31808SJens Wiklander 10532b31808SJens Wiklander### Caveats 10632b31808SJens Wiklander 10732b31808SJens Wiklander#### Out-of-scope countermeasures 10832b31808SJens Wiklander 10932b31808SJens WiklanderMbed TLS has evolved organically and a well defined threat model hasn't always 11032b31808SJens Wiklanderbeen present. Therefore, Mbed TLS might have countermeasures against attacks 11132b31808SJens Wiklanderoutside the above defined threat model. 11232b31808SJens Wiklander 11332b31808SJens WiklanderThe presence of such countermeasures don't mean that Mbed TLS provides 11432b31808SJens Wiklanderprotection against a class of attacks outside of the above described threat 11532b31808SJens Wiklandermodel. Neither does it mean that the failure of such a countermeasure is 11632b31808SJens Wiklanderconsidered a vulnerability. 11732b31808SJens Wiklander 11832b31808SJens Wiklander#### Block ciphers 11932b31808SJens Wiklander 12032b31808SJens WiklanderCurrently there are four block ciphers in Mbed TLS: AES, CAMELLIA, ARIA and 12132b31808SJens WiklanderDES. The pure software implementation in Mbed TLS implementation uses lookup 12232b31808SJens Wiklandertables, which are vulnerable to timing attacks. 12332b31808SJens Wiklander 12432b31808SJens WiklanderThese timing attacks can be physical, local or depending on network latency 12532b31808SJens Wiklandereven a remote. The attacks can result in key recovery. 12632b31808SJens Wiklander 12732b31808SJens Wiklander**Workarounds:** 12832b31808SJens Wiklander 12932b31808SJens Wiklander- Turn on hardware acceleration for AES. This is supported only on selected 13032b31808SJens Wiklander architectures and currently only available for AES. See configuration options 13132b31808SJens Wiklander `MBEDTLS_AESCE_C`, `MBEDTLS_AESNI_C` and `MBEDTLS_PADLOCK_C` for details. 13232b31808SJens Wiklander- Add a secure alternative implementation (typically hardware acceleration) for 13332b31808SJens Wiklander the vulnerable cipher. See the [Alternative Implementations 13432b31808SJens WiklanderGuide](docs/architecture/alternative-implementations.md) for more information. 13532b31808SJens Wiklander- Use cryptographic mechanisms that are not based on block ciphers. In 13632b31808SJens Wiklander particular, for authenticated encryption, use ChaCha20/Poly1305 instead of 13732b31808SJens Wiklander block cipher modes. For random generation, use HMAC\_DRBG instead of CTR\_DRBG. 138b0563631STom Van Eyck 139b0563631STom Van Eyck#### Everest 140b0563631STom Van Eyck 141b0563631STom Van EyckThe HACL* implementation of X25519 taken from the Everest project only protects 142b0563631STom Van Eyckagainst remote timing attacks. (See their [Security 143b0563631STom Van EyckPolicy](https://github.com/hacl-star/hacl-star/blob/main/SECURITY.md).) 144b0563631STom Van Eyck 145b0563631STom Van EyckThe Everest variant is only used when `MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED` 146b0563631STom Van Eyckconfiguration option is defined. This option is off by default. 147*c3deb3d6SEtienne Carriere 148*c3deb3d6SEtienne Carriere#### Formatting of X.509 certificates and certificate signing requests 149*c3deb3d6SEtienne Carriere 150*c3deb3d6SEtienne CarriereWhen parsing X.509 certificates and certificate signing requests (CSRs), 151*c3deb3d6SEtienne CarriereMbed TLS does not check that they are strictly compliant with X.509 and other 152*c3deb3d6SEtienne Carriererelevant standards. In the case of signed certificates, the signing party is 153*c3deb3d6SEtienne Carriereassumed to have performed this validation (and the certificate is trusted to 154*c3deb3d6SEtienne Carrierebe correctly formatted as long as the signature is correct). 155*c3deb3d6SEtienne CarriereSimilarly, CSRs are implicitly trusted by Mbed TLS to be standards-compliant. 156*c3deb3d6SEtienne Carriere 157*c3deb3d6SEtienne Carriere**Warning!** Mbed TLS must not be used to sign untrusted CSRs unless extra 158*c3deb3d6SEtienne Carrierevalidation is performed separately to ensure that they are compliant to the 159*c3deb3d6SEtienne Carriererelevant specifications. This makes Mbed TLS on its own unsuitable for use in 160*c3deb3d6SEtienne Carrierea Certificate Authority (CA). 161*c3deb3d6SEtienne Carriere 162*c3deb3d6SEtienne CarriereHowever, Mbed TLS aims to protect against memory corruption and other 163*c3deb3d6SEtienne Carriereundefined behavior when parsing certificates and CSRs. If a CSR or signed 164*c3deb3d6SEtienne Carrierecertificate causes undefined behavior when it is parsed by Mbed TLS, that 165*c3deb3d6SEtienne Carriereis considered a security vulnerability. 166