fix: validate secret key before updating service accounts

This commit is contained in:
Harshavardhana 2021-05-05 16:36:39 -07:00
parent b8833c2947
commit f4623ea8dc

View File

@ -1203,6 +1203,10 @@ func (sys *IAMSys) UpdateServiceAccount(ctx context.Context, accessKey string, o
return errNoSuchServiceAccount
}
if !auth.IsSecretKeyValid(opts.secretKey) {
return auth.ErrInvalidSecretKeyLength
}
if opts.secretKey != "" {
cr.SecretKey = opts.secretKey
}
@ -1346,6 +1350,14 @@ func (sys *IAMSys) CreateUser(accessKey string, uinfo madmin.UserInfo) error {
return errIAMActionNotAllowed
}
if !auth.IsAccessKeyValid(accessKey) {
return auth.ErrInvalidAccessKeyLength
}
if !auth.IsSecretKeyValid(uinfo.SecretKey) {
return auth.ErrInvalidSecretKeyLength
}
sys.store.lock()
defer sys.store.unlock()
@ -1388,6 +1400,14 @@ func (sys *IAMSys) SetUserSecretKey(accessKey string, secretKey string) error {
return errIAMActionNotAllowed
}
if !auth.IsAccessKeyValid(accessKey) {
return auth.ErrInvalidAccessKeyLength
}
if !auth.IsSecretKeyValid(secretKey) {
return auth.ErrInvalidSecretKeyLength
}
sys.store.lock()
defer sys.store.unlock()