Skip to content
XSS Write-up Intermediate

I Found XSS Security Flaws in Rails – Here's What Happened.

Rails' escape_javascript function did not escape backticks or dollar signs, allowing attackers to break out of template literals or use interpolation to execute JavaScript. This could lead to XSS when untrusted data is inserted into JavaScript strings.

Jesse Campos Follow

Published on chefsecure.com

Bounty$500 View original

def escapejavascript(javascript) # replace every unsafe character with safe version return javascript.gsub(/(\\|\r\n|[\n\r"'])/u, JSESCAPEMAP) end

Jesse Campos, on chefsecure.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. 6 min read.

Context

Ruby on Rails is a web framework used for building web applications with minimal setup and configuration. The write-up notes that although it is not as trendy as it once was, it is stable and reliable in most cases, and is still used by companies such as GitHub, Shopify, Airbnb and SoundCloud, as well as at Chef Secure.

The feature under examination is escape_javascript, the helper Rails developers use to escape untrusted data before placing it inside a JavaScript string. It is exposed to templates through the j alias and the full name:

Text
string = '<%= j untrusted_data %>'

or

Text
string = '<%= escape_javascript untrusted_data %>'

Used correctly, it stops untrusted data from running malicious code in XSS attacks. The article presents a simplified version of the implementation:

Text
JS_ESCAPE_MAP = {
  "'"    => "\\'",
  '"'    => '\\"',
  '\\'   => '\\\\',
  "\r\n" => '\n',
  "\n"   => '\n',
  "\r"   => '\n',
}

def escape_javascript(javascript)
  # replace every unsafe character with safe version
  return javascript.gsub(/(\\|\r\n|[\n\r"'])/u, JS_ESCAPE_MAP)
end
I Found XSS Security Flaws in Rails – Here's What Happened
I Found XSS Security Flaws in Rails – Here's What Happened From the original on chefsecure.com

This function replaces every unsafe character with a safe version. The researcher's point is that for the past five years, two things have been missing from it that could still allow attackers a way in.

Or watch on YouTube
From the original on chefsecure.com

Setup

The write-up does not describe a specific target application, account, role or tooling. The work is an analysis of the Rails helper itself, using small template snippets to show how developers call it. The only platform detail given is that the issue was submitted through HackerOne, and that HackerOne staff later helped contact the Rails team.

Finding it

The starting observation is about JavaScript string syntax. Strings can be created with single or double quotes, but when ES6 was introduced in 2015 it added a third way to create strings, template literals:

Text
'string1'
"string2"
`string3`

The difference is that template literals allow you to build strings while including variables and expressions inside. The escape map and the regular expression in escape_javascript handle \, \r\n, \n, \r, " and ', but not the backtick that delimits a template literal, and not the $ that begins an interpolation.

Exploitation

The article walks through the vulnerability with a concrete example. Suppose you want to show a user's online status using their name and a getStatus function that takes their id, so the end result looks like this:

Text
Jesse is Online

The old way adds the different pieces of the string together:

Text
'<%= j user.name %> is ' + getStatus(<%= user.id %>)

The new way with template literals combines these pieces inside a single string:

Text
`<%= j user.name %> is #{getStatus(<%= user.id %>)}`

The general technique for XSS in JavaScript, as described in the researcher's Attacks inside JavaScript recipe, is to break out of strings in order to get into the execution context, the place where your code gets run. Unlike HTML, where invalid syntax can pass without much consequence, JavaScript is very picky and stops working with even the smallest error, so the injection has to leave valid JavaScript behind. The pattern is:

  1. start with your payload (alert())
  2. surround it with matching string characters
  3. add a plus in between each part
Text
stringChar+alert()+stringChar

This breaks out of JS strings without errors, just like adding in a new variable.

Step 1: break out with a backtick

The escaping does not account for backticks being used to create strings via template literals. The same pattern therefore works with backticks as the string characters:

Text
`+alert()+`

The same pattern works with backticks as the string characters: The first fix adds the backtick to the escape map and to the regular expression:

Text
JS_ESCAPE_MAP = {
  "'"    => "\\'",
  '"'    => '\\"',
  '`'    => '\\`',
  ...

def escape_javascript(javascript)
  # replace every unsafe character with safe version
  return javascript.gsub(/(\\|\r\n|[\n\r"'`])/u, JS_ESCAPE_MAP)
end

Step 2: interpolate without breaking out

The second problem is that the same benefit template literals offer for combining expressions inside strings also lets attackers execute malicious code without breaking out of the string at all. The payload is simply surrounded by the ${} interpolation syntax, with no extra parts needed:

Text
${alert()}

The payload is simply surrounded by the ${} interpolation syntax, with no extra parts needed: The second fix escapes the $ character to stop this:

Text
JS_ESCAPE_MAP = {
  "'"    => "\\'",
  '"'    => '\\"',
  '`'    => '\\`',
  '$'    => '\\$',
  ...

def escape_javascript(javascript)
  # replace every unsafe character with safe version
  return javascript.gsub(/(\\|\r\n|[\n\r"'`$])/u, JS_ESCAPE_MAP)
end

Root cause

The mistake is in the escape map and the matching regular expression: they cover the quote characters that delimit ordinary JavaScript strings but not the two characters that give template literals their power, the backtick delimiter and the $ of ${} interpolation. Any data passed through escape_javascript and placed inside a template literal therefore remains able to terminate the string or to inject an expression. The escape map covers the quote characters that delimit ordinary JavaScript strings but not the backtick or the $ of ${} interpolation.

We were warned

The scenario had already been discussed eight years earlier. After the Rails patch was released, James Kettle, Director of Research at PortSwigger, sent the researcher a message on Twitter linking to a discussion on adding template literals to JavaScript, in which Gareth Heyes warns about the holes that would open up as a result. Gareth's warning, as quoted in the article:

Text
... this will introduce a new class of DOM based XSS attacks since developers in their infinite wisdom will use this feature to place user input inside ...

Impact

The write-up does not assign a severity or CVSS score. The impact follows from what the helper is for: wherever an application passes untrusted data through escape_javascript and interpolates it into a template literal, an attacker who controls that data can execute script in the context of the page, which is the usual consequence of XSS. The researcher also wonders, given that he appears to be the first to report this type of vulnerability and how long it remained unpatched, how often it has been exploited in the wild and what other frameworks and modules share the same problem. Those questions are left open.

Timeline

This issue took over a year to fix since it was originally reported to the Rails team.

Awkward Silence Rails Logo
Awkward Silence Rails Logo From the original on chefsecure.com

At least HackerOne has a badge for patience.

  1. January 3, 2019: submitted issue with solution to fix on HackerOne
  2. January 3, 2019: received response on addressing issue
  3. February 6, 2019: follow up for status and offered dev assistance
  4. May 21, 2019: follow up for status
  5. January 21, 2020: follow up for status and verified issue on most recent release
  6. February 5, 2020: received assistance from HackerOne staff to contact Rails team
  7. March 5, 2020: follow up for status
  8. March 6, 2020: HackerOne staff escalated issue internally
  9. March 12, 2020: patch created by Tenderlove and fix was verified
  10. March 19, 2020: official patch released
  11. March 24, 2020: request made to close issue
  12. April 8, 2020: follow up for status
  13. April 9, 2020: received assistance from HackerOne staff
  14. May 4, 2020: follow up for status
  15. May 5, 2020: issue closed and $500 bounty awarded

The researcher closes by saying that despite the long timeframe for getting this fixed, the hard work of the Rails team and HackerOne staff is still appreciated.

Fix

The two fixes shown above add the backtick and the $ character to JS_ESCAPE_MAP and to the regular expression used by escape_javascript. The patch was created by Tenderlove on March 12, 2020, the fix was verified, and the official patch was released on March 19, 2020.

Variants to test

Cross-Site Scripting icon
Cross-Site Scripting icon From the original on chefsecure.com

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

What happened, in plain words

A security researcher named Jesse Campos found a flaw in a piece of software called Ruby on Rails. Rails is a toolkit that programmers use to build websites. The flaw meant that a particular safety feature in Rails, one meant to stop attackers from slipping harmful code into a web page, did not cover every way a modern browser can read text. Jesse reported it to the Rails team through a bug bounty platform called HackerOne, where companies pay people for finding and reporting security problems. It took more than a year to fix, and he was paid 500 US dollars for the report.

I Found XSS Security Flaws in Rails – Here's What Happened
I Found XSS Security Flaws in Rails – Here's What Happened From the original on chefsecure.com

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

The code at the centre of it

Here is the piece of code the whole story is about. It is a simplified version of a function that lives inside Rails:

Text
JS_ESCAPE_MAP = {
  "'"    => "\\'",
  '"'    => '\\"',
  '\\'   => '\\\\',
  "\r\n" => '\n',
  "\n"   => '\n',
  "\r"   => '\n',
}

def escape_javascript(javascript)
  # replace every unsafe character with safe version
  return javascript.gsub(/(\\|\r\n|[\n\r"'])/u, JS_ESCAPE_MAP)
end

Let us go through it line by line, because everything that follows depends on understanding it.

  • JS_ESCAPE_MAP = { ... } creates a lookup table. Think of it as a small dictionary where each entry says: "if you see this character, swap it for that one instead." The name JS_ESCAPE_MAP is just a label the programmer chose; JS stands for JavaScript, the programming language that runs inside web browsers.
  • "'" => "\\'" is one entry in that dictionary. On the left is a single quote character. On the right is the same single quote with a backslash in front of it. In JavaScript, a backslash before a character tells the browser "treat this as an ordinary character, not as part of the code's structure." So this entry says: turn a single quote into a harmless single quote.
  • '"' => '\\"' does the same for the double quote character.
  • '\\' => '\\\\' handles the backslash itself, doubling it so that a backslash typed by a user cannot be mistaken for the start of an escape sequence.
  • "\r\n" => '\n', "\n" => '\n' and "\r" => '\n' deal with line breaks. \r and \n are invisible characters that mark the end of a line. These entries replace any kind of line break with a plain \n, so that a line break cannot be used to end a piece of code early.
  • def escape_javascript(javascript) starts the definition of a function, a reusable block of code. Its name is escape_javascript, and it takes one input, called javascript here, which is the text that needs to be made safe.
  • The line starting with # is a comment. The computer ignores it; it is a note for humans explaining that the function replaces every unsafe character with a safe version.
  • return javascript.gsub(/(\\|\r\n|[\n\r"'])/u, JS_ESCAPE_MAP) is the actual work. gsub means "globally substitute": go through the text and replace every match. The strange-looking part in slashes is a pattern that describes which characters to look for: a backslash, a carriage-return-plus-newline pair, or any one of newline, carriage return, double quote and single quote. The /u at the end tells the computer to treat the text as Unicode, the standard way of representing characters from every language. The second argument, JS_ESCAPE_MAP, is the dictionary from above, which says what each match should be replaced with.

So in one sentence: this function takes any text, finds the characters that could confuse a JavaScript interpreter, and replaces them with safe versions. The researcher's point is that for the past five years, two things have been missing from this list, and those two missing things could still let an attacker in.

Or watch on YouTube
From the original on chefsecure.com

What Rails is, and why anyone cares

Ruby on Rails is a web framework. A framework is a collection of ready-made building blocks that programmers assemble into a website, so they do not have to write every detail from scratch. Rails is known for letting people build web applications quickly with minimal setup and configuration, meaning you write less boilerplate before you have something that runs.

The article notes that Rails is not as trendy as it once was, but it is stable and reliable in most cases, and it is still used by a lot of companies, including GitHub, Shopify, Airbnb and SoundCloud, as well as at Chef Secure, the site that published this write-up. That list matters: a flaw in a widely used framework can affect a very large number of websites at once, even if each individual site's programmers did nothing obviously wrong.

The safety feature: escape_javascript

The code shown earlier is a function that developers use to escape untrusted data for safe use inside JavaScript strings. "Untrusted data" means anything that comes from outside your program and that you do not control: a name typed into a form, a comment, a message, a value stored in a database that a user supplied. "Escaping" means transforming that data so that, even if it contains characters that look like code, the browser will treat them as plain text.

A string, in programming, is simply a piece of text. JavaScript strings are usually written between quotes. If a user types a quote character into a form and the website drops that text straight into a JavaScript string without escaping, the quote can end the string early and whatever follows can be read as code. That is the essence of the attack class called Cross-Site Scripting, or XSS: getting your own code to run inside someone else's web page, in the browser of another user who visits it.

Rails exposes this helper to templates in two ways. A template is a file that mixes fixed text with placeholders that get filled in when the page is built. The <%= ... %> syntax marks a placeholder whose result is inserted into the page. Developers can call the helper by its short alias j:

Text
string = '<%= j untrusted_data %>'

or by its full name:

Text
string = '<%= escape_javascript untrusted_data %>'

Line by line: string = assigns the result to a variable called string. The single quotes around the outside are the JavaScript string the developer is building. Inside, <%= ... %> is the Rails placeholder. j untrusted_data means "run the j helper on the value called untrusted_data." The second snippet is identical except it spells out escape_javascript instead of j; they are the same function under two names.

Used correctly, this stops untrusted data from running malicious code in XSS attacks. The whole question of the article is whether "correctly" still means what it used to.

The new string syntax nobody updated for

JavaScript strings can be created with single or double quotes. That has been true since the language began. But when ES6 was introduced in 2015, it added a new way to create strings using what are called template literals. ES6 is short for ECMAScript 6, a version of the standard that defines the JavaScript language; browsers adopted its features over the following years.

Text
'string1'
"string2"
`string3`

Line by line: the first line is a string in single quotes. The second is a string in double quotes. The third is a string in backticks, the small slanted marks usually found at the top left of a keyboard, under the Escape key on many layouts. All three produce text. The difference is that template literals allow you to build strings while including variables and expressions inside. An expression is any piece of code that produces a value, such as a sum or a function call. In a template literal you can write ${...} and put an expression inside the braces; the browser works out the value and slots it into the text.

An everyday comparison: ordinary quoted strings are like a printed sentence where every word is fixed. A template literal is like a fill-in-the-blanks sentence, where the blanks are marked and get filled with whatever you put in them. That is convenient for programmers. It is also convenient for attackers, as we are about to see.

The escape map and the pattern in escape_javascript handle backslash, the line-break characters, double quote and single quote. They do not handle the backtick that marks the start and end of a template literal, and they do not handle the dollar sign that begins an interpolation. "Interpolation" is the act of inserting a value into a string; ${...} is JavaScript's interpolation syntax.

Walking through the vulnerability

Here is a concrete example. Suppose you want to show a user's online status using their name and a getStatus function that takes in their id, so the end result looks like this:

Text
Jesse is Online

getStatus is a function that takes in a user's id.

The old way would be to add the different pieces of the string together:

Text
'<%= j user.name %> is ' + getStatus(<%= user.id %>)

Line by line: the outer single quotes make an ordinary string. Inside it, <%= j user.name %> inserts the user's name after passing it through the escaping helper. Then the literal text is follows. The + joins that string to the result of getStatus(<%= user.id %>), where the user's id is inserted into the function call. The plus sign is JavaScript's way of gluing strings and values together.

The new way with template literals allows you to combine these pieces together inside a single string:

Text
`<%= j user.name %> is #{getStatus(<%= user.id %>)}`

Line by line: the whole thing is wrapped in backticks, so it is one template literal. The user's name is still passed through j. The text is follows. Then #{getStatus(<%= user.id %>)} is an interpolation: the browser evaluates the expression inside the braces and puts its result into the string. (In Ruby, the language Rails is written in, interpolation uses #{}; in JavaScript it uses ${}. )

So how do we exploit this? As the researcher explains in his Attacks inside JavaScript recipe in his XSS course, the most common way attackers achieve XSS in JavaScript is by breaking out of strings in order to get into the execution context, the place where your code gets run. Picture a string as a fenced enclosure: as long as your text stays inside the fence, it is just text. If you can type the character that ends the fence, everything after it is outside, in the open field where code is executed.

Now, in contrast to HTML, where you can have invalid syntax without much consequence, JavaScript is very picky and will stop working with even the smallest error. HTML is the language that describes the structure of a web page; browsers are forgiving with it and will render a page even if some tags are malformed. JavaScript is not forgiving: one stray character and the whole script fails, often silently. So you need to make sure you end up with valid JavaScript after your injection. If your payload breaks the script, nothing runs and the attack fails.

The pattern the researcher presents in the recipe is simple:

  1. start with your payload (alert())
  2. surround it with matching string characters
  3. and finally add a plus in between each part
Text
stringChar+alert()+stringChar

Line by line: stringChar stands for whatever quote character the surrounding code uses. alert() is a built-in browser function that pops up a small dialog box; security researchers use it as a harmless proof that code ran, because if you see the box, your code executed. The + signs join the pieces. The result reads, in effect: "end the string, add the result of alert(), start a new string." This allows you to break out of JS strings without errors, just like adding in a new variable. The browser sees a perfectly ordinary expression and runs it.

Do you see what is missing now? The escape map knows about ' and ", so it will neutralise the pattern if you use those characters. It does not know about backticks.

The first attack

The escaping does not account for backticks being used to create strings via template literals. In this case, this means we can run our exploit using the exact same pattern with backticks for the string characters:

Text
`+alert()+`

Line by line: the first backtick closes the template literal the developer opened. The + appends something to it. alert() is the payload: the browser runs it. The final backtick opens a new template literal, so that whatever the developer wrote after the injection point still has a string to sit in and the whole line remains valid JavaScript. Nothing here is exotic; it is the same three-part pattern as before, with a different character.

Why does this work? Because escape_javascript never saw a backtick as dangerous, so it passed it through untouched. The developer believed the data was safe because it had gone through the helper. The helper's list of dangerous characters was simply incomplete.

Okay, so let's add protection from backticks. The first fix adds the backtick to the escape map and to the pattern:

Text
JS_ESCAPE_MAP = {
  "'"    => "\\'",
  '"'    => '\\"',
  '`'    => '\\`',
  ...

def escape_javascript(javascript)
  # replace every unsafe character with safe version
  return javascript.gsub(/(\\|\r\n|[\n\r"'`])/u, JS_ESCAPE_MAP)
end

Line by line: the new entry '`' => '\\`' says "when you see a backtick, put a backslash in front of it," which turns it into an ordinary character inside a string rather than a string delimiter. The ... stands for the rest of the original dictionary, unchanged. In the pattern, the character class [\n\r"']now includes the backtick alongside newline, carriage return, double quote and single quote, sogsub` will find backticks and replace them. This closes the first hole.

There's still another problem

It turns out that the same benefit offered by template literals to combine expressions inside strings also allows attackers to execute malicious code without even having to break out of the string at all. This is the subtle part. The first attack needed to escape the fence. The second attack does not: it uses the fence's own built-in feature against it.

So to launch an attack this time, we'd just surround our payload with the ${} interpolation piece and we don't have to worry about any extra parts:

Text
${alert()}

Line by line: ${ begins an interpolation inside a template literal. alert() is the expression to evaluate. } closes the interpolation. If this text lands inside a template literal that the developer wrote, the browser does not treat it as text at all: it evaluates the expression and inserts the result. The attacker never leaves the string, so escaping the string delimiters does not help. The only defence is to stop the ${ from being recognised, which means escaping the dollar sign.

And now the second fix is to escape the $ character to stop this:

Text
JS_ESCAPE_MAP = {
  "'"    => "\\'",
  '"'    => '\\"',
  '`'    => '\\`',
  '$'    => '\\$',
  ...

def escape_javascript(javascript)
  # replace every unsafe character with safe version
  return javascript.gsub(/(\\|\r\n|[\n\r"'`$])/u, JS_ESCAPE_MAP)
end

Line by line: the new entry '$' => '\\$' puts a backslash before every dollar sign, so ${ becomes \${, which the browser reads as a literal dollar sign followed by a brace, not as the start of an interpolation. The pattern's character class now ends [\n\r"'$], adding the dollar sign to the set of characters gsub` searches for. With both fixes in place, neither the backtick payload nor the interpolation payload survives escaping.

Why the old defence failed

The mistake is in the escape map and the matching pattern: they cover the quote characters that delimit ordinary JavaScript strings but not the two characters that give template literals their power, the backtick delimiter and the $ of ${} interpolation. Any data passed through escape_javascript and placed inside a template literal therefore remains able to terminate the string or to inject an expression. The escape map covers the quote characters that delimit ordinary JavaScript strings but not the backtick or the $ of ${} interpolation.

An everyday comparison: it is like a building whose fire exits were all checked in 2010, and then a new wing was added in 2015 with doors nobody added to the inspection list. The old checklist is not wrong; it is just out of date.

We were warned

It turns out this scenario was already discussed 8 years ago. After the Rails patch was released, James Kettle, Director of Research at PortSwigger, sent the researcher a message on Twitter linking to a discussion on adding template literals to JavaScript, in which Gareth Heyes warns about the holes that will open up as a result. James Kettle is Director of Research at PortSwigger.

Gareth's warning, as quoted in the article:

Text
... this will introduce a new class of DOM based XSS attacks since developers in their infinite wisdom will use this feature to place user input inside ...

Line by line: the ellipses show that the quote is an excerpt. "A new class of DOM based XSS attacks" means a new family of XSS attacks that arise in the DOM, the Document Object Model, which is the browser's in-memory model of the page; DOM-based XSS happens when code running in the browser takes attacker-controlled data and puts it somewhere it gets executed, without the server ever being involved. The point is that the risk was foreseeable years before it was reported.

What else is vulnerable?

Considering that he appears to be the first to report this type of vulnerability and how long it remained unpatched, the researcher wonders how often it has been exploited in the wild and what other frameworks and modules share this same problem. "In the wild" means in real attacks against real sites, as opposed to in a test lab. A module is a self-contained piece of software that other programs can reuse. These questions are left open in the write-up; no answers are given.

Timeline

This issue has taken over a year to fix since originally reporting to the Rails team.

Awkward Silence Rails Logo
Awkward Silence Rails Logo From the original on chefsecure.com

At least HackerOne has a badge for patience, the researcher jokes. HackerOne is the bug bounty platform mentioned at the start: companies list their programs there, researchers submit reports, and the platform tracks the conversation. A badge is a small award the platform gives users for milestones; the joke is that waiting this long earned one.

  1. January 3, 2019: submitted issue with solution to fix on HackerOne. The researcher did not just report the problem; he included a proposed fix, which is good practice because it saves the maintainers work.
  2. January 3, 2019: received response on addressing issue. Same day, the team acknowledged it.
  3. February 6, 2019: follow up for status and offered dev assistance. A month later, he asked how it was going and offered to help write the code.
  4. May 21, 2019: follow up for status. Another check-in, months later.
  5. January 21, 2020: follow up for status and verified issue on most recent release. He checked that the bug was still present in the newest version, so the report could not be dismissed as already fixed.
  6. February 5, 2020: received assistance from HackerOne staff to contact Rails team. When a report stalls, platform staff can help put the researcher in touch with the right people.
  7. March 5, 2020: follow up for status.
  8. March 6, 2020: HackerOne staff escalated issue internally. "Escalated" means raised in priority and pushed to people with authority to act.
  9. March 12, 2020: patch created by Tenderlove and fix was verified. A patch is a small change to software that fixes a bug. Tenderlove is the handle of the Rails contributor who wrote it; the researcher then confirmed it worked.
  10. March 19, 2020: official patch released. The fix shipped to everyone using Rails.
  11. March 24, 2020: request made to close issue.
  12. April 8, 2020: follow up for status.
  13. April 9, 2020: received assistance from HackerOne staff.
  14. May 4, 2020: follow up for status.
  15. May 5, 2020: issue closed and $500 bounty awarded. A bounty is the payment a program gives for a valid report; here it was 500 US dollars.

The researcher closes by saying that despite the long timeframe for getting this fixed, the hard work of the Rails team and HackerOne staff is still appreciated.

The fix that shipped

The two fixes shown above add the backtick and the $ character to JS_ESCAPE_MAP and to the pattern used by escape_javascript. The patch was created by Tenderlove on March 12, 2020, the fix was verified, and the official patch was released on March 19, 2020.

What to check elsewhere

Learning more

The write-up ends by pointing to the researcher's XSS training material, including a recipe called Hacking Websites With Cross-Site Scripting and a broader course on the subject. If this article has whetted your appetite, those are the natural next step.

Cross-Site Scripting icon
Cross-Site Scripting icon From the original on chefsecure.com

Glossary

  • Backtick: the ` character, used in JavaScript to open and close a template literal.
  • Bounty: a payment made by a company or platform to someone who reports a valid security problem.
  • Bug bounty platform: a service, such as HackerOne, where companies list security programs and researchers submit reports.
  • Cross-Site Scripting (XSS): a class of vulnerability where an attacker gets their own code to run inside another person's web page, in the browser of a visitor.
  • DOM: the Document Object Model, the browser's in-memory representation of a page, which scripts can read and change.
  • DOM-based XSS: XSS that happens entirely in the browser, when client-side code takes attacker-controlled data and puts it somewhere it gets executed.
  • Escape / escaping: transforming characters that have special meaning in a language into harmless equivalents, so they are treated as plain text.
  • ES6: ECMAScript 6, a version of the JavaScript language standard introduced in 2015, which added template literals among other features.
  • Expression: any piece of code that produces a value, such as a function call or a sum.
  • Framework: a collection of ready-made building blocks that programmers use to build software faster.
  • Function: a reusable block of code that takes input and produces a result.
  • gsub: a Ruby method that replaces every occurrence of a pattern in a string.
  • HTML: the language that describes the structure of a web page.
  • Interpolation: inserting the value of an expression into a string; in JavaScript it uses ${...}.
  • JavaScript: the programming language that runs inside web browsers and makes pages interactive.
  • Module: a self-contained piece of software that other programs can reuse.
  • Patch: a small change to software that fixes a bug.
  • Payload: the piece of code an attacker wants to run, for example alert().
  • Regular expression: a pattern used to describe which characters or sequences to search for in text.
  • Ruby on Rails: a web framework written in the Ruby language, used to build web applications.
  • String: a piece of text in programming.
  • Template: a file that mixes fixed text with placeholders that are filled in when a page is built.
  • Template literal: a JavaScript string written between backticks, which can contain ${...} interpolations.
  • Unicode: the standard system for representing characters from every writing system.
  • Untrusted data: any data that comes from outside your program and that you do not control, such as form input.
  • Variable: a named container that holds a value in a program.

More from Ruby on Rails

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.