Skip to content
SSRF Write-up Advanced

Shopify SSRF: From Store Screenshot to Root Access

A screenshot service for online stores could be made to follow a redirect to Google Cloud's metadata service, exposing cloud and Kubernetes credentials. Those credentials allowed listing and creating pods and running commands as root in containers in one infrastructure subset.

Muhammad Asim Shahzad Follow

Published on masimshahzad.medium.com

Bug Bounty

Muhammad Asim Shahzad, on masimshahzad.medium.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. 4 min read.

Context

Shopify Exchange was a marketplace for buying and selling online stores. To make listings attractive, the platform ran a headless browser that took a screenshot of each store and attached it to the listing. That screenshot service is the subject of this case: a server-side browser that fetches a URL chosen by a user is, by construction, a server-side request forgery (SSRF) primitive.

AI-generated illustration From the original on masimshahzad.medium.com

The report is HackerOne #341876, "SSRF in Exchange leads to ROOT access in all instances", submitted on 22 April 2018 by 0xacb, with credit also given to Luís Maia and 0xfad0. It was disclosed on 23 May 2018. Shopify classified it as a Shopify Core RCE and paid $25,000. The HackerOne severity field was Medium, while the researcher rated the impact critical. There is no CVE because Exchange was a hosted service.

Setup

The precondition was simply the ability to own a store on Shopify Exchange. The researcher controlled the page that the screenshot renderer would load, which meant he controlled the HTML and JavaScript the headless browser would execute. No special tooling or version information is given in the report.

Finding it

The feature takes a URL, loads it in a headless browser and captures an image. The browser ran on Shopify infrastructure inside Google Cloud, so anything the page made it request was a request from inside that network. A page he controlled could direct the browser at addresses only reachable from the server side. In his words, the screenshot became a camera pointed at internal data.

Exploitation

Step 1: control the page that gets rendered

The researcher owned a store, so he controlled the content of the page the screenshot service would visit. The important property is that the navigation to the internal target was triggered by the page after it loaded, not by the URL submitted to the service.

Step 2: reach the cloud metadata service

Every Google Cloud instance can reach the internal metadata service. The page sent the browser there. Google normally requires a special header on metadata calls precisely to block this kind of abuse, but, according to the report, an older API version of the metadata service still answered without that header.

Step 3: harvest credentials from metadata

The metadata response exposed a cloud access token. Because GKE metadata concealment was not enabled on the affected infrastructure, the metadata also exposed Kubernetes node credentials.

Step 4: move into Kubernetes

With the node credentials, the researcher could list and create pods. From a pod he could read a service-account token, and with that token he ran commands as root in containers within that infrastructure subset.

Step 5: containment and reward

Shopify pulled the service within an hour of the report. The affected subset did not include Shopify core, but some of its applications had access to core data and systems, which is why the finding was paid as a core RCE. Shopify then audited every subset.

Root cause

The design flaw is that a server-side browser was allowed to make arbitrary outbound requests on behalf of untrusted page content. Validating the submitted store URL would not have helped, because the request to the metadata service came from a navigation the page triggered after loading. The second failure was in the cloud configuration: the metadata service answered an older API version without the header that normally blocks this, and GKE metadata concealment was not enabled, so node credentials were exposed alongside the access token.

Impact

An attacker who can control a rendered page could obtain a cloud access token and, in this environment, Kubernetes node credentials. Those allowed listing and creating pods, reading a service-account token and executing commands as root in containers in the affected subset. Root in production containers exposes secrets and running services. Shopify stated that the affected subset did not include Shopify core, but some applications in it had access to core data and systems, which is why the bounty was paid at core RCE level.

Fix

Shopify's fix, as summarised in the report, was a metadata concealment proxy and removal of access to internal IPs on all subsets. The report's own recommendations for renderers of this kind are:

  1. Validate every request, not just the first URL, because the attack used a navigation triggered after page load.
  2. Block metadata and internal addresses at the network layer.
  3. Minimise what metadata exposes, in particular keeping node credentials out of instance attributes.

The report includes this illustrative allow-list and request hook, reproduced as published:

Python
BLOCKED = [ip_network(n) for n in (    "[redacted]/8", "[redacted]/8", "[redacted]/12", "[redacted]/16",    "[redacted]/16",                          "::1/128", "fc00::/7", "fe80::/10", "::ffff:0:0/96")]def allow_request(url):    u = parse_url(url)    if u.scheme not in ("http", "https"):        return False    addrs = resolve_all(u.host)                if not addrs or any(ip_address(a) in net for a in addrs for net in BLOCKED):        return False    pin_dns(u.host, addrs)                     return Truedef render_screenshot(store_url):    page = headless.new_page()    page.on_request(lambda r: r.continue_() if allow_request(r.url) else r.abort())    page.goto(store_url, timeout_s=15)         return page.screenshot()

Variants to test

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

What happened, in plain words

Shopify Exchange was a website where people bought and sold online shops. To make each listing look good, Shopify ran a small program that opened every shop in a hidden browser and took a picture of it, then put that picture on the listing. That hidden browser is the star of this story.

A security researcher named 0xacb (with credit also given to Luís Maia and 0xfad0) worked out that he could make that hidden browser visit places it was never meant to visit. Because the browser runs on Shopify's own computers, inside Google's cloud, anything it fetched came from inside Shopify's network. He used it to reach the cloud metadata service, and from there he ended up with root in containers in one infrastructure subset.

He reported it on 22 April 2018 as HackerOne report #341876, titled "SSRF in Exchange leads to ROOT access in all instances". Shopify shut the screenshot service down within an hour and paid $25,000. The report was made public on 23 May 2018.

A few words before we start, because they come up constantly:

  • Server: a computer somewhere in a data centre that answers requests from your browser. When you load a web page, your browser asks a server for it.
  • Browser: the program on your computer (Chrome, Firefox) that shows web pages. A headless browser is the same kind of program with no window: it runs on a server, loads pages and can take screenshots, but no human watches it.
  • SSRF (Server-Side Request Forgery): tricking a server into making a request on your behalf, to a place you could not reach yourself. A simple comparison: a company receptionist will phone anyone you ask them to. If you ask them to phone the locked filing room and read out what is inside, you have just used the receptionist to get past a door you cannot open. The receptionist is the server; the phone call is the request.
  • Metadata service: a small private web service that every cloud machine can talk to, which tells the machine about itself and hands it temporary keys. It is only reachable from inside the cloud, never from the open internet. Think of it as a staff noticeboard in a locked corridor: only people already inside the building can read it, and it happens to list the keys to the building.
  • Token / credential: a long random string that proves who you are, like a wristband at an event. Show the wristband and you get in; you do not need to give a password every time.
  • Root: the all-powerful account on a Linux machine. Root can read, change or delete anything, including other people's data and passwords.
AI-generated illustration From the original on masimshahzad.medium.com

AI-generated illustration

Context

Shopify Exchange was a marketplace for buying and selling online stores. To make listings attractive, the platform ran a headless browser that took a screenshot of each store and attached it to the listing. That screenshot service is the subject of this case: a server-side browser that fetches a URL chosen by a user is, by construction, a server-side request forgery (SSRF) primitive.

Why "by construction"? Because the whole point of the feature is: someone gives us a web address, and our server visits it. The server is doing what a stranger tells it to do. Normally that is fine, as long as the stranger can only point it at ordinary public websites. The danger is that the stranger can point it at private addresses that only the server can reach.

The report is HackerOne #341876, "SSRF in Exchange leads to ROOT access in all instances", submitted on 22 April 2018 by 0xacb, with credit also given to Luís Maia and 0xfad0. It was disclosed on 23 May 2018. Shopify classified it as a Shopify Core RCE and paid $25,000. The HackerOne severity field was Medium, while the researcher rated the impact critical. There is no CVE because Exchange was a hosted service.

Two more terms there:

  • RCE (Remote Code Execution): getting a server to run commands of your choosing. "Core RCE" here means Shopify treated the finding as if it gave code execution on its central systems, which is the most serious category it has.
  • CVE: a public catalogue number for a flaw in software that many people install. A hosted service like Exchange is not a product you download, so there is nothing to catalogue and no CVE was assigned.

Setup

The precondition was simply the ability to own a store on Shopify Exchange. The researcher controlled the page that the screenshot renderer would load, which meant he controlled the HTML and JavaScript the headless browser would execute. No special tooling or version information is given in the report.

This is the key idea, so it is worth spelling out. HTML is the language web pages are written in; JavaScript is the language that lets a page do things after it has loaded, such as fetch more data or send the browser somewhere else. If you own a shop on the marketplace, you can put your own HTML and JavaScript on your shop's page. When Shopify's hidden browser opens your shop to photograph it, it runs your JavaScript. So you, an outsider, get to give instructions to a program running inside Shopify's network. That is the whole setup.

Finding it

The feature takes a URL, loads it in a headless browser and captures an image. The browser ran on Shopify infrastructure inside Google Cloud, so anything the page made it request was a request from inside that network. A page he controlled could direct the browser at addresses only reachable from the server side. In his words, the screenshot became a camera pointed at internal data.

That camera comparison is the clearest way to see the bug. The screenshot feature is supposed to photograph your shop front. If you can turn the camera around and point it at the inside of the building, the photo it hands back to you shows things you were never allowed to see.

Exploitation

Step 1: control the page that gets rendered

The researcher owned a store, so he controlled the content of the page the screenshot service would visit. The important property is that the navigation to the internal target was triggered by the page after it loaded, not by the URL submitted to the service.

Why does that detail matter? Imagine a bouncer who checks the address you write on the form at the door, then lets you in. If your page, once inside, quietly walks out a side door to a different address, the check at the front door was pointless. Any defence that only inspects the URL you submitted would have missed this attack entirely.

Step 2: reach the cloud metadata service

Every Google Cloud instance can reach the internal metadata service. The page sent the browser there. Google normally requires a special header on metadata calls precisely to block this kind of abuse, but, according to the report, an older API version of the metadata service still answered without that header.

A header is a small line of extra information sent along with a web request, like the label on a parcel. Google's protection was: only answer metadata requests that carry a particular label, which ordinary web pages cannot add. An API version is a numbered edition of a service's interface; older editions sometimes lack newer protections. Here the older edition still answered without the label, so the page got through.

Step 3: harvest credentials from metadata

The metadata response exposed a cloud access token. Because GKE metadata concealment was not enabled on the affected infrastructure, the metadata also exposed Kubernetes node credentials.

Unpacking that:

  • GKE (Google Kubernetes Engine): Google's managed version of Kubernetes, a system for running lots of containers across many machines.
  • Container: a lightweight, sealed-off running copy of an application. Think of many labelled boxes on one big shelf; each box holds one app.
  • Node: one of the machines in that cluster, the shelf itself rather than a box on it.
  • Metadata concealment: a GKE setting that hides the node's own credentials from the metadata service, so a container asking the noticeboard does not get the keys to the whole shelf. It was off, so the keys were on the noticeboard.

So the metadata service handed over two things: a cloud access token, and the credentials of the machine itself.

Step 4: move into Kubernetes

With the node credentials, the researcher could list and create pods. From a pod he could read a service-account token, and with that token he ran commands as root in containers within that infrastructure subset.

A pod is the smallest unit Kubernetes runs: one or more containers wrapped together. A service account is an identity that a program (rather than a person) uses to talk to the cluster, and its token is the wristband that proves that identity. The chain is: machine keys let him start his own pod, his pod could read a service account's wristband, and that wristband let him run commands as root inside containers. Each step is a small permission that unlocks the next, like a set of nested keys.

Step 5: containment and reward

Shopify pulled the service within an hour of the report. The affected subset did not include Shopify core, but some of its applications had access to core data and systems, which is why the finding was paid as a core RCE. Shopify then audited every subset.

"Subset" here means one portion of Shopify's cloud infrastructure, not the whole company. Even so, applications in that portion could reach central data and systems, so Shopify paid at the top level and then checked every other portion for the same weakness.

Root cause

The design flaw is that a server-side browser was allowed to make arbitrary outbound requests on behalf of untrusted page content. Validating the submitted store URL would not have helped, because the request to the metadata service came from a navigation the page triggered after loading. The second failure was in the cloud configuration: the metadata service answered an older API version without the header that normally blocks this, and GKE metadata concealment was not enabled, so node credentials were exposed alongside the access token.

In plain terms there were two locks, and both were open. The first lock was on the browser: it should not have been free to visit private addresses. The second lock was on the cloud: the metadata service should have refused requests without the label, and the node keys should not have been on the noticeboard. Egress filtering means controlling what traffic is allowed to leave a network, like a doorman who checks where you are going, not just who you are.

Impact

An attacker who can control a rendered page could obtain a cloud access token and, in this environment, Kubernetes node credentials. Those allowed listing and creating pods, reading a service-account token and executing commands as root in containers in the affected subset. Root in production containers exposes secrets and running services. Shopify stated that the affected subset did not include Shopify core, but some applications in it had access to core data and systems, which is why the bounty was paid at core RCE level.

"Production" means the systems real customers use, as opposed to test systems. Root there means an attacker could read stored passwords and keys and interfere with live services. That is why a screenshot feature ended up being paid as if it were full code execution on central systems.

Fix

Shopify's fix, as summarised in the report, was a metadata concealment proxy and removal of access to internal IPs on all subsets. The report's own recommendations for renderers of this kind are:

  1. Validate every request, not just the first URL, because the attack used a navigation triggered after page load.
  2. Block metadata and internal addresses at the network layer.
  3. Minimise what metadata exposes, in particular keeping node credentials out of instance attributes.

A proxy is a middleman that all traffic must pass through, so it can inspect and refuse requests. An IP address is the numeric address of a machine on a network; internal IP addresses are the ones only reachable from inside. Instance attributes are the pieces of information the metadata service publishes about a machine; keeping credentials out of them means a curious container finds nothing useful there.

The report includes this illustrative allow-list and request hook, reproduced as published:

Python
BLOCKED = [ip_network(n) for n in (    "[redacted]/8", "[redacted]/8", "[redacted]/12", "[redacted]/16",    "[redacted]/16",                          "::1/128", "fc00::/7", "fe80::/10", "::ffff:0:0/96")]def allow_request(url):    u = parse_url(url)    if u.scheme not in ("http", "https"):        return False    addrs = resolve_all(u.host)                if not addrs or any(ip_address(a) in net for a in addrs for net in BLOCKED):        return False    pin_dns(u.host, addrs)                     return Truedef render_screenshot(store_url):    page = headless.new_page()    page.on_request(lambda r: r.continue_() if allow_request(r.url) else r.abort())    page.goto(store_url, timeout_s=15)         return page.screenshot()

Line by line, in plain words:

  • BLOCKED = [...] builds a list of address ranges that must never be contacted. These are the private and internal ranges: [redacted]/8 is the machine talking to itself, [redacted]/8, [redacted]/12 and [redacted]/16 are private office and data-centre networks, [redacted]/16 is the link-local range that cloud metadata services live in, and the :: entries are the IPv6 equivalents. The /8, /16 style numbers say how big each range is.
  • def allow_request(url): starts a function, a named block of code, that decides yes or no for one web address.
  • u = parse_url(url) splits the address into its parts, such as the scheme (http or https) and the host name.
  • if u.scheme not in ("http", "https"): return False refuses anything that is not a normal web address, so other kinds of links cannot be used.
  • addrs = resolve_all(u.host) looks up the host name and gets every IP address it points to. "All" matters: a name can point to several addresses.
  • if not addrs or any(...): return False refuses the request if the lookup found nothing, or if any of the addresses falls inside any blocked range.
  • pin_dns(u.host, addrs) fixes the name to the addresses just checked, so the name cannot quietly change to a different address between the check and the actual visit. That trick is called DNS rebinding and is covered below.
  • return True means the address passed every check.
  • def render_screenshot(store_url): is the screenshot feature itself.
  • page = headless.new_page() opens a fresh hidden browser tab.
  • page.on_request(lambda r: r.continue_() if allow_request(r.url) else r.abort()) is the important line: it hooks every single request the page makes, not just the first one, and lets it continue only if it passes the check, otherwise it aborts it. This is what would have stopped the post-load navigation in this case.
  • page.goto(store_url, timeout_s=15) opens the shop, giving up after 15 seconds.
  • return page.screenshot() takes the picture and returns it.

Variants to test

These are the same ideas a tester would try on a similar feature. A positive result means the test showed the weakness is present.

A redirect is a web server telling the browser "not here, go there instead". DNS is the internet's phone book, turning names into IP addresses. DNS rebinding abuses the gap between the moment a name is checked and the moment it is used: the name gives a harmless public address during the check, then a private one when the request is actually made. Pinning the addresses, as in the code above, closes that gap.

Glossary

  • API: a defined way for one program to ask another program for something, like a service counter with set questions you are allowed to ask.
  • API version: a numbered edition of that interface; older editions may lack newer protections.
  • Browser: the program that displays web pages; a headless browser is the same thing with no window, running on a server.
  • Container: a sealed-off running copy of an application, sharing one machine with others.
  • Credential: a string that proves identity, such as a token or password.
  • CVE: a public catalogue number for a flaw in installable software; hosted services do not get one.
  • DNS: the internet's phone book, turning host names into IP addresses.
  • DNS rebinding: making a name resolve to a safe address during a check and an internal one afterwards.
  • Egress filtering: controlling which outbound traffic a network is allowed to send.
  • GKE (Google Kubernetes Engine): Google's managed Kubernetes service for running containers across machines.
  • Header: a small line of extra information sent with a web request, like a label on a parcel.
  • HTML: the language web pages are written in.
  • Instance attributes: the pieces of information the metadata service publishes about a machine.
  • IP address: the numeric address of a machine on a network; internal addresses are only reachable from inside.
  • JavaScript: the language that lets a loaded web page do things, such as fetch data or navigate elsewhere.
  • Kubernetes: a system for running and managing many containers across many machines.
  • Metadata concealment: a GKE setting that hides a node's own credentials from the metadata service.
  • Metadata service: a private web service inside a cloud that tells a machine about itself and hands it temporary keys.
  • Node: one machine in a Kubernetes cluster.
  • Pod: the smallest unit Kubernetes runs, one or more containers wrapped together.
  • Production: the systems real customers use, as opposed to test systems.
  • Proxy: a middleman all traffic passes through, able to inspect and refuse requests.
  • Redirect: a server telling the browser to go to a different address instead.
  • Root: the all-powerful account on a Linux machine, able to do anything.
  • Server: a computer in a data centre that answers requests from browsers.
  • Service account: an identity used by a program rather than a person to talk to a cluster; its token proves that identity.
  • SSRF (Server-Side Request Forgery): tricking a server into making a request on your behalf to somewhere you cannot reach yourself.
  • Token: a long random string that proves who you are, like a wristband at an event.

More by Muhammad Asim Shahzad

View all

21 more disclosed reports, best first.

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.