1*cfb92d14SAndroid Build Coastguard Worker## Reporting Vulnerabilities 2*cfb92d14SAndroid Build Coastguard Worker 3*cfb92d14SAndroid Build Coastguard WorkerIf you think you have found an Mbed TLS security vulnerability, then please 4*cfb92d14SAndroid Build Coastguard Workersend an email to the security team at 5*cfb92d14SAndroid Build Coastguard Worker<[email protected]>. 6*cfb92d14SAndroid Build Coastguard Worker 7*cfb92d14SAndroid Build Coastguard Worker## Security Incident Handling Process 8*cfb92d14SAndroid Build Coastguard Worker 9*cfb92d14SAndroid Build Coastguard WorkerOur security process is detailed in our 10*cfb92d14SAndroid Build Coastguard Worker[security 11*cfb92d14SAndroid Build Coastguard Workercenter](https://developer.trustedfirmware.org/w/mbed-tls/security-center/). 12*cfb92d14SAndroid Build Coastguard Worker 13*cfb92d14SAndroid Build Coastguard WorkerIts primary goal is to ensure fixes are ready to be deployed when the issue 14*cfb92d14SAndroid Build Coastguard Workergoes public. 15*cfb92d14SAndroid Build Coastguard Worker 16*cfb92d14SAndroid Build Coastguard Worker## Maintained branches 17*cfb92d14SAndroid Build Coastguard Worker 18*cfb92d14SAndroid Build Coastguard WorkerOnly the maintained branches, as listed in [`BRANCHES.md`](BRANCHES.md), 19*cfb92d14SAndroid Build Coastguard Workerget security fixes. 20*cfb92d14SAndroid Build Coastguard WorkerUsers are urged to always use the latest version of a maintained branch. 21*cfb92d14SAndroid Build Coastguard Worker 22*cfb92d14SAndroid Build Coastguard Worker## Threat model 23*cfb92d14SAndroid Build Coastguard Worker 24*cfb92d14SAndroid Build Coastguard WorkerWe classify attacks based on the capabilities of the attacker. 25*cfb92d14SAndroid Build Coastguard Worker 26*cfb92d14SAndroid Build Coastguard Worker### Remote attacks 27*cfb92d14SAndroid Build Coastguard Worker 28*cfb92d14SAndroid Build Coastguard WorkerIn this section, we consider an attacker who can observe and modify data sent 29*cfb92d14SAndroid Build Coastguard Workerover the network. This includes observing the content and timing of individual 30*cfb92d14SAndroid Build Coastguard Workerpackets, as well as suppressing or delaying legitimate messages, and injecting 31*cfb92d14SAndroid Build Coastguard Workermessages. 32*cfb92d14SAndroid Build Coastguard Worker 33*cfb92d14SAndroid Build Coastguard WorkerMbed TLS aims to fully protect against remote attacks and to enable the user 34*cfb92d14SAndroid Build Coastguard Workerapplication in providing full protection against remote attacks. Said 35*cfb92d14SAndroid Build Coastguard Workerprotection is limited to providing security guarantees offered by the protocol 36*cfb92d14SAndroid Build Coastguard Workerbeing implemented. (For example Mbed TLS alone won't guarantee that the 37*cfb92d14SAndroid Build Coastguard Workermessages will arrive without delay, as the TLS protocol doesn't guarantee that 38*cfb92d14SAndroid Build Coastguard Workereither.) 39*cfb92d14SAndroid Build Coastguard Worker 40*cfb92d14SAndroid Build Coastguard Worker**Warning!** Block ciphers do not yet achieve full protection against attackers 41*cfb92d14SAndroid Build Coastguard Workerwho can measure the timing of packets with sufficient precision. For details 42*cfb92d14SAndroid Build Coastguard Workerand workarounds see the [Block Ciphers](#block-ciphers) section. 43*cfb92d14SAndroid Build Coastguard Worker 44*cfb92d14SAndroid Build Coastguard Worker### Local attacks 45*cfb92d14SAndroid Build Coastguard Worker 46*cfb92d14SAndroid Build Coastguard WorkerIn this section, we consider an attacker who can run software on the same 47*cfb92d14SAndroid Build Coastguard Workermachine. The attacker has insufficient privileges to directly access Mbed TLS 48*cfb92d14SAndroid Build Coastguard Workerassets such as memory and files. 49*cfb92d14SAndroid Build Coastguard Worker 50*cfb92d14SAndroid Build Coastguard Worker#### Timing attacks 51*cfb92d14SAndroid Build Coastguard Worker 52*cfb92d14SAndroid Build Coastguard WorkerThe attacker is able to observe the timing of instructions executed by Mbed TLS 53*cfb92d14SAndroid Build Coastguard Workerby leveraging shared hardware that both Mbed TLS and the attacker have access 54*cfb92d14SAndroid Build Coastguard Workerto. Typical attack vectors include cache timings, memory bus contention and 55*cfb92d14SAndroid Build Coastguard Workerbranch prediction. 56*cfb92d14SAndroid Build Coastguard Worker 57*cfb92d14SAndroid Build Coastguard WorkerMbed TLS provides limited protection against timing attacks. The cost of 58*cfb92d14SAndroid Build Coastguard Workerprotecting against timing attacks widely varies depending on the granularity of 59*cfb92d14SAndroid Build Coastguard Workerthe measurements and the noise present. Therefore the protection in Mbed TLS is 60*cfb92d14SAndroid Build Coastguard Workerlimited. We are only aiming to provide protection against **publicly 61*cfb92d14SAndroid Build Coastguard Workerdocumented attack techniques**. 62*cfb92d14SAndroid Build Coastguard Worker 63*cfb92d14SAndroid Build Coastguard WorkerAs attacks keep improving, so does Mbed TLS's protection. Mbed TLS is moving 64*cfb92d14SAndroid Build Coastguard Workertowards a model of fully timing-invariant code, but has not reached this point 65*cfb92d14SAndroid Build Coastguard Workeryet. 66*cfb92d14SAndroid Build Coastguard Worker 67*cfb92d14SAndroid Build Coastguard Worker**Remark:** Timing information can be observed over the network or through 68*cfb92d14SAndroid Build Coastguard Workerphysical side channels as well. Remote and physical timing attacks are covered 69*cfb92d14SAndroid Build Coastguard Workerin the [Remote attacks](remote-attacks) and [Physical 70*cfb92d14SAndroid Build Coastguard Workerattacks](physical-attacks) sections respectively. 71*cfb92d14SAndroid Build Coastguard Worker 72*cfb92d14SAndroid Build Coastguard Worker**Warning!** Block ciphers do not yet achieve full protection. For 73*cfb92d14SAndroid Build Coastguard Workerdetails and workarounds see the [Block Ciphers](#block-ciphers) section. 74*cfb92d14SAndroid Build Coastguard Worker 75*cfb92d14SAndroid Build Coastguard Worker#### Local non-timing side channels 76*cfb92d14SAndroid Build Coastguard Worker 77*cfb92d14SAndroid Build Coastguard WorkerThe attacker code running on the platform has access to some sensor capable of 78*cfb92d14SAndroid Build Coastguard Workerpicking up information on the physical state of the hardware while Mbed TLS is 79*cfb92d14SAndroid Build Coastguard Workerrunning. This could for example be an analogue-to-digital converter on the 80*cfb92d14SAndroid Build Coastguard Workerplatform that is located unfortunately enough to pick up the CPU noise. 81*cfb92d14SAndroid Build Coastguard Worker 82*cfb92d14SAndroid Build Coastguard WorkerMbed TLS doesn't make any security guarantees against local non-timing-based 83*cfb92d14SAndroid Build Coastguard Workerside channel attacks. If local non-timing attacks are present in a use case or 84*cfb92d14SAndroid Build Coastguard Workera user application's threat model, they need to be mitigated by the platform. 85*cfb92d14SAndroid Build Coastguard Worker 86*cfb92d14SAndroid Build Coastguard Worker#### Local fault injection attacks 87*cfb92d14SAndroid Build Coastguard Worker 88*cfb92d14SAndroid Build Coastguard WorkerSoftware running on the same hardware can affect the physical state of the 89*cfb92d14SAndroid Build Coastguard Workerdevice and introduce faults. 90*cfb92d14SAndroid Build Coastguard Worker 91*cfb92d14SAndroid Build Coastguard WorkerMbed TLS doesn't make any security guarantees against local fault injection 92*cfb92d14SAndroid Build Coastguard Workerattacks. If local fault injection attacks are present in a use case or a user 93*cfb92d14SAndroid Build Coastguard Workerapplication's threat model, they need to be mitigated by the platform. 94*cfb92d14SAndroid Build Coastguard Worker 95*cfb92d14SAndroid Build Coastguard Worker### Physical attacks 96*cfb92d14SAndroid Build Coastguard Worker 97*cfb92d14SAndroid Build Coastguard WorkerIn this section, we consider an attacker who has access to physical information 98*cfb92d14SAndroid Build Coastguard Workerabout the hardware Mbed TLS is running on and/or can alter the physical state 99*cfb92d14SAndroid Build Coastguard Workerof the hardware (e.g. power analysis, radio emissions or fault injection). 100*cfb92d14SAndroid Build Coastguard Worker 101*cfb92d14SAndroid Build Coastguard WorkerMbed TLS doesn't make any security guarantees against physical attacks. If 102*cfb92d14SAndroid Build Coastguard Workerphysical attacks are present in a use case or a user application's threat 103*cfb92d14SAndroid Build Coastguard Workermodel, they need to be mitigated by physical countermeasures. 104*cfb92d14SAndroid Build Coastguard Worker 105*cfb92d14SAndroid Build Coastguard Worker### Caveats 106*cfb92d14SAndroid Build Coastguard Worker 107*cfb92d14SAndroid Build Coastguard Worker#### Out-of-scope countermeasures 108*cfb92d14SAndroid Build Coastguard Worker 109*cfb92d14SAndroid Build Coastguard WorkerMbed TLS has evolved organically and a well defined threat model hasn't always 110*cfb92d14SAndroid Build Coastguard Workerbeen present. Therefore, Mbed TLS might have countermeasures against attacks 111*cfb92d14SAndroid Build Coastguard Workeroutside the above defined threat model. 112*cfb92d14SAndroid Build Coastguard Worker 113*cfb92d14SAndroid Build Coastguard WorkerThe presence of such countermeasures don't mean that Mbed TLS provides 114*cfb92d14SAndroid Build Coastguard Workerprotection against a class of attacks outside of the above described threat 115*cfb92d14SAndroid Build Coastguard Workermodel. Neither does it mean that the failure of such a countermeasure is 116*cfb92d14SAndroid Build Coastguard Workerconsidered a vulnerability. 117*cfb92d14SAndroid Build Coastguard Worker 118*cfb92d14SAndroid Build Coastguard Worker#### Block ciphers 119*cfb92d14SAndroid Build Coastguard Worker 120*cfb92d14SAndroid Build Coastguard WorkerCurrently there are four block ciphers in Mbed TLS: AES, CAMELLIA, ARIA and 121*cfb92d14SAndroid Build Coastguard WorkerDES. The pure software implementation in Mbed TLS implementation uses lookup 122*cfb92d14SAndroid Build Coastguard Workertables, which are vulnerable to timing attacks. 123*cfb92d14SAndroid Build Coastguard Worker 124*cfb92d14SAndroid Build Coastguard WorkerThese timing attacks can be physical, local or depending on network latency 125*cfb92d14SAndroid Build Coastguard Workereven a remote. The attacks can result in key recovery. 126*cfb92d14SAndroid Build Coastguard Worker 127*cfb92d14SAndroid Build Coastguard Worker**Workarounds:** 128*cfb92d14SAndroid Build Coastguard Worker 129*cfb92d14SAndroid Build Coastguard Worker- Turn on hardware acceleration for AES. This is supported only on selected 130*cfb92d14SAndroid Build Coastguard Worker architectures and currently only available for AES. See configuration options 131*cfb92d14SAndroid Build Coastguard Worker `MBEDTLS_AESCE_C`, `MBEDTLS_AESNI_C` and `MBEDTLS_PADLOCK_C` for details. 132*cfb92d14SAndroid Build Coastguard Worker- Add a secure alternative implementation (typically hardware acceleration) for 133*cfb92d14SAndroid Build Coastguard Worker the vulnerable cipher. See the [Alternative Implementations 134*cfb92d14SAndroid Build Coastguard WorkerGuide](docs/architecture/alternative-implementations.md) for more information. 135*cfb92d14SAndroid Build Coastguard Worker- Use cryptographic mechanisms that are not based on block ciphers. In 136*cfb92d14SAndroid Build Coastguard Worker particular, for authenticated encryption, use ChaCha20/Poly1305 instead of 137*cfb92d14SAndroid Build Coastguard Worker block cipher modes. For random generation, use HMAC\_DRBG instead of CTR\_DRBG. 138*cfb92d14SAndroid Build Coastguard Worker 139*cfb92d14SAndroid Build Coastguard Worker#### Everest 140*cfb92d14SAndroid Build Coastguard Worker 141*cfb92d14SAndroid Build Coastguard WorkerThe HACL* implementation of X25519 taken from the Everest project only protects 142*cfb92d14SAndroid Build Coastguard Workeragainst remote timing attacks. (See their [Security 143*cfb92d14SAndroid Build Coastguard WorkerPolicy](https://github.com/hacl-star/hacl-star/blob/main/SECURITY.md).) 144*cfb92d14SAndroid Build Coastguard Worker 145*cfb92d14SAndroid Build Coastguard WorkerThe Everest variant is only used when `MBEDTLS_ECDH_VARIANT_EVEREST_ENABLED` 146*cfb92d14SAndroid Build Coastguard Workerconfiguration option is defined. This option is off by default. 147