How CSRF bypass has helped me earn

3 min readJun 3, 2023

Objective: Understanding Cross-Site Request Forgery (CSRF) and Its Implementation.

Introduction: In today’s interconnected web landscape, security threats are a persistent concern for businesses and individuals. Cross-Site Request Forgery (CSRF) is one such vulnerability that poses a significant risk to web applications. In this article, we will explore what CSRF is, how it works, and the measures that can be implemented to mitigate this threat.

What is CSRF?

As per standard definition, Cross-Site Request Forgery (CSRF) is a type of web vulnerability that allows an attacker to perform unauthorized actions on behalf of a victim user on a trusted website. It occurs when a malicious actor tricks a victim into unknowingly executing unwanted actions, such as changing their password, making a purchase, or deleting valuable data.

How does CSRF work?

CSRF attacks exploit the trust that websites place in a user’s browser. The process typically involves the following steps:

  1. The victim logs into a trusted website (such as an online banking platform) and receives a session cookie, which is stored in their browser.
  2. Meanwhile, the attacker crafts a malicious website or email that contains a hidden request, usually in the form of an HTML form or an AJAX request. This request is designed to perform a harmful action on the trusted website.
  3. The victim visits the attacker’s website or clicks on a malicious link in an email while still logged into the trusted website.
  4. The attacker’s website or script automatically sends the hidden request to the trusted website, using the victim’s stored session cookie. Since the request appears to come from the victim’s browser, the trusted website processes it as a legitimate action.
  5. The harmful action is executed on the trusted website without the victim’s knowledge or consent.

More or less this pic taken from the internet will explain one possible scenario of an attack

Implementing CSRF Protection:

To mitigate the risk of CSRF attacks, web developers can implement several security measures:

  1. Random Token Pattern (RTP): The most widely-used technique, RTP involves generating a unique, random token for each user session. This token is then included as a hidden field in forms or added as a header in AJAX requests. When a request is received, the server verifies that the token matches the user’s session, preventing unauthorized requests.
  2. SameSite Cookies: By setting the SameSite attribute to “Strict” or “Lax” in cookies, developers can restrict how they are sent in cross-origin requests. This helps prevent CSRF attacks by ensuring that cookies are not sent when the request originates from a different website.(modern browser supports this kind of thing but that doesn’t mean a developer can overlook the necessity of secure code)
  3. Double Submit Cookies: In this method, the server generates two tokens — a session-specific cookie and a form-specific cookie. The form-specific token is sent as a cookie and also included as a hidden field in the form. When the request is submitted, the server compares the two tokens to verify their consistency.
  4. Captcha and reCAPTCHA: Including a challenge-response test, such as a Captcha or reCAPTCHA, can further protect against CSRF attacks. These mechanisms require users to solve a puzzle or enter specific characters, thus proving that they are human and not an automated script.


Cross-Site Request Forgery (CSRF) remains a significant security concern in web applications. By understanding how CSRF attacks work and implementing appropriate countermeasures, developers can safeguard their users’ data and prevent unauthorized actions. Employing techniques such as the Random Token Pattern (RTP), SameSite Cookies, Double Submit Cookies, and Captcha/reCAPTCHA can significantly reduce the risk of CSRF attacks, providing a safer browsing experience for users and maintaining the integrity of web applications.

Demo Time

How can you leave the topic without a demo,lets roll it now

See and enjoy!! USe the techniques showcased in the video whenever you require that would be the real outcome of learning.