mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
fix: trim arn:aws:kms from incoming SSE aws-kms-key-id (#15540)
This commit is contained in:
@@ -76,6 +76,9 @@ var (
|
||||
// ErrIncompatibleEncryptionMethod indicates that both SSE-C headers and SSE-S3 headers were specified, and are incompatible
|
||||
// The client needs to remove the SSE-S3 header or the SSE-C headers
|
||||
ErrIncompatibleEncryptionMethod = Errorf("Server side encryption specified with both SSE-C and SSE-S3 headers")
|
||||
|
||||
// ErrInvalidEncryptionKeyID returns error when KMS key id contains invalid characters
|
||||
ErrInvalidEncryptionKeyID = Errorf("KMS KeyID contains unsupported characters")
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -56,6 +56,9 @@ const (
|
||||
// be part of the object. Therefore, the bucket/object name must be added
|
||||
// to the context, if not present, whenever a decryption is performed.
|
||||
MetaContext = "X-Minio-Internal-Server-Side-Encryption-Context"
|
||||
|
||||
// ARNPrefix prefix for "arn:aws:kms"
|
||||
ARNPrefix = "arn:aws:kms:"
|
||||
)
|
||||
|
||||
// IsMultiPart returns true if the object metadata indicates
|
||||
|
||||
@@ -55,7 +55,8 @@ func (ssekms) IsRequested(h http.Header) bool {
|
||||
return true
|
||||
}
|
||||
if _, ok := h[xhttp.AmzServerSideEncryption]; ok {
|
||||
return strings.ToUpper(h.Get(xhttp.AmzServerSideEncryption)) != xhttp.AmzEncryptionAES // Return only true if the SSE header is specified and does not contain the SSE-S3 value
|
||||
// Return only true if the SSE header is specified and does not contain the SSE-S3 value
|
||||
return strings.ToUpper(h.Get(xhttp.AmzServerSideEncryption)) != xhttp.AmzEncryptionAES
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -63,6 +64,10 @@ func (ssekms) IsRequested(h http.Header) bool {
|
||||
// ParseHTTP parses the SSE-KMS headers and returns the SSE-KMS key ID
|
||||
// and the KMS context on success.
|
||||
func (ssekms) ParseHTTP(h http.Header) (string, kms.Context, error) {
|
||||
if h == nil {
|
||||
return "", nil, ErrInvalidEncryptionMethod
|
||||
}
|
||||
|
||||
algorithm := h.Get(xhttp.AmzServerSideEncryption)
|
||||
if algorithm != xhttp.AmzEncryptionKMS {
|
||||
return "", nil, ErrInvalidEncryptionMethod
|
||||
@@ -80,7 +85,13 @@ func (ssekms) ParseHTTP(h http.Header) (string, kms.Context, error) {
|
||||
return "", nil, err
|
||||
}
|
||||
}
|
||||
return h.Get(xhttp.AmzServerSideEncryptionKmsID), ctx, nil
|
||||
|
||||
keyID := h.Get(xhttp.AmzServerSideEncryptionKmsID)
|
||||
spaces := strings.HasPrefix(keyID, " ") || strings.HasSuffix(keyID, " ")
|
||||
if spaces {
|
||||
return "", nil, ErrInvalidEncryptionKeyID
|
||||
}
|
||||
return strings.TrimPrefix(keyID, ARNPrefix), ctx, nil
|
||||
}
|
||||
|
||||
// IsEncrypted returns true if the object metadata indicates
|
||||
|
||||
Reference in New Issue
Block a user