Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the right http status of locked user due to brute force attack?

In case of brute force attack, what is the right status code that a REST api should return for a locked user? Actually, when a user fails password three times in last 3 minutes a lock its account.

If he try to login the fourth time, it receive a response with {"success":"false"} with status code 401. Is it formally right or not?

like image 514
sensorario Avatar asked Nov 02 '17 14:11

sensorario


People also ask

What response code was returned when the login was being brute forced?

While attempting to brute-force a login page, you should pay particular attention to any differences in: Status codes: During a brute-force attack, the returned HTTP status code is likely to be the same for the vast majority of guesses because most of them will be wrong.

What does it mean if a user account is locked?

The account lockout policy “locks” the user's account after a defined number of failed password attempts. The account lockout prevents the user from logging onto the network for a period of time even if the correct password is entered.

How many unsuccessful attempts does an user account get locked?

A locked account can't be used until you reset it or until the number of minutes specified by the Account lockout duration policy setting expires. You can set a value from 1 through 999 failed sign-in attempts, or you can specify that the account will never be locked by setting the value to 0.


2 Answers

I'm a teapot

If you determine that your application is under attack, you could return 418 (I'm a teapot) and use a "short and stout" message in the response payload.

Unauthorized and forbidden

For HTTP authentication (stateless and sending the credentials in the Authorization header) use 401 (Unauthorized) to indicate that the credentials have been refused for that request.

Assuming that the credentials are valid but the user account is locked (or in any other condition that prevents the server from accepting the request), you could use 403 (Forbidden) and a descriptive message in the payload. Quote from the RFC 7235:

A server that receives valid credentials that are not adequate to gain access ought to respond with the 403 (Forbidden) status code.

like image 83
cassiomolin Avatar answered Oct 06 '22 14:10

cassiomolin


403 Forbidden

403 means that "yes, I know about you, and your credentials might even be valid, but I am rejecting you anyway". Whether that be due to a lockout, your IP is banned, the phase of the moon isn't the correct one, etc, you can use this to signal that the request was invalid for that reason.

like image 38
Justine Krejcha Avatar answered Oct 06 '22 13:10

Justine Krejcha