Skip to content
XXE Write-up Intermediate

How we got read access on Google’s production servers

detectify Follow

Published on blog.detectify.com

TwitterLinkedIn

Detectify, on blog.detectify.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

The target was Google's own infrastructure, and the feature in question was the Google Toolbar button gallery. The gallery lets users customise their toolbar with new buttons, and developers can create their own buttons by uploading XML files that carry metadata such as styling. The Detectify team picked this target deliberately: rather than scanning Google from the outside, they wanted to use Google against itself, searching Google for Google-owned systems that were old, obscure, proprietary, or in early alpha or beta stages, since those categories tend to hold the most vulnerabilities.

Setup

The work was a weekend challenge by the Detectify team, who often spent time on bug bounties and CTFs. Mathias proposed the idea of finding a target that could be used against itself, and the team settled on the Google search engine as the tool for finding the target. No accounts, versions or tooling beyond Google search and the gallery's upload feature are described.

Finding it

The team combined Google dorking with a search for acquisitions and products, looking for antique systems without a noticeable number of users. The Google Toolbar button gallery stood out. The team joked that it "looks vuln", and within two minutes they noticed that the gallery lets users customise their toolbar with new buttons, and that developers can upload their own XML files containing metadata such as styling.

Fredrik read through the API specifications and noticed that the title and description fields of a button were printed out when searching for buttons. That reflection point made an XXE attack worth trying: if the parser interpreted user-supplied entities, the reflected fields would carry the expanded content back to the attacker.

Exploitation

Step 1: craft a button with XML entities

Fredrik crafted his own button containing fishy XML entities and uploaded it through the gallery. The upload succeeded on the first attempt, and the result revealed file contents from the server.

Step 2: verify with a second payload

A second upload was made for verification purposes, and it again returned file contents. The two results showed the contents of /etc/passwd and /etc/hosts of one of Google's production servers. The team describes these payloads as a proof of concept to prove impact, noting they could just as well have tried to access any other file on the server, or moved on to SSRF exploitation to reach internal systems.

Root cause

The root cause is a naive XML parser that blindly interprets the DTD of user-supplied XML documents. When a parser resolves external entities declared in an uploaded document, the entity is replaced by the contents of the referenced resource, and because the title and description fields were printed out when searching for buttons, that content came back to the uploader. The report lists the classes of issue this enables: local file access, SSRF, remote file includes, denial of service and possible remote code execution. It points to the OWASP page on XXE and on securing XML parsers in various languages and platforms for the fix.

Impact

The demonstrated impact was read access to files on a Google production server, specifically /etc/passwd and /etc/hosts. The team states that any other file on the server could have been targeted, and that SSRF exploitation to access internal systems was a possible next step.

Fix

The guidance it gives is to secure XML parsers so they do not resolve external entities, referencing the OWASP material on XXE and on hardening XML parsers across languages and platforms.

Variants to test

  • Upload features that accept XML and reflect fields back in listings or search results: a positive result is the reflected field containing the contents of a local file such as /etc/passwd.
  • Any XML import that accepts a DTD: try an external entity pointing at a local file, and separately at an internal URL, to test for file read and SSRF.
  • Metadata fields (titles, descriptions, styling) that are rendered after parsing: these are the natural exfiltration channel, so check whether entity expansion appears in the rendered output.
  • Out-of-band confirmation where nothing is reflected: point an entity at a host you control and watch for the request, which confirms entity resolution even without in-band output.

Disclosure

The team contacted Google straight away and received a reply after 20 minutes from Thai on the Google Security Team, who were impressed. Details were exchanged over the following days, and when the team asked what the vulnerability was worth, Google's answer put it at $10,000, which the team says covered a road trip through Europe. The report is dated 11 April 2014.

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

A small team of security researchers at a company called Detectify spent a weekend trying to break into Google. Their idea was unusual: instead of attacking Google from the outside with special tools, they would use Google's own search engine to find weak spots inside Google's own systems. They found the Google Toolbar button gallery, a system without any noticeable amount of users. That feature let people upload small files to describe new buttons. The team uploaded a file that was built to trick the server into reading files on its own hard drive and showing them back to whoever uploaded it. It worked on the first try. They could read files from one of Google's production servers. They told Google, and Google paid them $10,000.

This article walks through the whole story slowly, explaining every technical word the first time it appears. You only need to know how to use a browser and a computer.

The idea: use a target against itself

To stay current on security news, the Detectify team often spent time on bug bounties and CTFs.

  • A bug bounty is a programme where a company publicly invites outsiders to look for security flaws in its systems and pays them for reporting the flaws responsibly, instead of suing them or ignoring them.
  • A CTF, short for Capture The Flag, is a security competition or exercise where participants try to find hidden pieces of information (the "flags") by solving technical puzzles. It is a bit like a treasure hunt for people who like computers.

One weekend, while the team was deciding what challenge to take on, Mathias, one of the team members, had an interesting idea: what target can we use against itself?

Of course. The Google search engine!

What would be better than to scan Google for bugs other than by using the search engine itself? The reasoning was simple. Google's search engine is very good at finding pages on the internet. Google also owns a huge number of its own pages and services. So the team could type special search queries into Google to find Google's own forgotten corners, and then look for weaknesses there.

They listed the kinds of software that tend to contain the most vulnerabilities:

  • Old and deprecated software
  • Unknown and hardly accessible software
  • Proprietary software that only a few people have access to
  • Alpha/Beta releases and otherwise new technologies (software in early stages of its lifetime)

A vulnerability is a weakness in software that someone can abuse to make the software do something its makers did not intend, such as revealing private data or letting an outsider in. The logic behind the list is that old software is often no longer maintained, obscure software gets less attention from security reviewers, closed software is seen by fewer eyes, and brand new software has not had time to be tested by real users. All four categories are places where mistakes survive longer.

For you bounty hunters, here's a tip:

Finding the target

By combining one thing with another, the team started Google dorking for acquisitions and products to antique systems without any noticeable amount of users.

Google dorking means using advanced search operators in Google, the special words and symbols that narrow a search, to find things that ordinary searches would not surface. For example, you can ask Google to show only pages on a particular domain, or pages containing a particular phrase in their title. Security researchers use it to discover systems that were never meant to be found by the public.

An acquisition is a company that another company has bought. When a big company buys a small one, the small company's old websites and tools often keep running on the big company's infrastructure, sometimes forgotten. A product here means one of the many separate services a large company offers. "Antique systems" means very old systems. The team was deliberately hunting for old, neglected things that belonged to Google but that hardly anyone used.

One system caught their eyes: the Google Toolbar button gallery.

To understand what that is, start with Google Toolbar. It was a small add-on for web browsers that added a bar of buttons under the address bar, giving quick access to Google features. A button in this context is a small customised shortcut: a little icon with a name and a description that, when clicked, does something, such as search a particular site.

The button gallery was a public web page where users could browse buttons made by others and add them to their own toolbar. The team looked at each other and jokingly said "this looks vuln!", meaning "this looks vulnerable", not knowing how right they were.

Not two minutes later they noticed that the gallery provides users with the ability to customise their toolbar with new buttons. If you're a developer, you're also able to create your own buttons by uploading XML files containing various meta data (styling and such).

Two terms need unpacking here. XML stands for Extensible Markup Language. It is a way of writing data as text using tags in angle brackets, a bit like labelling boxes: you write a label, then the content, then a closing label. It is similar to HTML, the language web pages are written in, but XML is meant for describing arbitrary data rather than displaying it. Metadata is data about data: here, the name of the button, its description, and styling details such as colours or icons. "Styling" means how something looks.

So the gallery had an upload feature: a developer could send a file to Google's server, and the server would read it and store the button described inside. That is the feature the team would attack.

The plan: XXE

Fredrik read through the API specifications, and crafted his own button containing fishy XML entities. The plan was to conduct an XXE attack as he noticed the title and description fields were printed out when searching for the buttons.

An API, short for Application Programming Interface, is the set of rules that lets one piece of software talk to another. In everyday terms, think of a restaurant menu: it lists what you can order and how to order it, without you needing to know what happens in the kitchen. The API specifications are the written description of that menu: which requests the server accepts, in what format, and what it sends back. Fredrik read this documentation to learn exactly how to submit a button.

An entity in XML is a named placeholder that stands for some content. You declare it once, give it a name, and then use that name elsewhere in the document; when the document is processed, the name is replaced by the content. It is like writing "see appendix A" in a document and having appendix A pasted in wherever you wrote it. "Fishy" here means suspicious or malicious: Fredrik deliberately built entities designed to make the server do something it should not.

XXE stands for XML External Entity. It is a class of vulnerability where a server processes an uploaded XML document and, because of how its XML parser is configured, follows an entity that points outside the document, for example at a file on the server's own disk. The server then substitutes the file's contents in place of the entity name. If the processed document is later shown back to the person who uploaded it, the file's contents come back with it.

A parser is the piece of software that reads a structured document such as XML and turns it into something the program can work with. It is like a clerk who reads a form and fills in the database: if the clerk follows every instruction written on the form without questioning it, a malicious form can make the clerk do unintended things.

The title and description fields are the parts of the button metadata that hold its name and its explanatory text. The team noticed these fields were printed out when searching for buttons: if you searched the gallery, the results page showed each button's title and description. That is the crucial detail. If the server replaced an entity with the contents of a file, and the title or description contained that entity, then the file's contents would appear on the search results page, visible to the uploader. This is called a reflection: input that comes back out of the application. Without a reflection, the attacker would have no way to see what the server read.

Why XXE works

The root cause of XXE vulnerabilities are naive XML parsers that blindly interpret the DTD of the user supplied XML documents. By doing so, you risk having your parser doing a bunch of nasty things.

A DTD, short for Document Type Definition, is a section at the top of an XML document that declares rules for the document, including entities. A parser that "blindly interprets" the DTD treats every declaration in it as trustworthy, even though the document came from an unknown user on the internet. The everyday comparison: a mailroom clerk who opens every envelope and carries out any instruction written inside, including "go to the filing cabinet and bring back the folder marked salaries", without checking who sent the letter.

Some issues include: local file access, SSRF and remote file includes, Denial of Service and possible remote code execution.

  • Local file access means reading files stored on the server's own disk, files the uploader was never meant to see.
  • SSRF, short for Server-Side Request Forgery, means tricking the server into making a network request on the attacker's behalf, for example to an internal address that outsiders cannot reach directly. The server becomes an unwitting middleman, like asking a colleague inside a building to go and read a noticeboard that visitors are not allowed to approach.
  • Remote file includes means making the server pull in content from a file hosted somewhere else, under the attacker's control.
  • Denial of Service, often shortened to DoS, means making a service so busy or so overloaded that it stops working for legitimate users. A classic XML version is an entity that expands into a huge amount of text, exhausting the server's memory.
  • Remote code execution is the most severe outcome: making the server run commands or programs chosen by the attacker, rather than merely reading data.

If you want to know how to patch these issues, check out the OWASP page on how to secure XML parsers in various languages and platforms.

OWASP, the Open Worldwide Application Security Project, is a non-profit community that publishes free, widely respected guidance on application security. A patch is a fix applied to software. The report points readers to OWASP's material on XXE and on hardening XML parsers rather than describing a fix itself.

The upload

Nevertheless. The file got uploaded, and behold. First try:

Second try (for verification purposes):

Boom goes the dynamite.

What you see in those two images is the /etc/passwd and the /etc/hosts of one of Google's production servers.

These two file names need explaining, because they are central to the story.

  • /etc/passwd is a standard file on Unix-like operating systems, the family of systems that includes Linux, which many web servers run. It lists the user accounts that exist on the machine. On modern systems it does not contain passwords in readable form, but it still reveals which accounts exist, which is useful information to an attacker planning further steps. The leading / means it sits at the root of the filesystem, the top of the disk's folder tree.
  • /etc/hosts is another standard file. It is a small local list that maps names to network addresses, used before the machine asks a central name service. Reading it can reveal how the machine refers to other machines, including internal ones.

A production server is a machine that runs the real, live service used by actual customers, as opposed to a test or development machine. Reading files from a production server is serious: it is not a sandbox or a practice environment.

The team describes these payloads as a proof of concept to prove the impact. A proof of concept, often shortened to PoC, is a minimal demonstration that a vulnerability is real, just enough to show it works without causing harm. The team notes they could just as well have tried to access any other file on their server, or moved on to SSRF exploitation in order to access internal systems. In other words, reading two harmless system files was the safe demonstration; the same technique could have been pointed at more sensitive files or at internal network addresses. To say the least, that's pretty bad.

Telling Google

We contacted Google straight away while popping open some celebration beers. After 20 minutes we got a reply from Thai on the Google Security Team. They were impressed. We exchanged a few emails on the details back and forth during the coming days. In our correspondence we asked how much the vulnerability was worth. This is what we received as reply:

The bottles (or whatever it is that falls out), turned out to be worth $10,000, enough to cover a road trip through Europe.

The team's summary is that the reward was $10,000.

The short version

tl;dr: We uploaded a malicious XML to one of Google's servers. Turned out to be a major XXE issue. Google financed an awesome road trip for the team.

tl;dr stands for "too long; didn't read": a one-line summary placed at the end for readers in a hurry.

Why this matters to you

If Google can get hacked, are you sure your service is secure? Detectify is an automated security monitoring service that tests your website for over 700 vulnerabilities. Sign up for a free trial and check your site's security.

This closing paragraph is the company promoting its own product, an automated service that checks websites for known classes of weakness.

Variants to test

If you ever review a system with an upload feature, these are the patterns worth checking, in the same spirit as the team's test:

  • Upload features that accept XML and reflect fields back in listings or search results: a positive result is the reflected field containing the contents of a local file such as /etc/passwd.
  • Any XML import that accepts a DTD: try an external entity pointing at a local file, and separately at an internal URL, to test for file read and SSRF.
  • Metadata fields (titles, descriptions, styling) that are rendered after parsing: these are the natural exfiltration channel, so check whether entity expansion appears in the rendered output. Exfiltration means getting data out of a system to a place the attacker can see.
  • Out-of-band confirmation where nothing is reflected: point an entity at a host you control and watch for the request, which confirms entity resolution even without in-band output. Out-of-band means the evidence arrives through a separate channel, such as a request to your own server, rather than in the page you are looking at.

Glossary

  • API (Application Programming Interface): the documented set of rules that lets one piece of software send requests to another and understand the replies.
  • API specifications: the written description of an API: which requests it accepts, in what format, and what it returns.
  • Acquisition: a company that has been bought by another company.
  • Alpha/Beta release: an early version of software, released before it is considered finished and stable.
  • Bug bounty: a programme in which a company invites outsiders to find and report security flaws in exchange for a reward.
  • Button (Google Toolbar): a small customised shortcut with an icon, title and description that a user can add to the toolbar.
  • Button gallery: the public web page where Google Toolbar buttons could be browsed, and where developers could upload their own.
  • CTF (Capture The Flag): a security competition or exercise in which participants solve technical puzzles to find hidden flags.
  • Denial of Service (DoS): making a service unusable for legitimate users, for example by exhausting its memory or processing power.
  • DTD (Document Type Definition): a section of an XML document that declares rules and entities for that document.
  • Entity (XML): a named placeholder in an XML document that is replaced by its declared content when the document is processed.
  • Exfiltration: getting data out of a system to a place the attacker can see.
  • Google dorking: using advanced search operators to find pages or systems that ordinary searches would not surface.
  • Google Toolbar: a browser add-on that added a bar of quick-access buttons under the address bar.
  • /etc/hosts: a standard file on Unix-like systems that maps machine names to network addresses locally.
  • /etc/passwd: a standard file on Unix-like systems that lists the user accounts on the machine.
  • Local file access: reading files stored on the server's own disk that the attacker was never meant to see.
  • Metadata: data that describes other data, such as a button's title, description and styling.
  • Out-of-band: evidence that arrives through a separate channel, such as a request to a server you control, rather than in the page you are viewing.
  • OWASP: a non-profit community that publishes free guidance on application security.
  • Parser: software that reads a structured document such as XML and turns it into something a program can use.
  • Patch: a fix applied to software.
  • Production server: a machine running the real, live service used by actual customers.
  • Proof of concept (PoC): a minimal demonstration that a vulnerability is real, without causing harm.
  • Proprietary software: software whose source code is closed and controlled by its owner.
  • Reflection: input that an application sends back out in a page or response.
  • Remote code execution: making a server run commands or programs chosen by the attacker.
  • Remote file include: making a server pull in content from a file hosted elsewhere, under the attacker's control.
  • SSRF (Server-Side Request Forgery): tricking a server into making a network request on the attacker's behalf, often to internal addresses outsiders cannot reach.
  • Styling: the details of how something looks, such as colours and icons.
  • tl;dr: "too long; didn't read", a one-line summary for readers in a hurry.
  • Vulnerability: a weakness in software that can be abused to make it behave in unintended ways.
  • XML (Extensible Markup Language): a text format for describing data using tags in angle brackets.
  • XXE (XML External Entity): a vulnerability in which a server processes an uploaded XML document and follows an entity that points outside the document, such as at a local file.

More by detectify

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

XML external entities (XXE)

The lesson behind this report.

An XML parser resolves entities the attacker defines, reading local files or making the server send requests.