Skip to content

Commit

Permalink
fix DoS vulnerability in the content SHA-256 processing (#8026)
Browse files Browse the repository at this point in the history
This commit fixes a DoS issue that is caused by an incorrect
SHA-256 content verification during STS requests.

Before that fix clients could write arbitrary many bytes
to the server memory. This commit fixes this by limiting the
request body size.
  • Loading branch information
Andreas Auernhammer authored and harshavardhana committed Aug 5, 2019
1 parent 414a7ec commit f6d0645
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmd/signature-v4-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"crypto/hmac"
"encoding/hex"
"io"
"io/ioutil"
"net/http"
"strconv"
Expand Down Expand Up @@ -61,7 +62,7 @@ func skipContentSha256Cksum(r *http.Request) bool {
// Returns SHA256 for calculating canonical-request.
func getContentSha256Cksum(r *http.Request, stype serviceType) string {
if stype == serviceSTS {
payload, err := ioutil.ReadAll(r.Body)
payload, err := ioutil.ReadAll(io.LimitReader(r.Body, stsRequestBodyLimit))
if err != nil {
logger.CriticalIf(context.Background(), err)
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/sts-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
clientGrants = "AssumeRoleWithClientGrants"
webIdentity = "AssumeRoleWithWebIdentity"
assumeRole = "AssumeRole"

stsRequestBodyLimit = 10 * (1 << 20) // 10 MiB
)

// stsAPIHandlers implements and provides http handlers for AWS STS API.
Expand Down

0 comments on commit f6d0645

Please sign in to comment.