Skip to content

Commit

Permalink
graph: Fix Status code when updating the password
Browse files Browse the repository at this point in the history
Up to now the /me/changePassword endpoint return a 500 Status when
issue a password change with the old password set to the wrong password.
This changes the code to return 400 (Bad Request) with an additional
message that the old password is wrong. This does not seem to weaken the
security of /me/changePassword (i.e. for allowing easier brute-force
attacks) as the endpoint is only available to already authenticated
users (and only for changing their own passwords)

See owncloud#4480
  • Loading branch information
rhafer committed Aug 31, 2022
1 parent f9cd1f5 commit 89c967f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion services/graph/pkg/service/v0/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ func (g Graph) ChangeOwnPassword(w http.ResponseWriter, r *http.Request) {
return
}

if authRes.Status.Code != cs3rpc.Code_CODE_OK {
switch authRes.Status.Code {
case cs3rpc.Code_CODE_OK:
break
case cs3rpc.Code_CODE_UNAUTHENTICATED:
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "wrong current password")
return
default:
errorcode.InvalidRequest.Render(w, r, http.StatusInternalServerError, "password change failed")
return
}
Expand Down

0 comments on commit 89c967f

Please sign in to comment.