CSRF through URL with # tag parameter
A URL with a URI fragment (#createproject/...) triggered project creation without CSRF protection. An attacker could craft a link that, when clicked by a victim, created a project with attacker-chosen name and link.
Published on web.archive.org
Tommysuriel
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up describes a simple cross-site request forgery (CSRF) issue found in a bug bounty program. The researcher does not name the company, so the target is referred to throughout as redacted.com. The affected feature is the project creation functionality under redacted.com/projects: a user can create a project with a name and a link for the project.
The unusual part is where the action is triggered from. Instead of a form submission or a normal query string, the project creation was initiated by a URI fragment, the part of a URL after the #. The researcher notes that this kind of CSRF did not require Burp Suite or any other proxy tool to discover.
Setup
No accounts, roles, tool versions or special preconditions are described. The researcher found the issue by browsing the site normally and observing the URLs that appeared in the browser as links were clicked. The only tooling mentioned is the browser itself, plus a CSRF proof-of-concept generator used to produce the PoC page.
Finding it
The researcher was clicking through the website and watching the different URLs that populated in the browser. One of them looked like this:
Clicking that link created a project under redacted.com/projects, with the project name and a link for the project taken from the values after the slashes. The #createproject fragment called a function on the website, which then passed the remaining values along to create the project. No CSRF protection was present in that process.
The researcher points out that because the action is initiated by a URI fragment, a proxy tool such as Burp Suite would not have listed it: the URL would not have been crawled. That is why manual clicking and reading the address bar was the discovery method.
Exploitation
Step 1: Identify the fragment-driven action
The URL above is the whole attack surface. The fragment #createproject/sampleproject/webproject.com is interpreted by code on the page, which calls a function that passes the values after the slashes to create the project. The researcher states plainly that this process had no CSRF protection.
Step 2: Build a page that navigates the victim to the URL
The PoC used when reporting was generated with a CSRF generator and is reproduced here exactly as it appears in the write-up:
<html><head>
<title>CSRF PoC — Generated By AppSec Labs csrf-generator</title>
</head><body>
<form action=”[https://redacted.com/projects/#createproject/sampleproject/webproject.com](https://web.archive.org/web/20210227092343/https://redacted.com/projects/#createproject/sampleproject/webproject.com.)”>
<input type=’submit’ value=’Go!’ />
</form>
</body></html>
The form's action points at the vulnerable URL, and the only control is a submit button labelled Go!. When a victim loads this page and submits the form, the browser navigates to the fragment URL and the site's own code runs the create-project function. The researcher does not show the resulting response or any confirmation screen.
Step 3: Report
The researcher submitted this PoC and was paid $100 for the report.
Root cause
The create-project action is driven entirely by a URI fragment, and the code that handles the fragment performs the action without any CSRF protection. Because the fragment is processed by client-side code after the page loads, the request that results is not something a crawler or proxy history would surface, which is likely why it went unnoticed.
Impact
An attacker who can get a user to visit a crafted page, or otherwise navigate that user to the fragment URL, can trigger the create-project action with values of the attacker's choosing.
Fix
The natural fix, given the described behaviour, is to require a CSRF token or an equivalent same-origin check before the fragment handler performs the create-project action, and to avoid letting a fragment alone trigger a state-changing operation.
Variants to test
- Fragment-driven actions elsewhere: browse an application and note any URL whose
#portion looks like a command, such as#create...,#delete...or#invite.... A positive result is that loading the URL in a fresh tab performs the action without any additional confirmation. - Fragment handlers that accept multiple values: try changing the values after the slashes in a URL of the form
#action/value1/value2. A positive result is that the application creates or modifies an object using the values you supplied. - State-changing actions reachable by simple navigation: build a page with a form whose
actionis the candidate URL, as in the PoC above, and submit it while authenticated. A positive result is that the action completes with no token and no origin check. - Actions that proxy tools miss: compare what a crawler or proxy history records against what the address bar shows while clicking. A positive result is a state-changing URL that appears only in the browser and never in the tool's output.
What happened, in plain words
A security researcher was browsing a bug bounty program's website, clicking around like any normal visitor, and watching the address bar of the browser. One of the links he clicked did something surprising: it created a project on the site. The project's name and its link were taken straight from the address itself, and nothing else was needed. No password, no confirmation, no secret code.
That is the whole bug. If a website performs an action just because someone opened a particular address, then anyone who can trick a logged-in user into opening that address can make the action happen on that user's behalf. This class of bug is called cross-site request forgery, or CSRF.
The researcher reported it and was paid $100. The company is not named in the write-up, so the site is called redacted.com throughout.
Background you need first
A few everyday ideas make the rest of this easy to follow.
- A URL is the address you type or click to reach a page, for example
https://redacted.com/projects. The part after the#symbol is special: browsers call it the URI fragment. It is not sent to the server as part of the request. It is read by code running inside the page, in the browser, after the page has loaded. Think of it as a note written on the outside of an envelope: the postal service never reads it, but the person who opens the envelope can. - A CSRF attack works like this. You are logged in to a website, and your browser holds a cookie for it, a small piece of data the site gave your browser so it recognises you on the next visit. If another website can make your browser send a request to the first site, your browser attaches that cookie automatically, and the first site believes the request came from you. The attacker never sees your password; they just borrow your logged-in browser. The OWASP page linked in the write-up explains this in more depth.
- A proxy tool such as Burp Suite sits between your browser and the website and records every request and response. It is a common way to find bugs, but it only sees traffic that actually travels over the network. A fragment never travels over the network, so a proxy tool has nothing to record for it.
- A proof of concept (PoC) is a small, harmless demonstration that proves a bug is real, so the site owner can reproduce it.
Finding it
The researcher did not use Burp Suite or any other proxy tool. He simply clicked through the website and looked at the different URLs that appeared in the browser as he clicked. One of them looked like this:
Reading it piece by piece:
https://redacted.com/projectsis the projects page of the site.- Everything after the
#is the fragment:createproject/sampleproject/webproject.com. createprojectis the instruction. It tells code inside the page to run the function that creates a project.sampleprojectis the name given to the new project.webproject.comis the link stored with the project.
So the address is not just a location, it is a command with its arguments baked in. When the page loads, the site's own code reads the fragment, calls the create-project function, and passes along the values after the slashes. The researcher states that this process had no CSRF protection at all.
This is why clicking around by hand mattered. A proxy tool would not have listed this URL, because the action lives in the fragment and the fragment is never sent to the server. The only place it shows up is the address bar.
Proving it
Step 1: Confirm the fragment does the work
The URL above is the entire attack surface. Opening it creates a project using the values in the fragment. The report does not describe any further requirement.
Step 2: Build a page that sends the victim there
The PoC used when reporting was produced with a CSRF generator and is reproduced here exactly as it appears in the write-up:
<html><head>
<title>CSRF PoC — Generated By AppSec Labs csrf-generator</title>
</head><body>
<form action=”[https://redacted.com/projects/#createproject/sampleproject/webproject.com](https://web.archive.org/web/20210227092343/https://redacted.com/projects/#createproject/sampleproject/webproject.com.)”>
<input type=’submit’ value=’Go!’ />
</form>
</body></html>
Line by line:
<html><head>opens the page and its header section.<title>CSRF PoC — Generated By AppSec Labs csrf-generator</title>sets the text shown in the browser tab, naming the tool that generated the page.</head><body>closes the header and opens the visible part of the page.<form action=”...“>starts a form whoseactionis the address the browser will go to when the form is submitted. Here that address is the vulnerable fragment URL.<input type=’submit’ value=’Go!’ />is the only control on the page: a button labelledGo!.</form>closes the form, and</body></html>closes the page.
The idea is simple. The attacker hosts this page somewhere, or sends it to the victim. The victim opens it and presses Go!. The browser navigates to the fragment URL, the site's own code runs the create-project function, and a project is created. The write-up does not show the resulting page or any confirmation screen.
Step 3: Report it
The researcher submitted this PoC and was paid $100 for the report.
Why it works
The create-project action is driven entirely by the fragment, and the code that handles the fragment performs the action with no CSRF protection. Because the fragment is processed by code inside the page after it loads, the resulting request never appears in a crawler's output or a proxy history, which is likely why it went unnoticed.
What an attacker could do
Someone who can get a user to open a crafted page, or otherwise send that user to the fragment URL, can trigger the create-project action with a name and link of the attacker's choosing.
How to fix it
The natural fix, given the described behaviour, is to require a CSRF token, a secret value the page must present before the action is accepted, or an equivalent check that the request comes from the site's own pages, before the fragment handler creates anything. A fragment alone should never be enough to trigger an action that changes data.
Things to try on other sites
- Fragment-driven actions elsewhere. Browse an application and note any URL whose
#part looks like a command, such as#create...,#delete...or#invite.... A positive result is that opening the URL in a fresh tab performs the action with no further confirmation. - Fragment handlers that take several values. Try changing the values after the slashes in a URL of the form
#action/value1/value2. A positive result is that the application creates or changes an object using the values you supplied. - Actions reachable by simple navigation. Build a page with a form whose
actionis the candidate URL, as in the PoC above, and submit it while logged in. A positive result is that the action completes with no token and no origin check. - Actions that proxy tools miss. Compare what a crawler or proxy history records against what the address bar shows while you click. A positive result is a state-changing URL that appears only in the browser and never in the tool's output.
Glossary
- URL: the address of a page or resource on the web, such as
https://redacted.com/projects. - URI fragment: the part of a URL after the
#. It is read by code inside the page and is not sent to the server. - CSRF (cross-site request forgery): a bug where another site can make your logged-in browser perform an action on a site you are signed in to, without your intent.
- Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
- Proxy tool: software such as Burp Suite that sits between browser and server and records the traffic. It cannot see fragments, because they never leave the browser.
- Burp Suite: a common proxy tool used by security testers to inspect and modify web traffic.
- Crawler: software that follows links automatically to map a website. It does not execute fragment-driven actions.
- Proof of concept (PoC): a small demonstration that proves a bug is real and reproducible.
- CSRF token: a secret value a page must include with an action so the server can tell a genuine request from a forged one.
- Origin check: a server-side check that a request came from the site's own pages rather than from somewhere else.
- Bug bounty program: a scheme where organisations pay researchers for reporting security bugs responsibly.