未验证 提交 cae0911d 编写于 作者: K KubeSphere CI Bot 提交者: GitHub

Merge pull request #1290 from wansir/bug-fix

fix: privilege escalation
......@@ -160,6 +160,11 @@ func UpdateUser(req *restful.Request, resp *restful.Response) {
}
}
if usernameInHeader == user.Username {
// change cluster role by self is not permitted
user.ClusterRole = ""
}
result, err := iam.UpdateUser(&user)
if err != nil {
......
......@@ -1166,11 +1166,13 @@ func UpdateUser(user *models.User) (*models.User, error) {
return nil, err
}
err = CreateClusterRoleBinding(user.Username, user.ClusterRole)
if user.ClusterRole != "" {
err = CreateClusterRoleBinding(user.Username, user.ClusterRole)
if err != nil {
klog.Errorln("create cluster role binding filed", err)
return nil, err
if err != nil {
klog.Errorln(err)
return nil, err
}
}
// clear auth failed record
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册