Skip to content
UI spoofing Write-up Intermediate

Cool paste jacking attack earned me $$$

A subdomain endpoint exposed the current user's cookies, including email address and CSRF token, without X-Frame-Options protection. An attacker could frame the page and trick a victim into copying the exposed data and pasting it into an attacker-controlled form, stealing the cookies.

Aman Rawat Follow

Published on gyanihackers.com

Few months ago I found a cool bug you can also call it as paste jacking attack and I reported this bug and earned $$$, so lets start….

Aman Rawat (@theamanrawat), on gyanihackers.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 4 min read.

Context

This is a write-up about a paste jacking attack against a web application, app.example.com, and one of its subdomains, xxx.app.example.com. The researcher describes paste jacking as an exploitation of click jacking in which, rather than forcing the victim to click a button, the attacker convinces them to copy text and paste it into a desired text box.

From the original on gyanihackers.com

A directory on the subdomain returned the cookies of the currently logged-in user, including the email address, a CSRF token and some other secret tokens. The report does not describe what the application itself does beyond this.

Setup

The researcher performed basic reconnaissance: enumerating subdomains and looking for open ports and services. After enumeration, only app.example.com was in scope, so the work continued against subdomains of that host. The report does not name any tools or versions.

Finding it

While enumerating subdomains of app.example.com, the researcher found xxx.app.example.com. Opening that subdomain in the browser redirected to app.example.com.

From the original on gyanihackers.com

Next, the researcher scanned for valid directories and ended up with a valid /test directory. Navigating to it returned the string test a thousand times, which was not useful. Changing the directory name from /test to /test1 returned the cookies of the current logged-in user, including the email address, a CSRF token and some other secret tokens.

The open question was how to steal this from other users. The researcher first looked for CORS misconfiguration at that endpoint, but the endpoint was not vulnerable to CORS. The endpoint also had no protection for X-Frame, which the researcher took to mean it was vulnerable to click jacking, and the paste jacking proof of concept followed.

Exploitation

Step 1: Confirm the data leak

Requesting the changed directory name on the subdomain returns the current user's cookies:

Text
xxx.app.example.com/test1

The response contains the logged-in user's cookies, including the email address, CSRF token and other secret tokens.

Step 2: Rule out CORS

The researcher looked for CORS at that endpoint so the data could be read cross-origin, but the endpoint was not vulnerable to CORS.

Step 3: Build the paste jacking proof of concept

The endpoint had no X-Frame protection. The proof of concept convinces the victim to copy their cookies from xxx.app.example.com/test1 and paste them into a text box, which then sends the cookies to the attacker's server.

From the original on gyanihackers.com

The report does not include the HTML of the proof of concept or the server-side code that receives the cookies.

Step 4: Report and fix

The researcher reported the bug, received a bounty, and the company fixed it.

Step 5: Attempt a bypass

To bypass the fix, the researcher read the JavaScript files of app.example.com and found another endpoint:

Text
xxx.app.example.com/socket

Opening this endpoint again returned the cookies. The researcher reported it. A week later the company replied that it was a duplicate of the previous bug and that they were not fixing the issue.

Root cause

Two weaknesses combine. First, a directory on the subdomain returns the current user's cookies, including the email address, CSRF token and other secret tokens. Second, the endpoint has no X-Frame protection, which the researcher took to mean it was vulnerable to click jacking. CORS was checked and was not the vector; the leak was reachable through framing and social engineering instead.

Impact

An attacker who can convince a logged-in victim to copy text from the framed xxx.app.example.com/test1 page and paste it into a text box can receive that victim's cookies, including the email address, CSRF token and other secret tokens, on the attacker's server. The attack depends on the victim following the copy-and-paste instruction; it is not automatic. The same applies to the /socket endpoint found later.

Fix

The /socket endpoint that returned the same data was reported afterwards and marked as a duplicate, and the company said it was not fixing it. A fix should stop the endpoints from returning cookies and secret tokens in the response, and add X-Frame-Options or a CSP frame-ancestors directive so the pages cannot be framed.

Variants to test

  1. Enumerate subdomains of an in-scope host and open each one; a redirect to the main application can hide a host that still serves content. A positive result is a subdomain that responds with data instead of redirecting.
  2. Fuzz directory names around a known path, such as changing /test to /test1. A positive result is a response containing session cookies, email addresses, CSRF tokens or other secrets.
  3. Check whether endpoints that return sensitive data send X-Frame-Options or a CSP frame-ancestors directive. A positive result is a response with neither header, meaning the page can be framed.
  4. Read the application's JavaScript files for additional endpoints that return the same data. A positive result is a second endpoint, such as /socket, that leaks the same cookies.
  5. Where CORS is present, test whether the endpoint reflects arbitrary origins; here it did not, which is why framing was used instead.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

What happened, in plain words

A security researcher found a website that would hand back the cookies and tokens your browser uses to prove who you are, and then found a clever way to trick a logged-in person into handing those secrets over. The trick is called paste jacking. The researcher reported it, was paid a bounty, and the company fixed it. Later the researcher found a second place with the same leak, reported that too, and was told it was a duplicate of the first report and would not be fixed.

This article walks through the whole story from the beginning, assuming you have never done any security work. You only need to know how to use a browser. Every technical word is explained the first time it appears, and there is a glossary at the end.

The idea behind paste jacking

From the original on gyanihackers.com

Paste jacking is described in the report as an exploitation of click jacking. So let us start with click jacking.

Click jacking is a con where a bad page puts an invisible or disguised copy of a real website on top of its own content. You think you are clicking a harmless button on the bad page, but your click actually lands on the real site underneath, doing something you did not intend, such as pressing a "delete" or "pay" button.

Paste jacking flips the same idea around. Instead of tricking you into clicking, the attacker tricks you into copying something and pasting it somewhere. The report puts it this way: rather than forcing the victim to click on a button, the attacker convinces them to copy text and paste it into a desired text box.

An everyday comparison: imagine someone hands you a sealed envelope and asks you to copy the address on it into a form. Unknown to you, the envelope actually contains your house keys, and the form is a courier slip addressed to the thief. You did the copying yourself, so nothing looked suspicious.

Why does this matter? Because your browser will not let one website read the contents of another website's page. That protection is a core part of how the web stays safe. But if a person copies text with their own hands and pastes it, the browser sees a normal human action and allows it. The attacker borrows the victim's own hands to move the data.

The target and the first look around

The researcher found a website and did basic reconnaissance. Reconnaissance (recon) means gathering information about a target before attacking: what addresses exist, what services are running, what is reachable. The report mentions enumerating subdomains and looking for open ports and services.

  • A subdomain is a name that sits in front of a main domain. If the main site is example.com, then shop.example.com and mail.example.com are subdomains. Companies often run many of them, and they are easy to forget about.
  • Enumerating subdomains means making a list of all of them you can find, usually by trying lots of common names and seeing which ones answer.
  • An open port is a numbered doorway on a server that accepts connections. A service is the program listening behind that doorway, such as a web server.

After enumerating, the researcher found that only app.example.com was in scope. In scope means the company has given permission to test that particular address, and only that one. Testing outside the scope would be unauthorised, so the researcher stayed within it.

Because only app.example.com was in scope, the researcher started looking for subdomains of app.example.com itself. That led to xxx.app.example.com.

The redirect that looked wrong

When the researcher opened xxx.app.example.com in the browser, it redirected to app.example.com.

A redirect is the server telling your browser "not here, go to this other address instead". You have seen this when an old link sends you to a new homepage. The researcher's reaction, as written in the report, was surprise: the subdomain existed but seemed to bounce you straight back to the main site.

From the original on gyanihackers.com

This is an important lesson for anyone starting out. A redirect on the front page does not mean the subdomain is empty. It only means the front page sends you elsewhere. Other paths on the same subdomain can still respond with real content, and that is exactly what happened next.

Finding the directory that leaked cookies

Next the researcher scanned for valid directories. A directory is a folder-like part of a web address. In example.com/shop/toys, the parts /shop and /toys are directories. Scanning means trying many common names and noting which ones return something other than "not found".

The scan turned up a valid /test directory. The researcher navigated to it hoping for something interesting. Instead, the page returned the word test a thousand times. That is a placeholder, the kind of thing a developer leaves behind while testing, and it is useless to an attacker.

So the researcher changed the directory name from /test to /test1. This time the response contained the cookies of the currently logged-in user, including the email address, a CSRF token and some other secret tokens.

This is worth unpacking, because cookies and tokens are the heart of the whole story.

  • A cookie is a small piece of text that a website asks your browser to store and to send back with every request to that site. It is how a website remembers that you are logged in. Think of it as the wristband you get at an event: you show it at the door and you are let in without showing your ticket again.
  • A session cookie specifically identifies your current login session. Anyone who copies it can often act as you, without knowing your password.
  • A token is a similar small string of characters used as proof of identity or permission. The report mentions a CSRF token. CSRF stands for Cross-Site Request Forgery, an attack where a bad site makes your browser send a request to a good site while you are logged in. A CSRF token is a secret value the good site puts in its forms so it can tell a genuine form submission from a forged one. If an attacker learns the CSRF token, that protection is weakened.
  • The response also included the user's email address, which is personal data, and "some other secret tokens", which the report does not name.

The key point: a page that simply prints your cookies back to you is a serious leak. It is like a cloakroom that hands your coat to anyone who asks for it by number, without checking who you are.

The problem: how do you get other people's cookies?

Finding the leak on your own account is only half the job. The researcher now faced the obvious question: how can I steal this from other users?

You cannot simply ask a victim to visit xxx.app.example.com/test1 and send you the result. They would not do it, and even if they did, the browser would not let your page read the response from a different site. That protection is called the same-origin policy: a page from one origin (roughly, one scheme plus host plus port) cannot read data from another origin. It is the wall that stops any random website from reading your bank page while you are logged in.

So the researcher considered two ways around the wall.

First attempt: CORS

When people talk about stealing information from a user across sites, the first thing to check is often CORS. CORS stands for Cross-Origin Resource Sharing. It is a set of rules a server can send to say "these other websites are allowed to read my responses". If a server is misconfigured and says "any website at all may read my responses", then a malicious page can fetch the data and read it directly.

The researcher looked for CORS problems at that endpoint, but there was no luck: the endpoint was not vulnerable to CORS. In other words, the wall was intact, and the data could not simply be fetched and read by another site.

Second attempt: framing

Then the researcher noticed something else. The endpoint had no protection for X-Frame.

X-Frame-Options is a response header, a small instruction a server attaches to its reply. It tells the browser whether the page may be shown inside a frame. A frame (specifically an iframe) is a window inside a web page that displays another web page. Websites use frames for maps, videos and adverts. Attackers use them to display a victim site inside their own page.

If a page sends no X-Frame-Options header and no equivalent modern rule, the browser is generally willing to display it inside someone else's page. That is the condition for click jacking, and the researcher concluded the endpoint was vulnerable to click jacking.

This is the turning point. The attacker cannot read the framed page, but they can show it. And if they can show it, they can put their own instructions around it.

Building the trick

The researcher created a proof of concept. A proof of concept (PoC) is a small demonstration that shows a bug is real, without causing harm.

The idea: convince the victim to copy their cookies from xxx.app.example.com/test1 and paste them into a text box, and then send those cookies to the attacker's server. The report's own summary of the result is that we can successfully steal cookies from other users.

From the original on gyanihackers.com

Here is how the pieces fit together, in plain terms:

  1. The attacker builds a page that contains a frame showing xxx.app.example.com/test1, relying on the missing framing protection.
  2. The attacker writes text around the frame telling the visitor to copy something from it, for example "copy the code below to verify your account".
  3. The visitor, already logged in, copies the cookies shown in the frame.
  4. The visitor pastes the text into a box on the attacker's page and submits it.
  5. The attacker's server receives the cookies.

The report does not include the HTML of the proof of concept or the server-side code that receives the cookies. What it does make clear is that the attack is not automatic: it depends on the victim following the copy-and-paste instruction. That is why it is social engineering as much as a technical flaw. Social engineering means manipulating a person into doing something, rather than breaking the technology directly.

Reporting and the fix

The researcher reported the bug to the company, received a bounty, and the company fixed it. A bounty is a payment a company makes to someone who reports a security problem responsibly. The report does not say what the fix changed.

Trying to get around the fix

Fixes are not always complete, so the researcher decided to try to bypass it. The method was to read the JavaScript files of app.example.com.

JavaScript is the programming language that runs in your browser and makes pages interactive. Websites ship their JavaScript as files, and those files often mention addresses the site talks to. Reading them is a standard way to discover endpoints that are not linked anywhere visible.

An endpoint is a specific address on a server that does something when you request it, such as returning data or accepting a form. Think of the website as a building and endpoints as the individual service windows inside it.

Reading the JavaScript turned up another endpoint:

Text
xxx.app.example.com/socket

Opening this endpoint again returned the cookies. The researcher reported it, expecting a second bounty.

A week later the company replied. They marked it as a duplicate of the previous bug and said they were not fixing the issue. A duplicate means the company considers it the same underlying problem as an earlier report, so it does not count as a new finding.

Why this worked

Two weaknesses had to combine.

  1. A directory on the subdomain returned the current user's cookies, including the email address, a CSRF token and other secret tokens. That is the leak.
  2. The endpoint had no X-Frame protection, which the researcher took to mean it was vulnerable to click jacking. That is the delivery method.

CORS was checked and was not the vector. The leak was reachable through framing and social engineering instead.

What an attacker could do with it

An attacker who convinces a logged-in victim to copy text from the framed xxx.app.example.com/test1 page and paste it into a text box receives that victim's cookies, including the email address, a CSRF token and other secret tokens, on the attacker's server. With a session cookie, an attacker can often act as the victim without knowing the password. The same applies to the /socket endpoint found later.

How it should be fixed

The /socket endpoint that returned the same data was reported afterwards and marked as a duplicate, and the company said it was not fixing it.

A proper fix has two parts. First, stop the endpoints from returning cookies and secret tokens in the response at all. Second, add X-Frame-Options or a CSP frame-ancestors directive so the pages cannot be framed. CSP stands for Content Security Policy, a set of rules a site sends to the browser; the frame-ancestors directive says which sites, if any, are allowed to frame it.

Things to try yourself

These are the same checks the researcher performed, written as steps you can follow on a site you are authorised to test.

  1. Enumerate subdomains of an in-scope host and open each one. A redirect to the main application can hide a host that still serves content. A positive result is a subdomain that responds with data instead of redirecting.
  2. Fuzz directory names around a known path, such as changing /test to /test1. Fuzzing means trying many variations automatically. A positive result is a response containing session cookies, email addresses, CSRF tokens or other secrets.
  3. Check whether endpoints that return sensitive data send X-Frame-Options or a CSP frame-ancestors directive. A positive result is a response with neither header, meaning the page can be framed.
  4. Read the application's JavaScript files for additional endpoints that return the same data. A positive result is a second endpoint, such as /socket, that leaks the same cookies.
  5. Where CORS is present, test whether the endpoint reflects arbitrary origins. Here it did not, which is why framing was used instead.

Glossary

  • Bounty: a payment a company makes to someone who reports a security problem responsibly.
  • Click jacking: tricking a user into clicking something on a hidden or disguised page underneath the one they think they are using.
  • Cookie: a small piece of text a website asks your browser to store and send back with each request, commonly used to remember that you are logged in.
  • CORS (Cross-Origin Resource Sharing): rules a server sends to say which other websites are allowed to read its responses.
  • CSRF token: a secret value placed in forms so a site can tell a genuine submission from a forged one.
  • CSP (Content Security Policy): a set of rules a site sends to the browser; its frame-ancestors directive controls which sites may frame it.
  • Directory: a folder-like part of a web address, such as /test in example.com/test.
  • Duplicate: a report the company treats as the same underlying problem as an earlier one.
  • Endpoint: a specific address on a server that performs an action when requested.
  • Enumerating: systematically listing things, such as all subdomains that exist.
  • Frame (iframe): a window inside a web page that displays another web page.
  • Fuzzing: automatically trying many variations of a value to find one that behaves differently.
  • In scope: the addresses a company has given permission to test.
  • JavaScript: the programming language that runs in the browser and makes pages interactive.
  • Open port: a numbered doorway on a server that accepts connections.
  • Paste jacking: tricking a user into copying text and pasting it somewhere, so the attacker receives data the browser would not otherwise allow across sites.
  • Proof of concept (PoC): a small demonstration showing that a bug is real.
  • Reconnaissance (recon): gathering information about a target before testing it.
  • Redirect: a server telling the browser to go to a different address instead.
  • Same-origin policy: the browser rule that stops one website from reading data from another.
  • Service: a program listening behind a port, such as a web server.
  • Session cookie: a cookie that identifies your current login session.
  • Social engineering: manipulating a person into doing something, rather than breaking technology directly.
  • Subdomain: a name in front of a main domain, such as shop.example.com.
  • Token: a small string of characters used as proof of identity or permission.
  • X-Frame-Options: a response header telling the browser whether a page may be shown inside a frame.

Similar reports

View all

Same bug class and techniques, clearest first.

Clickjacking and UI spoofing

The lesson behind this report.

The interface lies to the user: a framed page catches their clicks, or a browser shows the wrong address or a fake prompt. Paid when it leads to a sensitive action or convincing phishing.