mirror of https://github.com/minio/minio.git
return `Access Denied` for invalid SSE keys (#6432)
This commit fixes are regression in the server regarding handling SSE requests with wrong SSE-C keys. The server now returns an AWS S3 compatable API error (access denied) in case of the SSE key does not match the secret key used during upload. Fixes #6431
This commit is contained in:
parent
5c13765168
commit
fd8749f42a
|
@ -1441,7 +1441,7 @@ func toAPIErrorCode(err error) (apiErr APIErrorCode) {
|
||||||
apiErr = ErrSSEEncryptedObject
|
apiErr = ErrSSEEncryptedObject
|
||||||
case errInvalidSSEParameters:
|
case errInvalidSSEParameters:
|
||||||
apiErr = ErrInvalidSSECustomerParameters
|
apiErr = ErrInvalidSSECustomerParameters
|
||||||
case crypto.ErrInvalidCustomerKey:
|
case crypto.ErrInvalidCustomerKey, crypto.ErrSecretKeyMismatch:
|
||||||
apiErr = ErrAccessDenied // no access without correct key
|
apiErr = ErrAccessDenied // no access without correct key
|
||||||
case crypto.ErrIncompatibleEncryptionMethod:
|
case crypto.ErrIncompatibleEncryptionMethod:
|
||||||
apiErr = ErrIncompatibleEncryptionMethod
|
apiErr = ErrIncompatibleEncryptionMethod
|
||||||
|
|
|
@ -43,6 +43,10 @@ var (
|
||||||
// base64-encoded string or not 256 bits long.
|
// base64-encoded string or not 256 bits long.
|
||||||
ErrInvalidCustomerKey = errors.New("The SSE-C client key is invalid")
|
ErrInvalidCustomerKey = errors.New("The SSE-C client key is invalid")
|
||||||
|
|
||||||
|
// ErrSecretKeyMismatch indicates that the provided secret key (SSE-C client key / SSE-S3 KMS key)
|
||||||
|
// does not match the secret key used during encrypting the object.
|
||||||
|
ErrSecretKeyMismatch = errors.New("The secret key does not match the secret key used during upload")
|
||||||
|
|
||||||
// ErrCustomerKeyMD5Mismatch indicates that the SSE-C key MD5 does not match the
|
// ErrCustomerKeyMD5Mismatch indicates that the SSE-C key MD5 does not match the
|
||||||
// computed MD5 sum. This means that the client provided either the wrong key for
|
// computed MD5 sum. This means that the client provided either the wrong key for
|
||||||
// a certain MD5 checksum or the wrong MD5 for a certain key.
|
// a certain MD5 checksum or the wrong MD5 for a certain key.
|
||||||
|
|
|
@ -124,7 +124,7 @@ func (key *ObjectKey) Unseal(extKey [32]byte, sealedKey SealedKey, domain, bucke
|
||||||
}
|
}
|
||||||
|
|
||||||
if n, err := sio.Decrypt(&decryptedKey, bytes.NewReader(sealedKey.Key[:]), unsealConfig); n != 32 || err != nil {
|
if n, err := sio.Decrypt(&decryptedKey, bytes.NewReader(sealedKey.Key[:]), unsealConfig); n != 32 || err != nil {
|
||||||
return err // TODO(aead): upgrade sio to use sio.Error
|
return ErrSecretKeyMismatch
|
||||||
}
|
}
|
||||||
copy(key[:], decryptedKey.Bytes())
|
copy(key[:], decryptedKey.Bytes())
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue