Skip to content
SSRF Disclosed report Intermediate

Asset proxy bypass using two `#` in the URL

A URL containing two hash characters is parsed inconsistently: the addressable gem accepts it, but URI.parse fails, so GitLab renders the image link directly instead of rewriting it through the media proxy. An attacker could make a victim's browser load an image from an arbitrary external host, bypassing the proxy.

GitLab

Originally disclosed on GitLab

  • Fixed in under an hour
  • Disclosed after under an hour

Summary

URLs with two # are officially invalid according to the spec but still parsed by the addressable gem. This leads to an issue similar to https://gitlab.com/gitlab-org/gitlab/-/issues/419213 where URI.parse fails and doesn't rewrite the URL with the media proxy however the link is rendered anyway.

Steps to reproduce

MARKDOWN
{{media:0}}

and observe the source that doesn't go through user-content.gitlab-static.net but directly to example.com

Example Project

<!-- If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report. If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version. -->

What is the current bug behavior?

URL is used as-in

What is the expected correct behavior?

Media proxy URL should be used instead

Relevant logs and/or screenshots

<!-- Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's tough to read otherwise. -->

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

<!-- Input any relevant GitLab environment information if needed. --> <details> <summary>Expand for output related to GitLab environment info</summary> <pre> (For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`) </pre> </details>

Results of GitLab application Check

<!-- Input any relevant GitLab application check information if needed. --> <details> <summary>Expand for output related to the GitLab application check</summary> <pre>

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

</pre> </details>

Possible fixes

<!-- If you can, link to the line of code that might be responsible for the problem. -->
<!-- Do not edit past here unless you are certain of the impact -->

cc @gitlab-com/gl-security/appsec

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

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 media-proxy rewrite relies on URI.parse, which rejects the malformed URL, while the markdown renderer uses the more lenient addressable gem and still renders the link.

Impact

A viewer's browser could contact an external host directly instead of the media proxy.

What the attacker needed

Ability to post a comment or description; victim views the rendered content

How it was found

  1. Put a markdown image whose URL contains two hash characters into a comment or description.
  2. View the rendered page source and note the image URL.
  3. Observe that the URL points directly at the external host rather than the media proxy.

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.

GitLab normally rewrites images so they load through the media proxy. A link with two hash symbols is not rewritten, so the image loads directly from the external host.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More from GitLab

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.