Site icon Astra Security Blog

Cross-Site Request Forgery (CSRF) Attacks: All You Need To Know

CSRF-All You Need to Know -Astra Security

Cross-Site Request Forgery (CSRF) is one of the most rampantly occurring online attack. Also notoriously known as XSRF or “Sea-Surf”, it is listed as the 8th most common web application vulnerability in the OWASP Top 10 report of 2017 cyber-attacks.

Understanding CSRF in PHP

Execution of a CSRF attack involves a malicious website sending a request to a web application via another formerly authenticated website. This allows the attacker to dodge authentication procedures by impersonating the victim using his/her credentials and perform malicious activity or financial transactions. Hot targets for such attacks are online banking services, social media applications and web interfaces for network devices.

General Workflow of a CSRF attack

To exemplify, a CSRF attack can occur if a victim logs in to their banking website and during an active session, receives an e-mail to click on a link. On clicking the link, a script would execute on the banking website, using the victim’s bank credentials to transfer funds from their account into the attacker’s account. In this case, the attacker posed as the victim by exploiting the victim’s login information, computer and IP address for illegally transferring funds.

Alternatively, instead of emailing a victim while validated into a site, an attacker may inject a code into the site and just when the user clicks on the link, the code would automatically perform the malicious transaction.

There is no way for the victim to claim that someone else performed the malicious transaction since their login credentials and IP information were previously used for legitimate transactions by the victim in the past

Misconceptions about CSRF

Following are some common techniques employed by the developers to boost security of the application but unfortunately none of them proves to be effective against the CSRF.

  1. SSL Certificate: Just like various other web application vulnerabilities, HTTPS does not offer any significant protection from the CSRF, This is because the vulnerability persists as a result of flaws in application logic.
  2. POST requests: This is not an effective method for preventing CSRF attacks. An attacker can generate a similar POST request like the main application and change data that is being is saved at the server side.

This is a simple CSRF exploit for the POST requests

 By tailoring this exploit according to specific application attackers can easily compromise the application.

How to defend against CSRF attacks in PHP

It is not difficult to fix this vulnerability.  Below are given methods which helps preventing applications from possible attacks:

Apart from these, a regular audit of your website is critical to ensure detection of any vulnerability. With Astra’s Business Plan, you can get monthly security scans to ensure that your website is well prepared against any hack scenarios.

Exit mobile version