3 - Cross Site Request Forgery (CSRF) (low/med/high) - Damn Vulnerable Web Application (DVWA)

3 - Cross Site Request Forgery (CSRF) (low/med/high) - Damn Vulnerable Web Application (DVWA)

Understanding Cross-Site Request Forgery (CSRF)

Introduction to CSRF

  • The video begins with an overview of the cross-site request forgery (CSRF) labs on DVWA, emphasizing a low security level for initial exploration.
  • CSRF is defined as a web security vulnerability that allows attackers to induce users into performing unintended actions, partially bypassing the same-origin policy.

Mechanism of CSRF Attacks

  • An example illustrates how an attacker can craft a URL that, when clicked by a victim who is logged into a site like Facebook, could change their email address to one controlled by the attacker.
  • Three conditions are necessary for a successful CSRF attack:
  • A relevant action must exist on the target website.
  • The website must rely solely on cookie-based session handling.
  • There should be no unpredictable request parameters.

Importance of CSRF Tokens

  • The discussion highlights the significance of random tokens in preventing CSRF attacks; if tokens are predictable or absent, vulnerabilities arise.
  • Previous challenges involved capturing and submitting new CSRF tokens using tools like Burp Suite during brute force attempts.

Overview of DVWA Labs

  • The speaker notes various complex labs available in DVWA related to CSRF and expresses intent to explore them further in future sessions.
  • A brief explanation reiterates that CSRF forces authenticated users to execute unwanted actions through social engineering tactics such as deceptive links.

Objective and Execution of Low-Level Challenge

  • The goal is outlined: make the current user unknowingly change their password via a crafted link. No protective measures against this attack are present at low difficulty levels.
  • By inspecting elements within the application, it becomes clear how functions trigger requests related to changing passwords.

Executing the Attack

Steps Taken During Attack Simulation

  • After logging in with valid credentials, requests made through Burp Suite reveal interactions with test credentials and password changes.
  • A GET request followed by POST requests demonstrates how user input is processed when attempting to change passwords.

Crafting Malicious Requests

  • By copying parameters from successful requests, an attacker can create URLs that will change victims' passwords without their knowledge when they click on them.

Testing Validity of Changes

  • After executing the crafted URL successfully changes a password, testing confirms access using new credentials established through manipulation.

Exploring Medium Difficulty Challenges

Adjustments for Increased Security Measures

  • Transitioning to medium difficulty introduces checks based on where requests originate; developers assume trust only if requests come from within the web application itself.

Understanding CSRF Vulnerabilities and Exploits

Exploring CSRF Attack Vectors

  • The discussion begins with an example of changing a password, highlighting the use of reflective XSS as a vulnerability to exploit.
  • A request to change the password is analyzed, revealing that a missing referrer header caused an error in the request validation process.
  • The importance of the referrer header is emphasized; its absence can sometimes bypass security checks, depending on how they are implemented.

Crafting an Exploit

  • The speaker creates an HTML form (exploit.html) designed to change passwords without user awareness by hiding fields and automatically submitting them.
  • This form is hosted on a server, replacing the original domain with one controlled by the attacker, demonstrating how attackers can manipulate URLs for exploitation.

Testing and Observations

  • Upon testing in Firefox, it’s noted that the request fails due to another missing referrer header. This highlights ongoing challenges in exploiting CSRF vulnerabilities effectively.
  • The speaker discusses using Burp Suite to analyze requests further and notes that without proper headers, attacks may not succeed.

Stored XSS Implementation

  • Transitioning to stored XSS, the speaker sets up a message for an admin containing a URL intended for exploitation.
  • An attempt is made to submit this message through a guestbook feature; however, issues arise when trying to include images or links directly.

Final Steps and Security Measures

  • After successfully submitting data via stored XSS, subsequent requests show that password changes were executed correctly despite initial errors due to missing headers.

Understanding CSRF and XSS Vulnerabilities

Exploring Token Management

  • The discussion begins with the need to change a URL to include a password and token for further operations.
  • The speaker mentions expanding the size of a set, indicating that they are working with data structures that require specific formatting, including backslashes for tokens.
  • A high-security level is noted as an obstacle since it prevents displaying certain information; switching to medium security is suggested for better visibility.

Analyzing User Tokens

  • The speaker attempts to retrieve the user token from the page using console commands but finds no token present initially.
  • Upon checking another page related to cross-site request forgery (CSRF), they successfully locate a user token, which changes upon each page refresh.
  • The importance of capturing this dynamic token is emphasized, as it could be sent off if retrieved correctly.

Challenges in Exploiting Vulnerabilities

  • The inability to inject scripts due to missing CSRF tokens is highlighted; setting difficulty levels affects exploitability.
  • Attempts to submit requests without proper tokens lead to errors, showcasing the necessity of correct authentication measures in web applications.

Crafting Phishing Scenarios

  • A hypothetical scenario is presented where an attacker tricks a victim into revealing their token through social engineering tactics involving fake links.
  • The speaker illustrates how an attacker might manipulate victims into changing passwords by sending them misleading URLs containing malicious scripts.

Addressing Security Measures

  • Discussion shifts towards the challenges posed by high-security settings requiring current passwords for changes; this complicates potential attacks significantly.
  • Even with access to user tokens, knowing the current password remains essential for executing successful exploits against users' accounts.
Video description

3 - Cross Site Request Forgery (CSRF) (low/med/high difficulties) video from the Damn Vulnerable Web Application (DVWA) walkthrough/tutorial series. DVWA is an intentionally vulnerable application for you to learn about ethical hacking. I made this series for students on the MSc in cybersecurity course at Queen's University Belfast but hopefully it can help others too! Hope you enjoy 🙂 ↢Damn Vulnerable Web Application (DVWA)↣ https://github.com/digininja/DVWA ↢CSRF↣ https://portswigger.net/web-security/csrf 👷‍♂️Resources🛠 https://cryptocat.me/resources ↢Chapters↣ Start - 0:00 Low - 3:43 Med - 6:40 High - 12:30 Impossible - 21:10