Skip to content
XSS Disclosed report Intermediate

Reflected XSS with CSP bypass in Reticulum via improperly escaped "query" parameter in Elixir GraphiQL interface

The GraphiQL interface at /api/v2_alpha/graphiql reflected the 'query' parameter unescaped in inline JavaScript, allowing an attacker to break out and execute arbitrary JavaScript. This could let an attacker interfere with authentication and act as the victim.

Viridian Follow

Originally disclosed on Mozilla

  • Fixed in 23 hours
  • Paid in 8 days
  • Disclosed after 23 hours

Summary

Reticulum is the Elixir backend for Hubs. It ships with an alpha GraphQL API which exposes an instance of the GraphiQL web IDE on the /api/v2_alpha/graphiql route:

ELIXIR
scope "/api/v2_alpha", as: :api_v2_alpha do
  pipe_through(
    [:parsed_body, :api, :public_api_access, :graphql] ++ if(Mix.env() == :prod, do: [:ssl_only], else: [])
  )

  forward "/graphiql", Absinthe.Plug.GraphiQL, json_codec: Jason, schema: RetWeb.Schema
  forward "/", Absinthe.Plug, json_codec: Jason, schema: RetWeb.Schema
end

While exploring the Reticulum GraphiQL instance, I noticed that the value of the GET parameter query was returned unescaped in the main block of inline JavaScript. As CSP does not appear to be enforced under /api/v2_alpha/*, I was able to break out of the config variable and execute arbitrary JavaScript in the context of https://hubs.mozilla.com.

Based on the invocation of Absinthe.Plug.GraphiQL in the Reticulum Elixir code I suspect that this is ultimately the result of a bug in the "Absinthe.Plug" library, however I am not particularly familiar with Elixir and would appreciate a second opinion.

Specifically, it looks like the graphiql_workspace.html.eex template is used to render the page with the query_string variable:

ELIXIR
var config = new graphiqlWorkspace.AppConfig("graphiql", {
  defaultUrl: <%= default_url %>,
  <%= if socket_url do %>
    defaultWebsocketUrl: <%= socket_url %>,
    subscriptionsClientBuilder: absintheSubscriptionsClientBuilder,
  <% end %>
  defaultQuery: '<%= query_string %>', # injection point
  defaultVariables: '<%= variables_string %>',
  defaultHeaders: <%= default_headers %>

This template is loaded by the parent GraphiQL module which attempts escaping on the query parameter. It is possible to bypass this escaping with a backslash as shown in the PoC in "Steps to Reproduce".

ELIXIR
defp js_escape(string) do
  string
  |> String.replace(~r/\n/, "\\n")
  |> String.replace(~r/'/, "\\'")
end

Environment

  • Firefox 105.0.1 (64-bit), Firefox Developer Edition 106.0b6 (64-bit)

Steps to Reproduce

  1. Browse to https://hubs.mozilla.com/api/v2_alpha/graphiql?query=xxx\%27});confirm(document.domain);%20var%20x=new%20graphiqlWorkspace.AppConfig(%22x%22,{//.

  2. Observe the JavaScript alert dialog with the value of document.domain.

Impact

An attacker can execute arbitrary JavaScript in the context of another user on https://hubs.mozilla.com. This may allow the attacker to interfere with the authentication flow and subsequently perform actions as that user.

The original report as published on Mozilla's Bugzilla, by Viridian. Images and videos are our own copies; raw HTML is shown as text. View it on Mozilla's Bugzilla.

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 a bug in the Absinthe.Plug library's escaping function, which only escapes single quotes and newlines, allowing a backslash to bypass it.

Impact

An attacker can execute arbitrary JavaScript in the context of another user on https://hubs.mozilla.com, potentially interfering with authentication and performing actions as that user.

What the attacker needed

Victim clicks a crafted link

How it was found

  1. Browse to the crafted URL with the malicious query parameter.
  2. Observe the JavaScript alert dialog showing the document domain.

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.

The GraphiQL page put the user's search text directly into a script without proper cleaning. An attacker could craft a link that, when clicked, runs their own code in the victim's browser on the Hubs website. This is called cross-site scripting (XSS).

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 Viridian

View all

4 more disclosed reports, best first.

More from Mozilla

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.