CVE-2020-8918: Github.com/google/go tpm TPM 1.2 Key Authorization Values Vulnerability

HIGH
Advisory Identifier: GHSA-5x29-3hr9-6wpw
CVSS 7.1
CWE-665
Published
Advisory Summary

CVE-2020-8918 is a HIGH (CVSS 7.1) tpm 1.2 key authorization values vulnerability (CWE-665: Improper Initialization) affecting Github.com/google/go tpm libraries in the Go ecosystem. The issue involves tpm 1.2 key authorization values vulnerable to tpm transport eavesdropper in go-tpm. Remediation is available by upgrading affected packages to version 0.3.0.

CVE-2020-8918 at a Glance

CVE Identifier CVE-2020-8918
GHSA Identifier GHSA-5x29-3hr9-6wpw
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-665: Improper Initialization
Affected Product Github.com/google/go tpm
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2020-8918

To remediate this vulnerability, upgrade all affected Github.com/google/go tpm dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/google/go-tpm fixed: 0.3.0
Upgrade github.com/google/go-tpm to 0.3.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/google/go-tpm

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-8918, inspect your project dependencies for Github.com/google/go tpm:

inspect dependencies for github.com/google/go-tpm

Analyze the terminal output to locate any version of Github.com/google/go tpm in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.3.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-665: Improper Initialization, where the product does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used. In Github.com/google/go tpm, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Impact TPM 2.0 users are unaffected by this issue. An adversary eavesdropping on the TPM 1.2 transport path can calculate `usageAuth` for a key created with CreateWrapKey, even though this value is encrypted as part of the TPM 1.2 command protocol. The TPM 1.2 CreateWrapKey command accepts two secrets: `usageAuth` and `migrationAuth`. The ADIP protocol ([TPM 1.2 specification, part 1, section 13.4](https://trustedcomputinggroup.org/wp-content/uploads/TPM-Main-Part-1-Design-Principles_v1.2_rev116_01032011.pdf)) calls for these values to be encrypted with two different XOR keys. Due to a bug in go-tpm prior to version 0.3.0, both `usageAuth` and `migrationAuth` are encrypted with the same XOR keystream. This allows an adversary to XOR `encUsageAuth` and `encMigrationAuth` together to calculate `usageAuth ^ encMigrationAuth`. Since `migrationAuth` is moot for all keys created with go-tpm's `CreateWrapKey` (since all keys created with this function are marked non-migratable), an adversary may guess or know (from code/binary inspection) that `migrationAuth` is all 0x00 bytes or some other fixed value. Such an adversary can then calculate `usageAuth` and use this value later to improperly use the created key, unbeknownst to the creator of the key. ### Patches Fixed in go-tpm version 0.3.0. ### Workarounds - TPM 2.0 users: No workaround needed. This issue only affects TPM 1.2 users. - TPM 1.2 users: Call CreateWrapKey with a random 20-byte value for `migrationAuth`, even though that value is not used again (since CreateWrapKey creates keys that are non-migratable). Do not store or log this value. ### Details TPM 1.2 uses a protocol called ADIP (Authorization Data Insertion Protocol) to encrypt authorization values over-the-wire for newly created objects. This prevents a bus-snooping attack like those publicized by TPM Genie. TPM 2.0 makes this optional (the way to do it is with parameter-encryption sessions). You can read more about ADIP in section 13.4 of Part 1: Design Principles in the latest [TPM 1.2 specification](https://trustedcomputinggroup.org/resource/tpm-main-specification/). Normally, ADIP consists of the following steps: ``` Key := SHA1(authSession.SharedSecret || a nonce) Note: nonces and auth values in TPM 1.2 are always 20 bytes EncAuth := XOR(Key, Auth) ``` When commands require one ADIP-encrypted auth value, the nonce is the last nonceEven (last nonce from the TPM). When commands require two ADIP-encrypted auth values, the nonce for the first auth value is still nonceEven, and the nonce for the second auth value is the last nonceOdd, which is the one being provided by the caller along with the current command on the session. The reason for this is that you wouldn't want an adversary to be able to XOR the two encrypted auth values together and come up with (auth 1 XOR key) XOR (auth 2 XOR key) where the "one-time" pad key is used twice and cancels itself out. Here are the commands that take one authorization value by ADIP: - Seal (the sealed data's auth value) - Sealx (the sealed data's auth value) - CreateKey (the key's auth value) - MakeIdentity (the AIK's auth value) - ChangeAuth (the entity's new auth value) - ChangeAuthOwner (the new owner auth value) - Delegate_CreateKeyDelegation (the new delegation auth value) - Delegate_CreateOwnerDelegation (the new delegation auth value) - NV_DefineSpace (the NV's auth value) - CreateCounter (the counter's auth value) Here are the commands that take two authorization values by ADIP: - CreateWrapKey (the key's auth value, and the key's migration (to export out of the TPM) auth value) The migrationAuth value is never used if the key does not have the `TPM_KEY_FLAGS.migratable` flag set on it. go-tpm does not currently allow the caller to set this flag. Here was the bug in our implementation of `CreateWrapKey()`: https://github.com/google/go-tpm/blob/16766ac4521425bd02ad23868fbdf24749268669/tpm/tpm.go#L1322-L1329 Here we see that both usageAuth and migrationAuth are encrypted by the same XOR key. This is the correct key (i.e., it is based on nonceEven) for usageAuth, but not migrationAuth. This means 2 things: **First: migrationAuth is being set to some value that is effectively unrelated to migrationAuth as passed by the caller.** Again, this is not interesting to all current callers (given that there is no way for them to pass `TPM_KEY_FLAGS.migratable` via the current API; migrationAuth is not a meaningful value). **Second, and much more importantly: a user of go-tpm is vulnerable to the following attack by a passive bus-snooping adversary (CVE-2020-8918)** 1. Wait for a `CreateWrapKey` command 2. Collect `encUsageAuth` and `encMigrationAuth` 3. Calculate `(usageAuth XOR migrationAuth) := (encUsageAuth XOR encMigrationAuth)` 4. Assuming migrationAuth is all 0x00 (a reasonable assumption for a caller who knows the key is not migratable), the calculation in (3) is the usage auth of the key.

CVE-2020-8918 Affected Github.com/google/go tpm Versions

1 component(s)
Fixed Versions:
0.3.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/google/go-tpm
Go
< 0.3.0
0.3.0

References

Frequently Asked Questions

What is CVE-2020-8918?
CVE-2020-8918 is a security vulnerability in Github.com/google/go tpm involving TPM 1.2 key authorization values vulnerable to TPM transport eavesdropper in go-tpm under CWE-665: Improper Initialization.
Which Github.com/google/go tpm versions are affected?
Affected versions include releases prior to 0.3.0 across affected packages: github.com/google/go-tpm.
What version fixes CVE-2020-8918?
Upgrading to 0.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/google/go-tpm affected?
Yes, github.com/google/go-tpm is affected in releases prior to 0.3.0. Upgrade your dependency to 0.3.0 or later.
What is the CVSS score of CVE-2020-8918?
CVE-2020-8918 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2020-8918?
CVE-2020-8918 is classified under CWE-665: Improper Initialization (The product does not initialize or incorrectly initializes a resource, which might leave the resource in an unexpected state when it is accessed or used.).
How can I check Go dependencies for CVE-2020-8918?
Run the dependency tree command: 'inspect dependencies for github.com/google/go-tpm'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-5x29-3hr9-6wpw",
  "modified" : "2023-08-29T21:08:37Z",
  "published" : "2022-02-11T23:18:09Z",
  "aliases" : [ "CVE-2020-8918" ],
  "summary" : "TPM 1.2 key authorization values vulnerable to TPM transport eavesdropper in go-tpm",
  "details" : "### Impact\nTPM 2.0 users are unaffected by this issue.\n\nAn adversary eavesdropping on the TPM 1.2 transport path can calculate `usageAuth` for a key created with CreateWrapKey, even though this value is encrypted as part of the TPM 1.2 command protocol.\n\nThe TPM 1.2 CreateWrapKey command accepts two secrets: `usageAuth` and `migrationAuth`. The ADIP protocol ([TPM 1.2 specification, part 1, section 13.4](https://trustedcomputinggroup.org/wp-content/uploads/TPM-Main-Part-1-Design-Principles_v1.2_rev116_01032011.pdf)) calls for these values to be encrypted with two different XOR keys. Due to a bug in go-tpm prior to version 0.3.0, both `usageAuth` and `migrationAuth` are encrypted with the same XOR keystream. This allows an adversary to XOR `encUsageAuth` and `encMigrationAuth` together to calculate `usageAuth ^ encMigrationAuth`. Since `migrationAuth` is moot for all keys created with go-tpm's `CreateWrapKey` (since all keys created with this function are marked non-migratable), an adversary may guess or know (from code/binary inspection) that `migrationAuth` is all 0x00 bytes or some other fixed value. Such an adversary can then calculate `usageAuth` and use this value later to improperly use the created key, unbeknownst to the creator of the key.\n\n### Patches\nFixed in go-tpm version 0.3.0.\n\n### Workarounds\n\n- TPM 2.0 users: No workaround needed. This issue only affects TPM 1.2 users.\n- TPM 1.2 users: Call CreateWrapKey with a random 20-byte value for `migrationAuth`, even though that value is not used again (since CreateWrapKey creates keys that are non-migratable). Do not store or log this value.\n\n\n### Details\n\nTPM 1.2 uses a protocol called ADIP (Authorization Data Insertion Protocol) to encrypt authorization values over-the-wire for newly created objects. This prevents a bus-snooping attack like those publicized by TPM Genie. TPM 2.0 makes this optional (the way to do it is with parameter-encryption sessions). You can read more about ADIP in section 13.4 of Part 1: Design Principles in the latest [TPM 1.2 specification](https://trustedcomputinggroup.org/resource/tpm-main-specification/). Normally, ADIP consists of the following steps:\n```\nKey := SHA1(authSession.SharedSecret || a nonce)\nNote: nonces and auth values in TPM 1.2 are always 20 bytes\nEncAuth := XOR(Key, Auth)\n```\nWhen commands require one ADIP-encrypted auth value, the nonce is the last nonceEven (last nonce from the TPM).\nWhen commands require two ADIP-encrypted auth values, the nonce for the first auth value is still nonceEven, and the nonce for the second auth value is the last nonceOdd, which is the one being provided by the caller along with the current command on the session.\nThe reason for this is that you wouldn't want an adversary to be able to XOR the two encrypted auth values together and come up with (auth 1 XOR key) XOR (auth 2 XOR key) where the \"one-time\" pad key is used twice and cancels itself out.\n\nHere are the commands that take one authorization value by ADIP:\n\n- Seal (the sealed data's auth value)\n- Sealx (the sealed data's auth value)\n- CreateKey (the key's auth value)\n- MakeIdentity (the AIK's auth value)\n- ChangeAuth (the entity's new auth value)\n- ChangeAuthOwner (the new owner auth value)\n- Delegate_CreateKeyDelegation (the new delegation auth value)\n- Delegate_CreateOwnerDelegation (the new delegation auth value)\n- NV_DefineSpace (the NV's auth value)\n- CreateCounter (the counter's auth value)\n\nHere are the commands that take two authorization values by ADIP:\n\n- CreateWrapKey (the key's auth value, and the key's migration (to export out of the TPM) auth value)\n\nThe migrationAuth value is never used if the key does not have the `TPM_KEY_FLAGS.migratable` flag set on it. go-tpm does not currently allow the caller to set this flag.\nHere was the bug in our implementation of `CreateWrapKey()`:\n\nhttps://github.com/google/go-tpm/blob/16766ac4521425bd02ad23868fbdf24749268669/tpm/tpm.go#L1322-L1329\n\nHere we see that both usageAuth and migrationAuth are encrypted by the same XOR key. This is the correct key (i.e., it is based on nonceEven) for usageAuth, but not migrationAuth.\n\nThis means 2 things:\n\n**First: migrationAuth is being set to some value that is effectively unrelated to migrationAuth as passed by the caller.** Again, this is not interesting to all current callers (given that there is no way for them to pass `TPM_KEY_FLAGS.migratable` via the current API; migrationAuth is not a meaningful value).\n\n**Second, and much more importantly: a user of go-tpm is vulnerable to the following attack by a passive bus-snooping adversary (CVE-2020-8918)**\n1. Wait for a `CreateWrapKey` command\n2. Collect `encUsageAuth` and `encMigrationAuth`\n3. Calculate `(usageAuth XOR migrationAuth) := (encUsageAuth XOR encMigrationAuth)`\n4. Assuming migrationAuth is all 0x00 (a reasonable assumption for a caller who knows the key is not migratable), the calculation in (3) is the usage auth of the key.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/google/go-tpm"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/google/go-tpm/security/advisories/GHSA-5x29-3hr9-6wpw"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-8918"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/google/go-tpm/pull/195"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/google/go-tpm/commit/d7806cce857a1a020190c03348e5361725d8f141"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/google/go-tpm"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2021-0095"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-665" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-24T18:32:13Z",
    "nvd_published_at" : null
  }
}