1Generic Threat Model 2******************** 3 4************ 5Introduction 6************ 7 8This document provides a generic threat model for TF-A firmware. 9 10.. _Target of Evaluation: 11 12******************** 13Target of Evaluation 14******************** 15 16In this threat model, the target of evaluation is the Trusted 17Firmware for A-class Processors (TF-A). This includes the boot ROM (BL1), 18the trusted boot firmware (BL2) and the runtime EL3 firmware (BL31) as 19shown on Figure 1. Everything else on Figure 1 is outside of the scope of 20the evaluation. 21 22TF-A can be configured in various ways. In this threat model we consider 23only the most basic configuration. To that end we make the following 24assumptions: 25 26- All TF-A images are run from either ROM or on-chip trusted SRAM. This means 27 TF-A is not vulnerable to an attacker that can probe or tamper with off-chip 28 memory. 29 30- Trusted boot is enabled. This means an attacker can't boot arbitrary images 31 that are not approved by platform providers. 32 33- There is no Secure-EL2. We don't consider threats that may come with 34 Secure-EL2 software. 35 36- There are no Root and Realm worlds. These are introduced by :ref:`Realm 37 Management Extension (RME)`. 38 39 The :ref:`Threat Model for TF-A with Arm CCA support` covers these types of 40 configurations. 41 42- No experimental features are enabled. We do not consider threats that may come 43 from them. 44 45 46Data Flow Diagram 47================= 48 49Figure 1 shows a high-level data flow diagram for TF-A. The diagram 50shows a model of the different components of a TF-A-based system and 51their interactions with TF-A. A description of each diagram element 52is given on Table 1. On the diagram, the red broken lines indicate 53trust boundaries. Components outside of the broken lines 54are considered untrusted by TF-A. 55 56.. uml:: ../resources/diagrams/plantuml/tfa_dfd.puml 57 :caption: Figure 1: TF-A Data Flow Diagram 58 59.. table:: Table 1: TF-A Data Flow Diagram Description 60 61 +-----------------+--------------------------------------------------------+ 62 | Diagram Element | Description | 63 +=================+========================================================+ 64 | DF1 | | At boot time, images are loaded from non-volatile | 65 | | memory and verified by TF-A boot firmware. These | 66 | | images include TF-A BL2 and BL31 images, as well as | 67 | | other secure and non-secure images. | 68 +-----------------+--------------------------------------------------------+ 69 | DF2 | | TF-A log system framework outputs debug or | 70 | | informative messages over a UART interface. | 71 | | | 72 | | | Also, characters can be read from a UART interface. | 73 +-----------------+--------------------------------------------------------+ 74 | DF3 | | Debug and trace IP on a platform can allow access | 75 | | to registers and memory of TF-A. | 76 +-----------------+--------------------------------------------------------+ 77 | DF4 | | Secure world software (e.g. trusted OS) interact | 78 | | with TF-A through SMC call interface and/or shared | 79 | | memory. | 80 +-----------------+--------------------------------------------------------+ 81 | DF5 | | Non-secure world software (e.g. rich OS) interact | 82 | | with TF-A through SMC call interface and/or shared | 83 | | memory. | 84 +-----------------+--------------------------------------------------------+ 85 | DF6 | | This path represents the interaction between TF-A and| 86 | | various hardware IPs such as TrustZone controller | 87 | | and GIC. At boot time TF-A configures/initializes the| 88 | | IPs and interacts with them at runtime through | 89 | | interrupts and registers. | 90 +-----------------+--------------------------------------------------------+ 91 92 93.. _threat_analysis: 94 95*************** 96Threat Analysis 97*************** 98 99In this section we identify and provide assessment of potential threats to TF-A 100firmware. The threats are identified for each diagram element on the 101data flow diagram above. 102 103For each threat, we identify the *asset* that is under threat, the 104*threat agent* and the *threat type*. Each threat is given a *risk rating* 105that represents the impact and likelihood of that threat. We also discuss 106potential mitigations. 107 108Assets 109====== 110 111We have identified the following assets for TF-A: 112 113.. table:: Table 2: TF-A Assets 114 115 +--------------------+---------------------------------------------------+ 116 | Asset | Description | 117 +====================+===================================================+ 118 | Sensitive Data | | These include sensitive data that an attacker | 119 | | must not be able to tamper with (e.g. the Root | 120 | | of Trust Public Key) or see (e.g. secure logs, | 121 | | debugging information such as crash reports). | 122 +--------------------+---------------------------------------------------+ 123 | Code Execution | | This represents the requirement that the | 124 | | platform should run only TF-A code approved by | 125 | | the platform provider. | 126 +--------------------+---------------------------------------------------+ 127 | Availability | | This represents the requirement that TF-A | 128 | | services should always be available for use. | 129 +--------------------+---------------------------------------------------+ 130 131Threat Agents 132============= 133 134To understand the attack surface, it is important to identify potential 135attackers, i.e. attack entry points. The following threat agents are 136in scope of this threat model. 137 138.. table:: Table 3: Threat Agents 139 140 +-------------------+-------------------------------------------------------+ 141 | Threat Agent | Description | 142 +===================+=======================================================+ 143 | NSCode | | Malicious or faulty code running in the Non-secure | 144 | | world, including NS-EL0 NS-EL1 and NS-EL2 levels | 145 +-------------------+-------------------------------------------------------+ 146 | SecCode | | Malicious or faulty code running in the secure | 147 | | world, including S-EL0 and S-EL1 levels | 148 +-------------------+-------------------------------------------------------+ 149 | AppDebug | | Physical attacker using debug signals to access | 150 | | TF-A resources | 151 +-------------------+-------------------------------------------------------+ 152 | PhysicalAccess | | Physical attacker having access to external device | 153 | | communication bus and to external flash | 154 | | communication bus using common hardware | 155 +-------------------+-------------------------------------------------------+ 156 157.. note:: 158 159 In this threat model an advanced physical attacker that has the capability 160 to tamper with a hardware (e.g. "rewiring" a chip using a focused 161 ion beam (FIB) workstation or decapsulate the chip using chemicals) is 162 considered out-of-scope. 163 164Threat Types 165============ 166 167In this threat model we categorize threats using the `STRIDE threat 168analysis technique`_. In this technique a threat is categorized as one 169or more of these types: ``Spoofing``, ``Tampering``, ``Repudiation``, 170``Information disclosure``, ``Denial of service`` or 171``Elevation of privilege``. 172 173Threat Risk Ratings 174=================== 175 176For each threat identified, a risk rating that ranges 177from *informational* to *critical* is given based on the likelihood of the 178threat occurring if a mitigation is not in place, and the impact of the 179threat (i.e. how severe the consequences could be). Table 4 explains each 180rating in terms of score, impact and likelihood. 181 182.. table:: Table 4: Rating and score as applied to impact and likelihood 183 184 +-----------------------+-------------------------+---------------------------+ 185 | **Rating (Score)** | **Impact** | **Likelihood** | 186 +=======================+=========================+===========================+ 187 | Critical (5) | | Extreme impact to | | Threat is almost | 188 | | entire organization | certain to be exploited.| 189 | | if exploited. | | 190 | | | | Knowledge of the threat | 191 | | | and how to exploit it | 192 | | | are in the public | 193 | | | domain. | 194 +-----------------------+-------------------------+---------------------------+ 195 | High (4) | | Major impact to entire| | Threat is relatively | 196 | | organization or single| easy to detect and | 197 | | line of business if | exploit by an attacker | 198 | | exploited | with little skill. | 199 +-----------------------+-------------------------+---------------------------+ 200 | Medium (3) | | Noticeable impact to | | A knowledgeable insider | 201 | | line of business if | or expert attacker could| 202 | | exploited. | exploit the threat | 203 | | | without much difficulty.| 204 +-----------------------+-------------------------+---------------------------+ 205 | Low (2) | | Minor damage if | | Exploiting the threat | 206 | | exploited or could | would require | 207 | | be used in conjunction| considerable expertise | 208 | | with other | and resources | 209 | | vulnerabilities to | | 210 | | perform a more serious| | 211 | | attack | | 212 +-----------------------+-------------------------+---------------------------+ 213 | Informational (1) | | Poor programming | | Threat is not likely | 214 | | practice or poor | to be exploited on its | 215 | | design decision that | own, but may be used to | 216 | | may not represent an | gain information for | 217 | | immediate risk on its | launching another | 218 | | own, but may have | attack | 219 | | security implications | | 220 | | if multiplied and/or | | 221 | | combined with other | | 222 | | threats. | | 223 +-----------------------+-------------------------+---------------------------+ 224 225Aggregate risk scores are assigned to identified threats; 226specifically, the impact score multiplied by the likelihood score. 227For example, a threat with high likelihood and low impact would have an 228aggregate risk score of eight (8); that is, four (4) for high likelihood 229multiplied by two (2) for low impact. The aggregate risk score determines 230the finding's overall risk level, as shown in the following table. 231 232.. table:: Table 5: Overall risk levels and corresponding aggregate scores 233 234 +---------------------+-----------------------------------+ 235 | Overall Risk Level | Aggregate Risk Score | 236 | | (Impact multiplied by Likelihood) | 237 +=====================+===================================+ 238 | Critical | 20–25 | 239 +---------------------+-----------------------------------+ 240 | High | 12–19 | 241 +---------------------+-----------------------------------+ 242 | Medium | 6–11 | 243 +---------------------+-----------------------------------+ 244 | Low | 2–5 | 245 +---------------------+-----------------------------------+ 246 | Informational | 1 | 247 +---------------------+-----------------------------------+ 248 249The likelihood and impact of a threat depends on the 250target environment in which TF-A is running. For example, attacks 251that require physical access are unlikely in server environments while 252they are more common in Internet of Things(IoT) environments. 253In this threat model we consider three target environments: 254``Internet of Things(IoT)``, ``Mobile`` and ``Server``. 255 256Threat Assessment 257================= 258 259The following threats were identified by applying STRIDE analysis on 260each diagram element of the data flow diagram. 261 262For each threat, we strive to indicate whether the mitigations are currently 263implemented or not. However, the answer to this question is not always straight 264forward. Some mitigations are partially implemented in the generic code but also 265rely on the platform code to implement some bits of it. This threat model aims 266to be platform-independent and it is important to keep in mind that such threats 267only get mitigated if the platform code properly fulfills its responsibilities. 268 269Also, some mitigations require enabling specific features, which must be 270explicitly turned on via a build flag. 271 272When such conditions must be met, these are highlighted in the ``Mitigations 273implemented?`` box. 274 275As our :ref:`Target of Evaluation` is made of several, distinct firmware images, 276some threats are confined in specific images, while others apply to each of 277them. To help developers implement mitigations in the right place, threats below 278are categorized based on the firmware image that should mitigate them. 279 280.. _General Threats: 281 282General Threats for All Firmware Images 283--------------------------------------- 284 285+------------------------+---------------------------------------------------+ 286| ID | 05 | 287+========================+===================================================+ 288| Threat | | **Information leak via UART logs** | 289| | | 290| | | During the development stages of software it is | 291| | common to print all sorts of information on the | 292| | console, including sensitive or confidential | 293| | information such as crash reports with detailed | 294| | information of the CPU state, current registers | 295| | values, privilege level or stack dumps. | 296| | | 297| | | This information is useful when debugging | 298| | problems before releasing the production | 299| | version but it could be used by an attacker | 300| | to develop a working exploit if left enabled in | 301| | the production version. | 302| | | 303| | | This happens when directly logging sensitive | 304| | information and more subtly when logging | 305| | side-channel information that can be used by an | 306| | attacker to learn about sensitive information. | 307+------------------------+---------------------------------------------------+ 308| Diagram Elements | DF2 | 309+------------------------+---------------------------------------------------+ 310| Affected TF-A | BL1, BL2, BL31 | 311| Components | | 312+------------------------+---------------------------------------------------+ 313| Assets | Sensitive Data | 314+------------------------+---------------------------------------------------+ 315| Threat Agent | AppDebug | 316+------------------------+---------------------------------------------------+ 317| Threat Type | Information Disclosure | 318+------------------------+------------------+----------------+---------------+ 319| Application | Server | IoT | Mobile | 320+------------------------+------------------+----------------+---------------+ 321| Impact | N/A | Low (2) | Low (2) | 322+------------------------+------------------+----------------+---------------+ 323| Likelihood | N/A | High (4) | High (4) | 324+------------------------+------------------+----------------+---------------+ 325| Total Risk Rating | N/A | Medium (8) | Medium (8) | 326+------------------------+------------------+----------------+---------------+ 327| Mitigations | | Remove sensitive information logging in | 328| | production releases. | 329| | | 330| | | Do not conditionally log information depending | 331| | on potentially sensitive data. | 332| | | 333| | | Do not log high precision timing information. | 334+------------------------+---------------------------------------------------+ 335| Mitigations | | Yes / Platform Specific. | 336| implemented? | Requires the right build options to be used. | 337| | | 338| | | Crash reporting is only enabled for debug | 339| | builds by default, see ``CRASH_REPORTING`` | 340| | build option. | 341| | | 342| | | The log level can be tuned at build time, from | 343| | very verbose to no output at all. See | 344| | ``LOG_LEVEL`` build option. By default, release | 345| | builds are a lot less verbose than debug ones | 346| | but still produce some output. | 347| | | 348| | | Messages produced by the platform code should | 349| | use the appropriate level of verbosity so as | 350| | not to leak sensitive information in production | 351| | builds. | 352+------------------------+---------------------------------------------------+ 353 354+------------------------+----------------------------------------------------+ 355| ID | 06 | 356+========================+====================================================+ 357| Threat | | **An attacker can read sensitive data and | 358| | execute arbitrary code through the external | 359| | debug and trace interface** | 360| | | 361| | | Arm processors include hardware-assisted debug | 362| | and trace features that can be controlled without| 363| | the need for software operating on the platform. | 364| | If left enabled without authentication, this | 365| | feature can be used by an attacker to inspect and| 366| | modify TF-A registers and memory allowing the | 367| | attacker to read sensitive data and execute | 368| | arbitrary code. | 369+------------------------+----------------------------------------------------+ 370| Diagram Elements | DF3 | 371+------------------------+----------------------------------------------------+ 372| Affected TF-A | BL1, BL2, BL31 | 373| Components | | 374+------------------------+----------------------------------------------------+ 375| Assets | Code Execution, Sensitive Data | 376+------------------------+----------------------------------------------------+ 377| Threat Agent | AppDebug | 378+------------------------+----------------------------------------------------+ 379| Threat Type | Tampering, Information Disclosure, | 380| | Elevation of privilege | 381+------------------------+------------------+---------------+-----------------+ 382| Application | Server | IoT | Mobile | 383+------------------------+------------------+---------------+-----------------+ 384| Impact | N/A | High (4) | High (4) | 385+------------------------+------------------+---------------+-----------------+ 386| Likelihood | N/A | Critical (5) | Critical (5) | 387+------------------------+------------------+---------------+-----------------+ 388| Total Risk Rating | N/A | Critical (20) | Critical (20) | 389+------------------------+------------------+---------------+-----------------+ 390| Mitigations | Disable the debug and trace capability for | 391| | production releases or enable proper debug | 392| | authentication as recommended by [`DEN0034`_]. | 393+------------------------+----------------------------------------------------+ 394| Mitigations | | Platform specific. | 395| implemented? | | 396| | | Configuration of debug and trace capabilities is | 397| | entirely platform specific. | 398+------------------------+----------------------------------------------------+ 399 400+------------------------+------------------------------------------------------+ 401| ID | 08 | 402+========================+======================================================+ 403| Threat | | **Memory corruption due to memory overflows and | 404| | lack of boundary checking when accessing resources | 405| | could allow an attacker to execute arbitrary code, | 406| | modify some state variable to change the normal | 407| | flow of the program, or leak sensitive | 408| | information** | 409| | | 410| | | Like in other software, TF-A has multiple points | 411| | where memory corruption security errors can arise. | 412| | | 413| | | Some of the errors include integer overflow, | 414| | buffer overflow, incorrect array boundary checks, | 415| | and incorrect error management. | 416| | Improper use of asserts instead of proper input | 417| | validations might also result in these kinds of | 418| | errors in release builds. | 419+------------------------+------------------------------------------------------+ 420| Diagram Elements | DF4, DF5 | 421+------------------------+------------------------------------------------------+ 422| Affected TF-A | BL1, BL2, BL31 | 423| Components | | 424+------------------------+------------------------------------------------------+ 425| Assets | Code Execution, Sensitive Data | 426+------------------------+------------------------------------------------------+ 427| Threat Agent | NSCode, SecCode | 428+------------------------+------------------------------------------------------+ 429| Threat Type | Tampering, Information Disclosure, | 430| | Elevation of Privilege | 431+------------------------+-------------------+-----------------+----------------+ 432| Application | Server | IoT | Mobile | 433+------------------------+-------------------+-----------------+----------------+ 434| Impact | Critical (5) | Critical (5) | Critical (5) | 435+------------------------+-------------------+-----------------+----------------+ 436| Likelihood | Medium (3 | Medium (3) | Medium (3) | 437+------------------------+-------------------+-----------------+----------------+ 438| Total Risk Rating | High (15) | High (15) | High (15) | 439+------------------------+-------------------+-----------------+----------------+ 440| Mitigations | | 1) Use proper input validation. | 441| | | 442| | | 2) Code reviews, testing. | 443+------------------------+------------------------------------------------------+ 444| Mitigations | | 1) Yes. | 445| implemented? | Data received from normal world, such as addresses | 446| | and sizes identifying memory regions, are | 447| | sanitized before being used. These security checks | 448| | make sure that the normal world software does not | 449| | access memory beyond its limit. | 450| | | 451| | | By default *asserts* are only used to check for | 452| | programming errors in debug builds. Other types of | 453| | errors are handled through condition checks that | 454| | remain enabled in release builds. See | 455| | `TF-A error handling policy`_. TF-A provides an | 456| | option to use *asserts* in release builds, however | 457| | we recommend using proper runtime checks instead | 458| | of relying on asserts in release builds. | 459| | | 460| | | 2) Yes. | 461| | TF-A uses a combination of manual code reviews | 462| | and automated program analysis and testing to | 463| | detect and fix memory corruption bugs. All TF-A | 464| | code including platform code go through manual | 465| | code reviews. Additionally, static code analysis | 466| | is performed using Coverity Scan on all TF-A code. | 467| | The code is also tested with | 468| | `Trusted Firmware-A Tests`_ on Juno and FVP | 469| | platforms. | 470+------------------------+------------------------------------------------------+ 471 472 473+------------------------+----------------------------------------------------+ 474| ID | 11 | 475+========================+====================================================+ 476| Threat | | **Misconfiguration of the Memory Management Unit | 477| | (MMU) may allow a normal world software to | 478| | access sensitive data, execute arbitrary | 479| | code or access otherwise restricted HW | 480| | interface** | 481| | | 482| | | A misconfiguration of the MMU could | 483| | lead to an open door for software running in the | 484| | normal world to access sensitive data or even | 485| | execute code if the proper security mechanisms | 486| | are not in place. | 487+------------------------+----------------------------------------------------+ 488| Diagram Elements | DF5, DF6 | 489+------------------------+----------------------------------------------------+ 490| Affected TF-A | BL1, BL2, BL31 | 491| Components | | 492+------------------------+----------------------------------------------------+ 493| Assets | Sensitive Data, Code execution | 494+------------------------+----------------------------------------------------+ 495| Threat Agent | NSCode | 496+------------------------+----------------------------------------------------+ 497| Threat Type | Information Disclosure, Elevation of Privilege | 498+------------------------+-----------------+-----------------+----------------+ 499| Application | Server | IoT | Mobile | 500+------------------------+-----------------+-----------------+----------------+ 501| Impact | Critical (5) | Critical (5) | Critical (5) | 502+------------------------+-----------------+-----------------+----------------+ 503| Likelihood | High (4) | High (4) | High (4) | 504+------------------------+-----------------+-----------------+----------------+ 505| Total Risk Rating | Critical (20) | Critical (20) | Critical (20) | 506+------------------------+-----------------+-----------------+----------------+ 507| Mitigations | When configuring access permissions, the | 508| | principle of least privilege ought to be | 509| | enforced. This means we should not grant more | 510| | privileges than strictly needed, e.g. code | 511| | should be read-only executable, read-only data | 512| | should be read-only execute-never, and so on. | 513+------------------------+----------------------------------------------------+ 514| Mitigations | | Platform specific. | 515| implemented? | | 516| | | MMU configuration is platform specific, | 517| | therefore platforms need to make sure that the | 518| | correct attributes are assigned to memory | 519| | regions. | 520| | | 521| | | TF-A provides a library which abstracts the | 522| | low-level details of MMU configuration. It | 523| | provides well-defined and tested APIs. | 524| | Platforms are encouraged to use it to limit the | 525| | risk of misconfiguration. | 526+------------------------+----------------------------------------------------+ 527 528 529+------------------------+-----------------------------------------------------+ 530| ID | 13 | 531+========================+=====================================================+ 532| Threat | | **Leaving sensitive information in the memory, | 533| | can allow an attacker to retrieve them.** | 534| | | 535| | | Accidentally leaving not-needed sensitive data in | 536| | internal buffers can leak them if an attacker | 537| | gains access to memory due to a vulnerability. | 538+------------------------+-----------------------------------------------------+ 539| Diagram Elements | DF4, DF5 | 540+------------------------+-----------------------------------------------------+ 541| Affected TF-A | BL1, BL2, BL31 | 542| Components | | 543+------------------------+-----------------------------------------------------+ 544| Assets | Sensitive Data | 545+------------------------+-----------------------------------------------------+ 546| Threat Agent | NSCode, SecCode | 547+------------------------+-----------------------------------------------------+ 548| Threat Type | Information Disclosure | 549+------------------------+-------------------+----------------+----------------+ 550| Application | Server | IoT | Mobile | 551+------------------------+-------------------+----------------+----------------+ 552| Impact | Critical (5) | Critical (5) | Critical (5) | 553+------------------------+-------------------+----------------+----------------+ 554| Likelihood | Medium (3) | Medium (3) | Medium (3) | 555+------------------------+-------------------+----------------+----------------+ 556| Total Risk Rating | High (15) | High (15) | High (15) | 557+------------------------+-------------------+----------------+----------------+ 558| Mitigations | Clear the sensitive data from internal buffers as | 559| | soon as they are not needed anymore. | 560+------------------------+-----------------------------------------------------+ 561| Mitigations | | Yes / Platform specific | 562| implemented? | | 563+------------------------+-----------------------------------------------------+ 564 565 566+------------------------+-----------------------------------------------------+ 567| ID | 15 | 568+========================+=====================================================+ 569| Threat | | **Improper handling of input data received over | 570| | a UART interface may allow an attacker to tamper | 571| | with TF-A execution environment.** | 572| | | 573| | | The consequences of the attack depend on the | 574| | the exact usage of input data received over UART. | 575| | Examples are injection of arbitrary data, | 576| | sensitive data tampering, influencing the | 577| | execution path, denial of service (if using | 578| | blocking I/O). This list may not be exhaustive. | 579+------------------------+-----------------------------------------------------+ 580| Diagram Elements | DF2, DF4, DF5 | 581+------------------------+-----------------------------------------------------+ 582| Affected TF-A | BL1, BL2, BL31 | 583| Components | | 584+------------------------+-----------------------------------------------------+ 585| Assets | Sensitive Data, Code Execution, Availability | 586+------------------------+-----------------------------------------------------+ 587| Threat Agent | NSCode, SecCode | 588+------------------------+-----------------------------------------------------+ 589| Threat Type | Tampering, Information Disclosure, Denial of | 590| | service, Elevation of privilege. | 591+------------------------+-------------------+----------------+----------------+ 592| Application | Server | IoT | Mobile | 593+------------------------+-------------------+----------------+----------------+ 594| Impact | Critical (5) | Critical (5) | Critical (5) | 595+------------------------+-------------------+----------------+----------------+ 596| Likelihood | Critical (5) | Critical (5) | Critical (5) | 597+------------------------+-------------------+----------------+----------------+ 598| Total Risk Rating | Critical (25) | Critical (25) | Critical (25) | 599+------------------------+-------------------+----------------+----------------+ 600| Mitigations | | By default, the code to read input data from UART | 601| | interfaces is disabled (see `ENABLE_CONSOLE_GETC` | 602| | build option). It should only be enabled on a | 603| | need basis. | 604| | | 605| | | Data received over UART interfaces should be | 606| | treated as untrusted data. As such, it should be | 607| | properly sanitized and handled with caution. | 608+------------------------+-----------------------------------------------------+ 609| Mitigations | | Platform specific. | 610| implemented? | | 611| | | Generic code does not read any input data from | 612| | UART interface(s). | 613+------------------------+-----------------------------------------------------+ 614 615 616.. _Boot Firmware Threats: 617 618Threats to be Mitigated by the Boot Firmware 619-------------------------------------------- 620 621The boot firmware here refers to the boot ROM (BL1) and the trusted boot 622firmware (BL2). Typically it does not stay resident in memory and it is 623dismissed once execution has reached the runtime EL3 firmware (BL31). Thus, past 624that point in time, the threats below can no longer be exploited. 625 626Note, however, that this is not necessarily true on all platforms. Platform 627vendors should review these threats to make sure they cannot be exploited 628nonetheless once execution has reached the runtime EL3 firmware. 629 630+------------------------+----------------------------------------------------+ 631| ID | 01 | 632+========================+====================================================+ 633| Threat | | **An attacker can mangle firmware images to | 634| | execute arbitrary code** | 635| | | 636| | | Some TF-A images are loaded from external | 637| | storage. It is possible for an attacker to access| 638| | the external flash memory and change its contents| 639| | physically, through the Rich OS, or using the | 640| | updating mechanism to modify the non-volatile | 641| | images to execute arbitrary code. | 642+------------------------+----------------------------------------------------+ 643| Diagram Elements | DF1, DF4, DF5 | 644+------------------------+----------------------------------------------------+ 645| Affected TF-A | BL2, BL31 | 646| Components | | 647+------------------------+----------------------------------------------------+ 648| Assets | Code Execution | 649+------------------------+----------------------------------------------------+ 650| Threat Agent | PhysicalAccess, NSCode, SecCode | 651+------------------------+----------------------------------------------------+ 652| Threat Type | Tampering, Elevation of Privilege | 653+------------------------+------------------+-----------------+---------------+ 654| Application | Server | IoT | Mobile | 655+------------------------+------------------+-----------------+---------------+ 656| Impact | Critical (5) | Critical (5) | Critical (5) | 657+------------------------+------------------+-----------------+---------------+ 658| Likelihood | Critical (5) | Critical (5) | Critical (5) | 659+------------------------+------------------+-----------------+---------------+ 660| Total Risk Rating | Critical (25) | Critical (25) | Critical (25) | 661+------------------------+------------------+-----------------+---------------+ 662| Mitigations | | 1) Implement the `Trusted Board Boot (TBB)`_ | 663| | feature which prevents malicious firmware from | 664| | running on the platform by authenticating all | 665| | firmware images. | 666| | | 667| | | 2) Perform extra checks on unauthenticated data, | 668| | such as FIP metadata, prior to use. | 669+------------------------+----------------------------------------------------+ 670| Mitigations | | 1) Yes, provided that the ``TRUSTED_BOARD_BOOT`` | 671| implemented? | build option is set to 1. | 672| | | 673| | | 2) Yes. | 674+------------------------+----------------------------------------------------+ 675 676+------------------------+----------------------------------------------------+ 677| ID | 02 | 678+========================+====================================================+ 679| Threat | | **An attacker may attempt to boot outdated, | 680| | potentially vulnerable firmware image** | 681| | | 682| | | When updating firmware, an attacker may attempt | 683| | to rollback to an older version that has unfixed | 684| | vulnerabilities. | 685+------------------------+----------------------------------------------------+ 686| Diagram Elements | DF1, DF4, DF5 | 687+------------------------+----------------------------------------------------+ 688| Affected TF-A | BL2, BL31 | 689| Components | | 690+------------------------+----------------------------------------------------+ 691| Assets | Code Execution | 692+------------------------+----------------------------------------------------+ 693| Threat Agent | PhysicalAccess, NSCode, SecCode | 694+------------------------+----------------------------------------------------+ 695| Threat Type | Tampering | 696+------------------------+------------------+-----------------+---------------+ 697| Application | Server | IoT | Mobile | 698+------------------------+------------------+-----------------+---------------+ 699| Impact | Critical (5) | Critical (5) | Critical (5) | 700+------------------------+------------------+-----------------+---------------+ 701| Likelihood | Critical (5) | Critical (5) | Critical (5) | 702+------------------------+------------------+-----------------+---------------+ 703| Total Risk Rating | Critical (25) | Critical (25) | Critical (25) | 704+------------------------+------------------+-----------------+---------------+ 705| Mitigations | Implement anti-rollback protection using | 706| | non-volatile counters (NV counters) as required | 707| | by `TBBR-Client specification`_. | 708+------------------------+----------------------------------------------------+ 709| Mitigations | | Yes / Platform specific. | 710| implemented? | | 711| | | After a firmware image is validated, the image | 712| | revision number taken from a certificate | 713| | extension field is compared with the | 714| | corresponding NV counter stored in hardware to | 715| | make sure the new counter value is larger than | 716| | the current counter value. | 717| | | 718| | | **Platforms must implement this protection using | 719| | platform specific hardware NV counters.** | 720+------------------------+----------------------------------------------------+ 721 722 723+------------------------+-------------------------------------------------------+ 724| ID | 03 | 725+========================+=======================================================+ 726| Threat | | **An attacker can use Time-of-Check-Time-of-Use | 727| | (TOCTOU) attack to bypass image authentication | 728| | during the boot process** | 729| | | 730| | | Time-of-Check-Time-of-Use (TOCTOU) threats occur | 731| | when the security check is produced before the time | 732| | the resource is accessed. If an attacker is sitting | 733| | in the middle of the off-chip images, they could | 734| | change the binary containing executable code right | 735| | after the integrity and authentication check has | 736| | been performed. | 737+------------------------+-------------------------------------------------------+ 738| Diagram Elements | DF1 | 739+------------------------+-------------------------------------------------------+ 740| Affected TF-A | BL1, BL2 | 741| Components | | 742+------------------------+-------------------------------------------------------+ 743| Assets | Code Execution, Sensitive Data | 744+------------------------+-------------------------------------------------------+ 745| Threat Agent | PhysicalAccess | 746+------------------------+-------------------------------------------------------+ 747| Threat Type | Elevation of Privilege | 748+------------------------+---------------------+-----------------+---------------+ 749| Application | Server | IoT | Mobile | 750+------------------------+---------------------+-----------------+---------------+ 751| Impact | N/A | Critical (5) | Critical (5) | 752+------------------------+---------------------+-----------------+---------------+ 753| Likelihood | N/A | Medium (3) | Medium (3) | 754+------------------------+---------------------+-----------------+---------------+ 755| Total Risk Rating | N/A | High (15) | High (15) | 756+------------------------+---------------------+-----------------+---------------+ 757| Mitigations | Copy image to on-chip memory before authenticating | 758| | it. | 759+------------------------+-------------------------------------------------------+ 760| Mitigations | | Platform specific. | 761| implemented? | | 762| | | The list of images to load and their location is | 763| | platform specific. Platforms are responsible for | 764| | arranging images to be loaded in on-chip memory. | 765+------------------------+-------------------------------------------------------+ 766 767 768+------------------------+-------------------------------------------------------+ 769| ID | 04 | 770+========================+=======================================================+ 771| Threat | | **An attacker with physical access can execute | 772| | arbitrary image by bypassing the signature | 773| | verification stage using glitching techniques** | 774| | | 775| | | Glitching (Fault injection) attacks attempt to put | 776| | a hardware into a undefined state by manipulating an| 777| | environmental variable such as power supply. | 778| | | 779| | | TF-A relies on a chain of trust that starts with the| 780| | ROTPK, which is the key stored inside the chip and | 781| | the root of all validation processes. If an attacker| 782| | can break this chain of trust, they could execute | 783| | arbitrary code on the device. This could be | 784| | achieved with physical access to the device by | 785| | attacking the normal execution flow of the | 786| | process using glitching techniques that target | 787| | points where the image is validated against the | 788| | signature. | 789+------------------------+-------------------------------------------------------+ 790| Diagram Elements | DF1 | 791+------------------------+-------------------------------------------------------+ 792| Affected TF-A | BL1, BL2 | 793| Components | | 794+------------------------+-------------------------------------------------------+ 795| Assets | Code Execution | 796+------------------------+-------------------------------------------------------+ 797| Threat Agent | PhysicalAccess | 798+------------------------+-------------------------------------------------------+ 799| Threat Type | Tampering, Elevation of Privilege | 800+------------------------+---------------------+-----------------+---------------+ 801| Application | Server | IoT | Mobile | 802+------------------------+---------------------+-----------------+---------------+ 803| Impact | N/A | Critical (5) | Critical (5) | 804+------------------------+---------------------+-----------------+---------------+ 805| Likelihood | N/A | Medium (3) | Medium (3) | 806+------------------------+---------------------+-----------------+---------------+ 807| Total Risk Rating | N/A | High (15) | High (15) | 808+------------------------+---------------------+-----------------+---------------+ 809| Mitigations | Mechanisms to detect clock glitch and power | 810| | variations. | 811+------------------------+-------------------------------------------------------+ 812| Mitigations | | No. | 813| implemented? | | 814| | | The most effective mitigation is adding glitching | 815| | detection and mitigation circuit at the hardware | 816| | level. | 817| | | 818| | | However, software techniques, such as adding | 819| | redundant checks when performing conditional | 820| | branches that are security sensitive, can be used | 821| | to harden TF-A against such attacks. | 822| | **At the moment TF-A doesn't implement such | 823| | mitigations.** | 824+------------------------+-------------------------------------------------------+ 825 826.. topic:: Measured Boot Threats (or lack of) 827 828 In the current Measured Boot design, BL1, BL2, and BL31, as well as the 829 secure world components, form the |SRTM|. Measurement data is currently 830 considered an asset to be protected against attack, and this is achieved 831 by storing them in the Secure Memory. 832 Beyond the measurements stored inside the TCG-compliant Event Log buffer, 833 there are no other assets to protect or threats to defend against that 834 could compromise |TF-A| execution environment's security. 835 836 There are general security assets and threats associated with remote/delegated 837 attestation. However, these are outside the |TF-A| security boundary and 838 should be dealt with by the appropriate agent in the platform/system. 839 Since current Measured Boot design does not use local attestation, there would 840 be no further assets to protect(like unsealed keys). 841 842 A limitation of the current Measured Boot design is that it is dependent upon 843 Secure Boot as implementation of Measured Boot does not extend measurements 844 into a discrete |TPM|, where they would be securely stored and protected 845 against tampering. This implies that if Secure-Boot is compromised, Measured 846 Boot may also be compromised. 847 848 Platforms must carefully evaluate the security of the default implementation 849 since the |SRTM| includes all secure world components. 850 851 852.. _Runtime Firmware Threats: 853 854Threats to be Mitigated by the Runtime EL3 Firmware 855--------------------------------------------------- 856 857+------------------------+------------------------------------------------------+ 858| ID | 07 | 859+========================+======================================================+ 860| Threat | | **An attacker can perform a denial-of-service | 861| | attack by using a broken SMC call that causes the | 862| | system to reboot or enter into unknown state.** | 863| | | 864| | | Secure and non-secure clients access TF-A services | 865| | through SMC calls. Malicious code can attempt to | 866| | place the TF-A runtime into an inconsistent state | 867| | by calling unimplemented SMC call or by passing | 868| | invalid arguments. | 869+------------------------+------------------------------------------------------+ 870| Diagram Elements | DF4, DF5 | 871+------------------------+------------------------------------------------------+ 872| Affected TF-A | BL31 | 873| Components | | 874+------------------------+------------------------------------------------------+ 875| Assets | Availability | 876+------------------------+------------------------------------------------------+ 877| Threat Agent | NSCode, SecCode | 878+------------------------+------------------------------------------------------+ 879| Threat Type | Denial of Service | 880+------------------------+-------------------+----------------+-----------------+ 881| Application | Server | IoT | Mobile | 882+------------------------+-------------------+----------------+-----------------+ 883| Impact | Medium (3) | Medium (3) | Medium (3) | 884+------------------------+-------------------+----------------+-----------------+ 885| Likelihood | High (4) | High (4) | High (4) | 886+------------------------+-------------------+----------------+-----------------+ 887| Total Risk Rating | High (12) | High (12) | High (12) | 888+------------------------+-------------------+----------------+-----------------+ 889| Mitigations | Validate SMC function ids and arguments before using | 890| | them. | 891+------------------------+------------------------------------------------------+ 892| Mitigations | | Yes / Platform specific. | 893| implemented? | | 894| | | For standard services, all input is validated. | 895| | | 896| | | Platforms that implement SiP services must also | 897| | validate SMC call arguments. | 898+------------------------+------------------------------------------------------+ 899 900 901+------------------------+------------------------------------------------------+ 902| ID | 09 | 903+========================+======================================================+ 904| Threat | | **Improperly handled SMC calls can leak register | 905| | contents** | 906| | | 907| | | When switching between worlds, TF-A register state | 908| | can leak to software in different security | 909| | contexts. | 910+------------------------+------------------------------------------------------+ 911| Diagram Elements | DF4, DF5 | 912+------------------------+------------------------------------------------------+ 913| Affected TF-A | BL31 | 914| Components | | 915+------------------------+------------------------------------------------------+ 916| Assets | Sensitive Data | 917+------------------------+------------------------------------------------------+ 918| Threat Agent | NSCode, SecCode | 919+------------------------+------------------------------------------------------+ 920| Threat Type | Information Disclosure | 921+------------------------+-------------------+----------------+-----------------+ 922| Application | Server | IoT | Mobile | 923+------------------------+-------------------+----------------+-----------------+ 924| Impact | Medium (3) | Medium (3) | Medium (3) | 925+------------------------+-------------------+----------------+-----------------+ 926| Likelihood | High (4) | High (4) | High (4) | 927+------------------------+-------------------+----------------+-----------------+ 928| Total Risk Rating | High (12) | High (12) | High (12) | 929+------------------------+-------------------+----------------+-----------------+ 930| Mitigations | Save and restore registers when switching contexts. | 931+------------------------+------------------------------------------------------+ 932| Mitigations | | Yes. | 933| implemented? | | 934| | | This is the default behaviour in TF-A. | 935| | Build options are also provided to save/restore | 936| | additional registers such as floating-point | 937| | registers. These should be enabled if required. | 938+------------------------+------------------------------------------------------+ 939 940+------------------------+-----------------------------------------------------+ 941| ID | 10 | 942+========================+=====================================================+ 943| Threat | | **SMC calls can leak sensitive information from | 944| | TF-A memory via microarchitectural side channels**| 945| | | 946| | | Microarchitectural side-channel attacks such as | 947| | `Spectre`_ can be used to leak data across | 948| | security boundaries. An attacker might attempt to | 949| | use this kind of attack to leak sensitive | 950| | data from TF-A memory. | 951+------------------------+-----------------------------------------------------+ 952| Diagram Elements | DF4, DF5 | 953+------------------------+-----------------------------------------------------+ 954| Affected TF-A | BL31 | 955| Components | | 956+------------------------+-----------------------------------------------------+ 957| Assets | Sensitive Data | 958+------------------------+-----------------------------------------------------+ 959| Threat Agent | SecCode, NSCode | 960+------------------------+-----------------------------------------------------+ 961| Threat Type | Information Disclosure | 962+------------------------+-------------------+----------------+----------------+ 963| Application | Server | IoT | Mobile | 964+------------------------+-------------------+----------------+----------------+ 965| Impact | Medium (3) | Medium (3) | Medium (3) | 966+------------------------+-------------------+----------------+----------------+ 967| Likelihood | Medium (3) | Medium (3) | Medium (3) | 968+------------------------+-------------------+----------------+----------------+ 969| Total Risk Rating | Medium (9) | Medium (9) | Medium (9) | 970+------------------------+-------------------+----------------+----------------+ 971| Mitigations | Enable appropriate side-channel protections. | 972+------------------------+-----------------------------------------------------+ 973| Mitigations | | Yes / Platform specific. | 974| implemented? | | 975| | | TF-A implements software mitigations for Spectre | 976| | type attacks as recommended by `Cache Speculation | 977| | Side-channels`_ for the generic code. | 978| | | 979| | | SiPs should implement similar mitigations for | 980| | code that is deemed to be vulnerable to such | 981| | attacks. | 982+------------------------+-----------------------------------------------------+ 983 984 985+------------------------+-----------------------------------------------------+ 986| ID | 12 | 987+========================+=====================================================+ 988| Threat | | **Incorrect configuration of Performance Monitor | 989| | Unit (PMU) counters can allow an attacker to | 990| | mount side-channel attacks using information | 991| | exposed by the counters** | 992| | | 993| | | Non-secure software can configure PMU registers | 994| | to count events at any exception level and in | 995| | both Secure and Non-secure states. This allows | 996| | a Non-secure software (or a lower-level Secure | 997| | software) to potentially carry out | 998| | side-channel timing attacks against TF-A. | 999+------------------------+-----------------------------------------------------+ 1000| Diagram Elements | DF5, DF6 | 1001+------------------------+-----------------------------------------------------+ 1002| Affected TF-A | BL31 | 1003| Components | | 1004+------------------------+-----------------------------------------------------+ 1005| Assets | Sensitive Data | 1006+------------------------+-----------------------------------------------------+ 1007| Threat Agent | NSCode | 1008+------------------------+-----------------------------------------------------+ 1009| Threat Type | Information Disclosure | 1010+------------------------+-------------------+----------------+----------------+ 1011| Application | Server | IoT | Mobile | 1012+------------------------+-------------------+----------------+----------------+ 1013| Impact | Medium (3) | Medium (3) | Medium (3) | 1014+------------------------+-------------------+----------------+----------------+ 1015| Likelihood | Low (2) | Low (2) | Low (2) | 1016+------------------------+-------------------+----------------+----------------+ 1017| Total Risk Rating | Medium (6) | Medium (6) | Medium (6) | 1018+------------------------+-------------------+----------------+----------------+ 1019| Mitigations | Follow mitigation strategies as described in | 1020| | `Secure Development Guidelines`_. | 1021+------------------------+-----------------------------------------------------+ 1022| Mitigations | | Yes / platform specific. | 1023| implemented? | | 1024| | | General events and cycle counting in the Secure | 1025| | world is prohibited by default when applicable. | 1026| | | 1027| | | However, on some implementations (e.g. PMUv3) | 1028| | Secure world event counting depends on external | 1029| | debug interface signals, i.e. Secure world event | 1030| | counting is enabled if external debug is enabled. | 1031| | | 1032| | | Configuration of debug signals is platform | 1033| | specific, therefore platforms need to make sure | 1034| | that external debug is disabled in production or | 1035| | proper debug authentication is in place. This | 1036| | should be the case if threat #06 is properly | 1037| | mitigated. | 1038+------------------------+-----------------------------------------------------+ 1039 1040 1041Threats to be Mitigated by an External Agent Outside of TF-A 1042------------------------------------------------------------ 1043 1044+------------------------+-----------------------------------------------------+ 1045| ID | 14 | 1046+========================+=====================================================+ 1047| Threat | | **Attacker wants to execute an arbitrary or | 1048| | untrusted binary as the secure OS.** | 1049| | | 1050| | | When the option OPTEE_ALLOW_SMC_LOAD is enabled, | 1051| | this trusts the non-secure world up until the | 1052| | point it issues the SMC call to load the Secure | 1053| | BL32 payload. If a compromise occurs before the | 1054| | SMC call is invoked, then arbitrary code execution| 1055| | in S-EL1 can occur or arbitrary memory in EL3 can | 1056| | be overwritten. | 1057+------------------------+-----------------------------------------------------+ 1058| Diagram Elements | DF5 | 1059+------------------------+-----------------------------------------------------+ 1060| Affected TF-A | BL31, BL32 | 1061| Components | | 1062+------------------------+-----------------------------------------------------+ 1063| Assets | Code Execution, Sensitive Data | 1064+------------------------+-----------------------------------------------------+ 1065| Threat Agent | NSCode | 1066+------------------------+-----------------------------------------------------+ 1067| Threat Type | Tampering, Information Disclosure, | 1068| | Elevation of privilege | 1069+------------------------+-----------------+-----------------+-----------------+ 1070| Application | Server | IoT | Mobile | 1071+------------------------+-----------------+-----------------+-----------------+ 1072| Impact | Critical (5) | Critical (5) | Critical (5) | 1073+------------------------+-----------------+-----------------+-----------------+ 1074| Likelihood | High (4) | High (4) | High (4) | 1075+------------------------+-----------------+-----------------+-----------------+ 1076| Total Risk Rating | Critical (20) | Critical (20) | Critical (20) | 1077+------------------------+-----------------+-----------------+-----------------+ 1078| Mitigations | When enabling the option OPTEE_ALLOW_SMC_LOAD, | 1079| | the non-secure OS must be considered a closed | 1080| | platform up until the point the SMC can be invoked | 1081| | to load OP-TEE. | 1082+------------------------+-----------------------------------------------------+ 1083| Mitigations | | None in TF-A itself. This option is only used by | 1084| implemented? | ChromeOS currently which has other mechanisms to | 1085| | to mitigate this threat which are described in | 1086| | `OP-TEE Dispatcher`_. | 1087+------------------------+-----------------------------------------------------+ 1088 1089-------------- 1090 1091*Copyright (c) 2021-2023, Arm Limited. All rights reserved.* 1092 1093 1094.. _STRIDE threat analysis technique: https://docs.microsoft.com/en-us/azure/security/develop/threat-modeling-tool-threats#stride-model 1095.. _DEN0034: https://developer.arm.com/documentation/den0034/latest 1096.. _Cache Speculation Side-channels: https://developer.arm.com/support/arm-security-updates/speculative-processor-vulnerability 1097.. _Spectre: https://developer.arm.com/support/arm-security-updates/speculative-processor-vulnerability 1098.. _TBBR-Client specification: https://developer.arm.com/documentation/den0006/d/ 1099.. _Trusted Board Boot (TBB): https://trustedfirmware-a.readthedocs.io/en/latest/design/trusted-board-boot.html 1100.. _TF-A error handling policy: https://trustedfirmware-a.readthedocs.io/en/latest/process/coding-guidelines.html#error-handling-and-robustness 1101.. _Secure Development Guidelines: https://trustedfirmware-a.readthedocs.io/en/latest/process/security-hardening.html#secure-development-guidelines 1102.. _Trusted Firmware-A Tests: https://git.trustedfirmware.org/TF-A/tf-a-tests.git/about/ 1103.. _OP-TEE Dispatcher: https://github.com/ARM-software/arm-trusted-firmware/blob/master/docs/components/spd/optee-dispatcher.rst 1104