Warning: I’m not an expert on security or this kind of attack.
Cookies and Session do not resolve
Cookies and Session nay are suitable places to place this type of security.
Cookies are the customer’s responsibility (usually the browser), therefore easily manipulated.
The User Session, despite staying on the server, is just a data structure associated with an identifier, which usually stays in a Cookie or else in the URL through the URL Rewriting.
In the above two cases, requests to perform a brute force attack simply need to simulate a new user at each request, as if someone had just opened the browser, causing the server to automatically generate a new session.
Security is not only of the application
Attacks involving massive network use like this or Dos (Denial of Service) are usually best handled by Firewalls or Proxies that filter excess requests.
Leaving this in charge of the application will bring a complexity to it and will make the team spend time implementing something that is not part of the scope of the system. This distraction almost always comes at the cost of a system with less quality.
And the IP?
A simple but naive technique would be to limit the number of requests using the IP address.
This works in a simple attack, from only one source. However, more sophisticated distributed attacks will control multiple sources and it ends up being very difficult to differentiate between a "normal" and an automated request.
How to detect attacks?
Speaking of differentiate, that’s the whole question. How to detect the request pattern artificial generated by request attacks genuine originated by users?
The answer to this question makes it possible to effectively avoid brute force attacks.
I will not try to answer that here, as it will be the subject of debate by security experts.
I can even think of small techniques to make it difficult for a hacker to act, but ultimately, it will always be possible for him to identify these techniques and adjust the attack.
Maybe use a captcha or equivalent "human testing" is one of the most effective ways today, but often hinders usability and there are also guarantees that an automated algorithm that solves these challenges cannot be implemented.
Considerations
The purpose of this response is to inform web application developers not to try to reinvent security using "naive" techniques. At the same time, I want to say that security must be a concern, but requires further study, appropriate tools and expert consultation.
good question +1
– Jorge B.
if I’m going to try brute force, nothing prevents me from adding a command to the script to clear the session at each attempt...
– RodrigoBorth
The idea is good and websites like Internet Banking systems do it; however, you cannot do sessions for non-authenticated users. You can, however, store in a table the number of attempts to access each distinct IP in the last five minutes. More than five unsuccessful attempts = block.
– Oralista de Sistemas
@Rodrigoborth the session can be server-side. If something like this is on the client’s side, then the site deserves to be hacked anyway.
– Oralista de Sistemas
One more thing: I don’t believe Fappening happened due to a blunt-force attack. It looks more like something you get with social engineering or stolen bank + rainbow table.
– Oralista de Sistemas
@Renan server side session control uses what to save records? is not an ID that gets stored in the browser?
– RodrigoBorth
@Rodrigoborth uses RAM, just... At the time the user scrolls down, or if a certain amount of time becomes inactive, the entire session is deleted. Examples of this type of session treatment are the class Httpsessionstate of the . NET and the interface Httpsession java.
– Oralista de Sistemas
@Renan no cara, when you create a SESSION on the server, it by default add a cookie (client-side) to manage whose SESSION is, there is SESSION cookieless that is managed by SQL, but anyway.
– PauloHDSousa
@Paulohdsousa well remembered. My fault.
– Oralista de Sistemas
That’s what I was referring to, I can freely delete the cookie when I feel like it from my browser... that is, there are few alternatives left, cookieless is a good, depending on how will be treated identification on the server
– RodrigoBorth
Incrementing the login screen lock time if you exceed the number of attempts can be interesting as well. Something like 2 n... Where n is the number of attempts. This makes the attack unfeasible.
– gmsantos
Man, I believe the safest way is to block by IP and put a captcha on the page... The only way the guy can request with different Ips is to change it with each request or change the machine, which for attacks to sites not so big is kind of unimaginable.
– HiHello