CSRF Attack: All You Need To Know


Presently, the focus has moved to other attacks that have corrupted the databases of many businesses. Nevertheless, this is not the only sort of crime that hackers conduct.

This article will explore usually overlooked attack, cross-site request forgery (CSRF), How Are CSRF attacks accomplished, examples of CSRF attacks and effective ways to prevent cross-site request forgery vulnerabilities.

  1. What is CSRF attack?
  2. How CSRF works?
  3. Example of a CSRF attack using a GET request
  4. CSRF attack using a POST request
  5. Preventing CSRF vulnerabilities
  6. How does CSRF token work?

1. What is CSRF attack?

CSRF attack is a kind of attack in which deceives the user to do the malicious task on a user authenticated network on behalf of hackers interests.

2. How CSRF works?

CSRF only works if the latent user is verified. Hacker can avoid the verification process to enter a network. When a user with additional benefits executes actions that are not available to all after this, CSRF attacks happen.

There are two sections to execute a Cross-Site Request Forgery (CSRF) attack:

1) In the first section hacker trick the user into clicking a malicious link or loading up a harmful page. By adopting a social engineering technique, a hacker will attract the user to click the link.

2) In the second section hacker send a framed or made-up request to the user’s browser. This link will send a genuine-looking request to the web application. The request transmitted is according to the conditions that the attacker wants, this request covers any cookies that the user has connected with that website

When a request is sent to a network application, the browser verifies if it has any Cookies. If the proper cookies are available, it is sent along with the request. It is needed to remember users communications with the web site as HTTP. So, they do not have to again verify for each page that they visit. If, the cookies sent to the website approve and considered that the session is valid. Hacker can use CSRF to send requests.

Now the cookies sent to web application assumes that the user can execute these actions on the website as it has a higher level of permission. It will term as these requests are original. But the truth is the user was working according to the will of the attackers.

Attackers relish the fact that the browser sends the cookies to the network application automatically with every request.

3. Example of a CSRF attack using a GET request

When the user clicked the malicious, the hacker leads the user to the malicious web application that does the job of sending illegal request. The request considered to be Illegal because the user is not aware of the request sent. As it contains all the Cookie, the web-server make sure to validate a user is the one who is performing all the tasks.

 In this example, a valid URL, which will request the web application transfers 200,000 INR to User’s account.

The request will hold the Cookie for the validated user, so there would be no requirement to define which account will be used to generate funds. That means that if a non-registered user accesses this URL, they would be asked to validate that means web application already knows from which account the funds will be extracted. We know the technique used to trick a user into sending the request that the hacker needs for validating as the user.

If the web application is awaiting a GET request, then the attacker can include a tag on their website, rather than linking to an image, it will send a request to the bank’s web application.

The browser in a normal situation will directly send the Cookies linked with the particular web application. That means allowing the user to work on behalf of the hacker, means a transfer of funds.

4. CSRF attack using a POST request

let us analyze this with an example:

Suppose a user login to a website using personal credential authentication.

The server validates the user. In return, the authentication cookie as a response is sent back.

Now the user left the site without logging out and visits a harmful website. This site has HTML forms which support unsafe websites.

As the user clicks on the submit button. The browser combines the authentication cookie with the request.

Now the request runs on the server with the complete user’s authentication setting and can do any work which a validated user is permitted.   

5. Preventing CSRF vulnerabilities

Implement the use of tokens dispensed to a single individual and contain a hidden value in every dynamic form.

6. How does CSRF token work?

The user requests an HTML page that has a form.

The server contains two tokens in the response. One is sent as a cookie, and the other is cached in a secured form field. The tokens are randomly distributed. So, that attackers cannot figure out the token number.

When the user submits the form, should send back both the numbers to the server. 

If the user does not have both the token number server will not allow the user to proceed further.


CSRF attacks have detected on an extensive number of sites. Any site where data is simply modified and can be used to perform malicious activities is a latent aim. So, it has become vital for the users to be aware of these attacks, and if any mishappening occurs instantly take action.

So, have you made up your mind to make a career in Cyber Security? Visit our Master Certificate in Cyber Security (Red Team) for further help. It is the first program in offensive technologies in India and allows learners to practice in a real-time simulated ecosystem, that will give you an edge in this competitive world.

Also Read


Related Articles

Please wait while your application is being created.
Request Callback