Skip to content
XSS Write-up Beginner

How I caught Multiple vulnerabilities in Udemy.com, But not rewarded for serious XSS vulnerability :(

The researcher found a DOM-based XSS, HTML injection, clickjacking, and broken authentication on Udemy's homepage. An attacker could execute JavaScript to steal cookies, inject HTML, frame the site, or brute-force coupon codes.

Satyendra Shrivastava Follow

Published on medium.com

{{media:0}}

Satyendra, on medium.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

Udemy is an online learning marketplace where visitors search for courses and browse course listings. The researcher, Satyendra Shrivastava, describes testing the homepage of udemy.com, specifically the course search bar, and reports a set of issues found there: DOM-based XSS, HTML injection, clickjacking and broken authentication. The write-up was published on 5 April 2018.

Satyendra
Satyendra From the original on medium.com

The account is informal and does not include HTTP requests, responses, parameter names or version numbers. What follows sticks to what the researcher actually describes.

Setup

No accounts, roles, tools or versions are described. The researcher was working from his college computer lab, browsing the web, and arrived at udemy.com while looking for hacking courses. He then decided to test the search bar for XSS. The only precondition stated is access to the public homepage and its search field.

From the original on medium.com

Finding it

The researcher searched udemy.com for a "bwapp training course". He then decided to test the search bar for XSS and entered a simple JavaScript payload. The first payload produced no response. He then tried a second payload that relies on an image load error rather than a script tag, and this one executed.

Exploitation

Step 1: script tag payload in the search bar

The first payload entered in the search bar was:

HTML
<script>alert(XSS)</script>

This is a classic reflected XSS probe: if the search term is written into the page as HTML without encoding, the browser parses the script element and runs alert(XSS). The researcher reports that there was no response, so this payload did not execute.

Step 2: image onerror payload

After some time he tried a second JavaScript payload:

HTML
<img src=1 onerror=alert(document.cookie)>
From the original on medium.com

This payload does not need a script element. The browser tries to load an image from the relative URL 1, the load fails, and the onerror handler runs alert(document.cookie). It is a common way to get execution when a script tag is filtered but event handler attributes are not.

The researcher reports that he got a popup with the cookie reflection.

From the original on medium.com

Step 3: HTML injection payload

Encouraged by the result, he continued testing and tried an HTML injection payload:

HTML
<h1><marquee>Udemy has beeen hacked</marquee></h1>
From the original on medium.com

This does not execute JavaScript; it only injects markup. The marquee element makes the text scroll across the page, which makes the injection visually obvious. The researcher reports that this worked as well.

From the original on medium.com

Step 4: clickjacking

He then reports finding clickjacking on udemy.com. The write-up gives no request, response, header or proof of concept for this issue, so the exact framing conditions are not described.

Step 5: broken authentication in the coupon code field

He also reports broken authentication that, in his description, allows an attacker to brute force the coupon code field. Again, no request, response, rate limit behaviour or payload is shown, so the mechanics are not documented in the write-up.

Root cause

The report does not analyse the code. The behaviour it describes is consistent with the search term being inserted into the page as HTML rather than being encoded or assigned as text, so markup in the query is parsed by the browser. The report does not explain why the script tag did not fire while the img onerror payload did. For the clickjacking and coupon code issues, the report gives no root cause at all.

Impact

The researcher's own demonstration is limited to alert popups: a cookie reflection through alert(document.cookie) and a visible HTML injection. In the researcher's framing, the XSS is the serious issue, and the broken authentication would let an attacker brute force the coupon code field. The report does not describe what an attacker could achieve beyond these demonstrations, nor which users or sessions would be affected.

Fix

The report ends with the status "Fixed".

Disclosure outcome

All the bugs were reported to Udemy. The XSS was assessed as out of scope for the program, and the broken authentication report was marked as a duplicate. The remaining issues, HTML injection and potential clickjacking, were triaged.

From the original on medium.com

Variants to test

  1. Search fields and query reflections: submit a benign marker and check whether it appears as text or as markup in the response and in the DOM. A positive result is the marker being parsed as an element rather than displayed literally.
  2. Filter bypass with event handlers: where a script tag is blocked, try attribute-based execution such as an image with an onerror handler. A positive result is the handler running.
  3. HTML injection without script: inject a harmless element such as a heading or marquee. A positive result is the element rendering on the page, which shows the input reaches the HTML sink even if script execution is blocked.
  4. Clickjacking: check whether the target page can be framed and whether framing protections are present. A positive result is the page rendering inside an attacker-controlled frame.
  5. Coupon or promo code fields: submit repeated guesses and observe whether responses differ and whether any throttling, lockout or CAPTCHA appears. A positive result is unlimited or weakly limited guessing with distinguishable responses.

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. 11 min read.

What happened, in plain words

Udemy is a website where people buy and watch online courses. It has a search box on its homepage where you type what you want to learn about, and it shows you matching courses. Satyendra Shrivastava, a security researcher, was browsing that site one day and decided to type some unusual things into that search box to see how the site would react. He found several problems: a cross-site scripting (XSS) bug, an HTML injection bug, a clickjacking issue and a broken authentication issue in a coupon code field. He reported them all to Udemy. Udemy decided the XSS was outside the scope of its bug bounty programme, and the broken authentication report was marked as a duplicate of something already known. The HTML injection and the potential clickjacking were accepted for triage, and the report ends with the status "Fixed".

This article walks through the same steps he describes, in the same order, and explains every term from scratch along the way.

Satyendra
Satyendra From the original on medium.com

Background: what the pieces are

Before the steps, a few ideas that come up again and again.

  • A web page and its HTML. When you open a website, your browser receives a document written in HTML. HTML is a set of instructions in angle brackets, called tags, that tell the browser what to display: a heading, a paragraph, an image, a button. The browser reads the tags and draws the page. If a tag says "run this program", the browser runs it.
  • JavaScript. This is the programming language that runs inside your browser. It can read what is on the page, change it, and read things the browser has stored for that site. A short JavaScript program is often called a payload in security writing, meaning the piece of input that is meant to make something happen.
  • A cookie. When you log in to a site, the site's server gives your browser a small piece of text called a cookie. Your browser sends it back with every later request so the site knows who you are. If someone else can read your cookie, they may be able to act as you. That is why researchers often demonstrate a cookie being read: it shows how serious the bug could be.
  • Cross-site scripting (XSS). This is when a site takes something a visitor typed and puts it into the page in a way that the browser treats as instructions rather than as plain text. If the visitor typed a harmless word, nothing happens. If they typed JavaScript, the browser runs it. The word cross-site refers to the fact that the code runs in the context of the victim's session on that site.
  • DOM-based XSS. The DOM is the browser's in-memory model of the page, the tree of elements it has built from the HTML. DOM-based XSS means the dangerous handling happens in the browser itself, in JavaScript running on the page, rather than on the server. The server may send a perfectly normal page, and the page's own script then takes something from the address or a form field and inserts it into the page unsafely.
  • HTML injection. This is the milder cousin of XSS. The site lets your input become real HTML tags, so you can add headings, images or scrolling text to the page, but you cannot run JavaScript. It is still a bug because it lets an attacker change what other visitors see, and it can sometimes be chained into something worse.
  • Clickjacking. This is a trick where an attacker puts the real site inside an invisible frame on their own page, and lines up a button or link so that when the victim thinks they are clicking something harmless, they are actually clicking the real site. The defence is for the site to tell browsers not to allow it to be framed.
  • Broken authentication. This is a broad label for weaknesses in how a site checks who you are or protects actions that should require a valid credential. A common example is a form that accepts unlimited guesses, so an attacker can try thousands of codes until one works.
  • Brute force. Trying many possibilities one after another, quickly, until one succeeds. If a form has no limit on attempts, a computer can try a huge number of guesses.
  • A coupon code. A short code you type at checkout to get a discount. If a site lets you guess coupon codes without limit, an attacker can find valid ones and use them, or find out which codes exist.
  • Bug bounty programme and scope. Many companies run programmes where outside researchers can report security bugs and sometimes get paid. The programme has rules, including a scope: a list of what is and is not eligible. If a bug is out of scope, the company may still fix it but will not pay a reward. A duplicate is a report of a bug that someone else already reported.
  • Triage. The first stage of handling a report, where the security team checks that the bug is real and decides how to handle it.

Setup

The researcher does not describe any special tools, accounts or software versions. He was in his college computer lab, with other students studying around him, and he was browsing the web. He was looking for courses about hacking, and that is how he ended up on udemy.com. The only thing he needed was the public homepage and its search box, which anyone can use without logging in.

From the original on medium.com

Finding it

He searched udemy.com for a "bwapp training course". That is a normal, harmless search. Then he had the idea of testing the search box for XSS: he wanted to see whether the site would treat what he typed as text or as instructions.

Step 1: a script tag in the search bar

The first thing he typed into the search box was:

HTML
<script>alert(XSS)</script>

Line by line:

  • <script> is the HTML tag that tells the browser "everything until the closing tag is JavaScript, run it".
  • alert(XSS) is a JavaScript instruction that opens a small popup box showing the text XSS. It is the classic harmless test: if the popup appears, you know your code ran.
  • </script> closes the script.

Why this step: if the search box puts your text into the page without escaping it, the browser will see a real script tag and run the popup. If the site escapes the text, the browser will show the literal characters <script>alert(XSS)</script> on the page as text, and nothing runs. The researcher reports that there was no response, so this payload did not execute.

Step 2: an image with an error handler

After some time he tried a second JavaScript payload:

HTML
<img src=1 onerror=alert(document.cookie)>
From the original on medium.com

Line by line:

  • <img starts an image tag.
  • src=1 tells the browser to load an image from the address 1. That is a relative address, so the browser looks for a file called 1 next to the current page. There is no such image, so the load will fail.
  • onerror=alert(document.cookie) is an event handler: an instruction that says "when the image fails to load, run this JavaScript". The JavaScript is alert(document.cookie), which opens a popup showing the value of document.cookie, the cookies the browser holds for that site.
  • > closes the tag.

Why this step: the first payload used a script tag, and it did not run. Many sites block the word script but forget that other tags can also run code through event handlers. An image that fails to load is a reliable way to trigger an event handler, because the failure is guaranteed. If the site lets your input become real HTML, the browser will try to load the image, fail, and run the handler.

The researcher reports that he got a popup with the cookie reflection, which he describes as a DOM-based XSS. The researcher describes this as a DOM-based XSS.

From the original on medium.com

Step 3: HTML injection

Encouraged by the result, he continued testing and tried an HTML injection payload:

HTML
<h1><marquee>Udemy has beeen hacked</marquee></h1>
From the original on medium.com

Line by line:

  • <h1> is a top-level heading tag. It makes text large and bold.
  • <marquee> is an old HTML tag that makes its contents scroll across the screen. Browsers still render it, which makes it a very visible way to prove that your markup reached the page.
  • Udemy has beeen hacked is the text that will scroll. Note the spelling in the original: three e's in "beeen".
  • </marquee> closes the scrolling element, and </h1> closes the heading.

Why this step: this payload does not run JavaScript at all. It only adds markup. If the page renders a scrolling heading, that proves your input is being treated as HTML, even if script execution is blocked. It is a useful separate finding because it shows the underlying problem (input becoming markup) without relying on JavaScript running.

The researcher reports that this worked as well.

From the original on medium.com

Step 4: clickjacking

He then reports finding clickjacking on udemy.com. The write-up gives no request, response, header or proof of concept for this issue, so the exact conditions under which the page could be framed are not described. In plain terms, clickjacking would mean an attacker could put the Udemy page inside a frame on their own site and trick a visitor into clicking something on it.

Step 5: broken authentication in the coupon code field

He also reports broken authentication that, in his description, allows an attacker to brute force the coupon code field. Again, no request, response, rate limit behaviour or payload is shown, so the mechanics are not documented. In plain terms, this would mean the coupon code form accepts repeated guesses without any limit, so an attacker could try many codes quickly.

Why it happened

The report does not analyse the site's code. The behaviour it describes is consistent with the search term being inserted into the page as HTML rather than being encoded or assigned as text, so markup in the query is parsed by the browser. The report does not explain why the script tag did not fire while the img onerror payload did. For the clickjacking and coupon code issues, the report gives no root cause at all.

What an attacker could do

The researcher's own demonstration is limited to alert popups: a cookie reflection through alert(document.cookie) and a visible HTML injection. In his framing, the XSS is the serious issue, and the broken authentication would let an attacker brute force the coupon code field.

The fix

The report ends with the status "Fixed".

What happened with the report

All the bugs were reported to Udemy. The XSS was assessed as out of scope for the programme, and the broken authentication report was marked as a duplicate. The remaining issues, HTML injection and potential clickjacking, were triaged.

From the original on medium.com

Things you can try yourself

These are the same kinds of checks, described so that someone with only a browser can follow along. Only test sites you own or that explicitly allow testing; testing a site without permission can be illegal.

  1. Search fields and reflections. Type a harmless marker such as zzz123 into a search box and look at the result. If the page shows zzz123 as plain text, the input is being displayed safely. If it shows up as part of the page's structure, for example inside a tag, that is worth noting. A positive result is the marker being parsed as an element rather than displayed literally.
  2. Event handlers when script tags are blocked. Where a script tag is blocked, try attribute-based execution such as an image with an onerror handler. A positive result is the handler running.
  3. HTML injection without script. Inject a harmless element such as a heading or marquee. A positive result is the element rendering on the page, which shows the input reaches the HTML sink even if script execution is blocked.
  4. Clickjacking. Check whether the target page can be framed and whether framing protections are present. A positive result is the page rendering inside an attacker-controlled frame.
  5. Coupon or promo code fields. Submit repeated guesses and observe whether responses differ and whether any throttling, lockout or CAPTCHA appears. A positive result is unlimited or weakly limited guessing with distinguishable responses.

Glossary

  • API: a way for one piece of software to talk to another, like a waiter taking your order to the kitchen and bringing back the food.
  • Broken authentication: a weakness in how a site checks who you are or protects actions that should require a valid credential, such as a form that accepts unlimited guesses.
  • Bug bounty programme: a scheme where a company invites outside researchers to report security bugs, sometimes for a reward.
  • Clickjacking: a trick where an attacker puts a real site inside an invisible frame on their own page so that a victim's clicks land on the real site without them realising.
  • Cookie: a small piece of text a site stores in your browser so it can recognise you on later requests.
  • Coupon code: a short code typed at checkout to get a discount.
  • Cross-site scripting (XSS): a bug where a site puts visitor input into a page in a way that the browser treats as instructions, so JavaScript runs.
  • DOM: the browser's in-memory model of the page, the tree of elements it has built from the HTML.
  • DOM-based XSS: XSS where the dangerous handling happens in the browser's own JavaScript rather than on the server.
  • Duplicate: a report of a bug that someone else has already reported.
  • Event handler: an instruction attached to an HTML element that runs when something happens to it, such as an image failing to load.
  • HTML: the language of tags in angle brackets that tells a browser what to display.
  • HTML injection: a bug where a site lets your input become real HTML tags, so you can add elements to the page, even if you cannot run JavaScript.
  • JavaScript: the programming language that runs inside your browser.
  • Payload: the piece of input that is meant to make something happen, such as a short JavaScript program.
  • Scope: the list of what is and is not eligible for a bug bounty programme.
  • XSS: see cross-site scripting.

More from Udemy

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.