Google Maps API (Not the Key) Bugs That I Found Over the Years
Several Google Maps API endpoints (Staticmap, Streetview, Embed) did not enforce HTTP Referer restrictions when the Referer header was omitted, allowing unauthorised use of other customers' API keys. Additionally, wildcard Referer controls could be bypassed using crafted URLs, and the JavaScript API's client-side authentication could be fooled by tampering with server responses.
{{media:0}}
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.
Context
Google Maps exposes several distinct APIs, and each one authenticates callers in its own way. The report covers the API key mechanism (including HTTP Referer restrictions and URL signatures) and the older client-id mechanism used by premium customers, and it notes that nearly every Maps API also has a JavaScript counterpart that uses a different authentication scheme from the REST-style APIs.
The security control at the centre of the first findings is the HTTP Referer restriction: a customer restricts an API key to their own application's referers, and Google Maps servers refuse requests that arrive with a disallowed or missing Referer header. The report also examines the signature parameter used by the Static Maps API, which is meant to be generated on the back end with a private key, and the wildcard referer syntax that lets a key be used across subdomains.

The author had previously published a post on unauthorised Google Maps API key usage and a scanner script, and wrote this follow-up after researchers reported inconsistencies between scanner results and client feedback. The findings are published with the approval of the Google Trust & Safety team.
Setup
The work is black-box testing against Google's public Maps endpoints, using a key published by Google itself in its documentation and keys restricted to the author's own domain. The tools involved are a browser, Burp Suite for intercepting and modifying responses, and the author's own scanner, gmapsapiscanner. No accounts, roles or software versions are given beyond the premium client-id context for the JavaScript API.
The preconditions that matter throughout are:
- A key that is enabled for the API under test (Staticmap, Streetview, Embed, or the JavaScript API).
- For the referer findings, a key configured with referer restrictions, either a full domain or a wildcard subdomain pattern.
- For the JavaScript API finding, the ability to intercept and modify traffic between the browser and Google, which the author frames as a local or internal application where you control the responses reaching your own machine or server.
Finding it
The starting observation is structural: Maps services have several APIs with different authentication schemes, covering both API keys and client-id mechanisms, and almost all of them have a JavaScript version with yet another authentication mechanism. That variety is what made configuration mistakes worth hunting for.
The first anomaly appeared while testing referer restrictions. On most APIs the control behaved correctly in both directions: a request with an allowed Referer succeeded, a request with a disallowed Referer was blocked, and a request with no Referer header at all was also blocked.



But on the Staticmap, Streetview and Embed APIs the control did not hold: deleting the Referer header entirely bypassed the restriction when the key was enabled for those APIs.

The second anomaly came from reading Google's own documentation for the Static Maps API at https://developers.google.com/maps/documentation/maps-static/intro, where Google's own pages use an API key.

That key appeared to be protected by a signature, which is a secure mechanism because signatures are created on the back end with a private key. Removing the signature from the request, however, returned no error.

The third anomaly was in the wildcard referer syntax. Google documents the wildcard form as:
Any subdomain or path URLs in a single domain, using wildcard asterisks (*): *.example.com/*
so a key restricted to *.ozguralp.com/* should only accept ozguralp.com and its subdomains. The author found that other domains could satisfy the check by placing special characters in the wildcard part of the Referer URL.

The fourth anomaly was in the JavaScript API. Loading the example map HTML from https://developers.google.com/maps/documentation/javascript/tutorial without a valid key showed map tiles beginning to load before the page returned an error.


Inspecting the traffic showed the JavaScript file sending a request to https://maps.googleapis.com/maps/api/js/AuthenticationService.Authenticate with the API key in the URL, and the server returning an error because the key was invalid.

With a valid key, the same request returned a body of the same shape, differing only in the detailed error message and the error codes. For a valid key the body is just the string [1,null,0,null,null,[1]], with no cookies, tokens or other security mechanism involved.

That meant the authentication decision was being made on the client side, on data the client could change.
Exploitation
Step 1: Bypass referer restrictions with no Referer header
The payload is a single HTML line. The meta tag stops the browser from sending a Referer header, and the img tag requests a Static Maps image with the target key.
<meta name="referrer" content="no-referrer"/><img src="http://maps.googleapis.com/maps/api/staticmap?center=45%2C10&zoom=7&size=400x400&key=YOUR_API_KEY”>
The first element sets the document's referrer policy to no-referrer, so the image request carries no Referer header. If the key is enabled for the Staticmap API, the request succeeds from any other application, and the referer restriction is bypassed. The same behaviour was observed on the Streetview and Embed APIs.
Step 2: Use Google's own key without a signature
The documentation page's key was used with its signature removed, and the request still succeeded, as shown in the response captured below.

Because the key was also allowed on the Staticmap API with no referer controls, this chained with the first finding. The author's scanner confirmed the leaked key was usable.

Step 3: Bypass wildcard referer restrictions
With a key restricted to *.ozguralp.com/*, the following Referer values were accepted even though the browser actually visits test.com, a domain owned by someone else:
https://test.com#.ozguralp.com
https://test.com?.ozguralp.com
https://test.com\.ozguralp.com
The report attributes the bypass to the wildcard part of the subdomain pattern allowing these special characters. Browsing any of these URLs loads test.com, not ozguralp.com, so the key can be used from another company's site.
Step 4: Use the JavaScript API without a key
- Load the example JS Map HTML without a valid key. Tiles start loading, then the page errors.
- In Burp Suite, intercept the response to the authentication request.

- Change the HTML response body from its original content to the value a valid key would produce.


- Repeat the same interception and body change on the request to
https://maps.googleapis.com/maps/api/js/QuotaService.RecordEvent.

With both responses altered, the client-side check passes and the JavaScript API works on the local host or server instead of returning an error.
Root cause
The referer findings come from the server treating a missing Referer header as acceptable on the Staticmap, Streetview and Embed APIs, rather than rejecting requests that do not present one. The wildcard finding comes from special characters being allowed in the wildcard part of the subdomain pattern, so a URL whose host is not the allowed domain can still match. The signature finding comes from the Static Maps endpoint returning no error when the signature was removed, so a key meant to be protected by a back-end-generated signature worked with the key alone. The JavaScript API finding comes from the client trusting the server's authentication response without any session control: all data gathering starts before authentication completes, and the only thing standing between an unauthenticated client and a working map is a response body the client can rewrite. In each case the existing defence (referer check, signature, authentication response) was present but not enforced where it mattered.
Impact
An attacker who obtains a customer's key, or who uses a key published by Google itself, can consume the Maps APIs on the customer's account when the key is enabled for Staticmap, Streetview or Embed, regardless of referer restrictions. For the wildcard case, any key restricted with a wildcard subdomain pattern can be used from an attacker-controlled domain. For the JavaScript API, anyone who can modify their own traffic can use the API without a valid key on a local or internal application.
A later update, contributed by Gerard Arall, notes that the Embed API bypass applies only to the basic, free endpoints; the advanced endpoints still return 403. The practical risk to a customer is unexpected billing, and the author recommends a budget or quota limit, while warning that if the Maps integration is central to the business, an over-quota state can act as a denial of service, so the limit should be chosen with that in mind.
Fix
The wildcard referer bypass was patched by Google without notifying the author. The other issues were not fixed at the time of writing: the missing-Referer bypass on Staticmap, Streetview and Embed was still present in production after 1.5 years, and the signature-less use of Google's own key still worked more than a year after it was reported. The report does not describe the code changes that would fix them; the implied fixes are to reject requests with no Referer header on those APIs, to require the signature parameter on Static Maps requests, and to enforce the JavaScript API authentication on the server rather than trusting a client-side response.
Variants to test
- Strip the Referer header on any API that advertises referer restrictions, using the
no-referrermeta tag or a proxy. A positive result is a successful response where the same request with a disallowed Referer is blocked. - Remove the signature parameter from a signed Static Maps request. A positive result is a normal map image instead of an error.
- Try
#,?and\in front of an allowed wildcard domain in the Referer, for examplehttps://attacker.tld#.allowed.tld. A positive result is a successful response while the browser actually loads the attacker's domain. - Intercept the JavaScript API authentication response and replace the error body with the valid body
[1,null,0,null,null,[1]], and do the same for the quota recording request. A positive result is a working map without a valid key. - Run the author's scanner against keys found in documentation and public pages. A positive result is a key that responds successfully to API calls it should not be authorised for.
What happened, in plain words
Google Maps is not one product but a collection of services that websites and apps can call to draw maps, show street-level photos, or embed a map in a page. Each of those services is an API: a way for one piece of software to ask another piece of software to do something, like a waiter taking your order to the kitchen. You do not go into the kitchen yourself; you ask, and the kitchen answers.
To use Google's kitchen, a website needs a key. An API key is a long string of characters that identifies who is asking, much like a membership card at a gym: the gym lets you in because the card says you belong. Because every use of the Maps services can be billed, the key is also how Google knows whose account to charge.
A key on its own is dangerous if it leaks, so Google offers extra locks. One lock is the HTTP Referer restriction: the browser normally tells the server which web page the request came from, and the customer can say "only accept requests that come from my own site". Another lock is a signature, a code computed on the customer's own server with a secret, so that a request without the right code is refused. A third is the client-id, an older way for paying customers to identify themselves.
This report is a tour of four places where those locks did not do their job. In each case the lock existed on paper but could be walked around. The author found them over several years, reported them to Google, and published the write-up with the approval of Google's Trust & Safety team.

Before this article, the author had already published a post about unauthorised use of Google Maps API keys, plus a small program called gmapsapiscanner that checks whether a key can be abused. Other researchers wrote to him saying the scanner's results did not always match what clients saw, and that there might be deeper bugs behind the difference. That is why he collected everything he had found into one place.
The ideas you need before the details
A few terms come back constantly, so here they are from zero.
- An API is a defined way for software to talk to software. When a web page shows you a map, the page is not drawing the map itself; it is asking Google's servers for map images or map data and then displaying the answer.
- An API key is a password-like string that identifies the application making those requests. It is not usually a human's password; it belongs to a website or app.
- A request is one message sent to a server, and a response is the server's answer. A request has a URL, some headers (small labelled pieces of information sent along with it), and sometimes a body.
- The Referer header (yes, spelled that way in the protocol) is a header in which the browser says which page the request started from. If you click a link on
example.comthat loads an image frommaps.googleapis.com, the image request usually carriesReferer: https://example.com/.... It is like a return address on an envelope. - A signature is a short code computed from the request using a secret that only the customer's server knows. If someone changes the request or removes the code, the server can tell. It is like a wax seal on a letter: easy to check, hard to forge.
- A cookie is a small piece of data a website asks your browser to store and send back on later requests, so the server can recognise you between requests. A token is a similar idea: a value that proves you were authenticated earlier. Both are ways of remembering who you are.
- Authentication means proving who you are. Authorisation means deciding what you are allowed to do once you have proved it.
- Client-side means the work happens in your browser or on your computer, where you control it. Server-side means it happens on the company's machine, where you do not. A rule enforced only on the client side is like a nightclub bouncer who asks you to tick a box saying you are old enough: you can always tick it.
- Burp Suite is a tool that sits between your browser and a website and lets you look at, pause, and change the traffic going each way. Think of a postal worker who can open your letters, read them, rewrite them, and reseal them before delivery.
- A wildcard is a pattern character, usually
*, meaning "anything here".*.example.commeans "example.com and any subdomain of it". - A subdomain is a name in front of a domain: in
maps.google.com,mapsis a subdomain ofgoogle.com. - Production means the live systems real customers use, as opposed to a test environment.
- A 403 is the HTTP status code for "forbidden": the server understood the request and refused it.
- A quota is a cap on how much of a service you may use, and a budget is a cap on how much money you are willing to spend.
- A denial of service happens when a service stops working for legitimate users, for example because a limit was hit.
The starting point
The author's first observation was structural. Google Maps is not one API but several, and they do not all check identity the same way. Some use API keys, some support the older client-id mechanism for premium customers, and nearly every one has a JavaScript version that authenticates differently again. Where there are many doors, there are many chances for one of them to be left unlocked, so that variety is exactly what made the area worth testing.
The testing was black-box: the author did not have access to Google's source code, only to the public endpoints, the way any customer or attacker would see them. He used a key that Google itself had published in its own documentation, and keys restricted to his own domain. The tools were a browser, Burp Suite, and his own scanner.
Three conditions had to be true for the findings to matter:
- The key had to be enabled for the API being tested: Staticmap, Streetview, Embed, or the JavaScript API.
- For the referer findings, the key had to be configured with referer restrictions, either a full domain or a wildcard subdomain pattern.
- For the JavaScript API finding, the person had to be able to intercept and change the traffic between their browser and Google, which is realistic for a local or internal application where you control what reaches your own machine.
Finding the problems
The first place to look was the referer restriction. On most APIs it behaved exactly as advertised. A request carrying an allowed Referer succeeded.

A request carrying a Referer that was not on the list was blocked.

And a request with no Referer header at all was also blocked, which is the safe behaviour: if you cannot prove where you came from, you are turned away.

But on three APIs, Staticmap, Streetview and Embed, the last of those checks was missing. Deleting the Referer header entirely let the request through whenever the key was enabled for those APIs.

The second problem came from reading Google's own documentation for the Static Maps API at https://developers.google.com/maps/documentation/maps-static/intro. The example pages there use an API key belonging to Google.

That key looked protected by a signature, which is the strong mechanism: the signature is generated on the back end with a private secret, so nobody without the secret can produce a valid one. Yet when the signature was simply removed from the request, the server returned no error.

The third problem was in the wildcard syntax. Google documents the wildcard form like this:
Any subdomain or path URLs in a single domain, using wildcard asterisks (*): *.example.com/*
In plain words: a key restricted to *.ozguralp.com/* should accept ozguralp.com and names like test.ozguralp.com, and nothing else. The author found that other domains could still pass the check by putting special characters in the wildcard part of the Referer URL.

The fourth problem was in the JavaScript API. Loading Google's example map page from https://developers.google.com/maps/documentation/javascript/tutorial without a valid key showed something odd: map tiles began to load before the page finally showed an error.

Then the error appeared.

Looking at the traffic explained why. The JavaScript file sends a request to https://maps.googleapis.com/maps/api/js/AuthenticationService.Authenticate with the API key in the URL, and the server answers with an error because the key is not valid.

With a valid key, the same request came back with a body of the same shape, differing only in the detailed error message and the error codes. For a valid key the body is just the string [1,null,0,null,null,[1]], and no cookie, token or other proof of identity is involved.

That is the key insight: the decision about whether you are allowed in was being made on the client side, using data the client can change. The map data had already started arriving before the decision was made.
Exploiting the problems
Step 1: Get past the referer restriction by sending no Referer at all
The whole attack is one line of HTML. The meta tag tells the browser not to send a Referer header, and the img tag asks for a Static Maps image using the target key.
<meta name="referrer" content="no-referrer"/><img src="http://maps.googleapis.com/maps/api/staticmap?center=45%2C10&zoom=7&size=400x400&key=YOUR_API_KEY”>
Line by line:
<meta name="referrer" content="no-referrer"/>sets the page's referrer policy tono-referrer. From that point on, the browser sends no Referer header with requests that start from this page. It is like posting a letter with no return address.<img src="..."/>makes the browser fetch an image from the given URL. The URL is a Static Maps request:center=45%2C10picks the map centre,zoom=7the zoom level,size=400x400the image size, andkey=YOUR_API_KEYthe key being abused.
Why this works: the server should refuse a request that cannot say where it came from, but on the Staticmap API it accepts it. So if the key is enabled for that API, the request succeeds from any other application, and the referer restriction is bypassed. The same behaviour was seen on the Streetview and Embed APIs.
Step 2: Use Google's own key without its signature
The key from the documentation page was used with its signature removed, and the request still succeeded, as the captured response shows.

Because that key was also allowed on the Staticmap API with no referer controls, this chained with the first finding: two weaknesses together made the key usable by anyone. The author's scanner confirmed the leaked key was usable.

Step 3: Get past a wildcard referer restriction
With a key restricted to *.ozguralp.com/*, the following Referer values were accepted even though the browser actually visits test.com, a domain owned by someone else:
https://test.com#.ozguralp.com
https://test.com?.ozguralp.com
https://test.com\.ozguralp.com
Line by line:
https://test.com#.ozguralp.comuses#, the fragment marker. Everything after#is normally ignored by the browser when deciding which page to load, so the browser goes totest.com.https://test.com?.ozguralp.comuses?, which normally starts the query string. Again the browser loadstest.com.https://test.com\.ozguralp.comuses a backslash, which browsers treat leniently in URLs.
Why this works: special characters were allowed in the wildcard part of the subdomain pattern, so the string matched *.ozguralp.com even though the real destination was test.com. Browsing any of these URLs loads test.com, not ozguralp.com, so the key can be used from another company's site.
Step 4: Use the JavaScript API without a key
- Load the example JS Map HTML without a valid key. Tiles start loading, then the page errors.
- In Burp Suite, intercept the response to the authentication request.

- Change the HTML response body from its original content to the value a valid key would produce.


- Repeat the same interception and body change on the request to
https://maps.googleapis.com/maps/api/js/QuotaService.RecordEvent.

Why each step: the browser asks Google whether the key is valid, and Google says no. But because the browser is the one reading the answer, and Burp Suite sits in the middle, you can replace the "no" with the "yes" that a valid key would have produced. The second request, which records quota usage, needs the same treatment, otherwise it would still fail. With both responses altered, the client-side check passes and the JavaScript API works on the local host or server instead of returning an error.
Why the problems existed
Each finding has a simple root cause, and in each case the defence was present but not enforced where it mattered.
- The referer findings come from the server treating a missing Referer header as acceptable on the Staticmap, Streetview and Embed APIs, instead of rejecting requests that do not present one.
- The wildcard finding comes from special characters being allowed in the wildcard part of the subdomain pattern, so a URL whose host is not the allowed domain can still match.
- The signature finding comes from the Static Maps endpoint returning no error when the signature was removed, so a key meant to be protected by a back-end-generated signature worked with the key alone.
- The JavaScript API finding comes from the client trusting the server's authentication response with no session control: data gathering starts before authentication completes, and the only thing between an unauthenticated client and a working map is a response body the client can rewrite.
What the impact was
An attacker who obtains a customer's key, or who uses a key published by Google itself, can consume the Maps APIs on the customer's account when the key is enabled for Staticmap, Streetview or Embed, regardless of referer restrictions. For the wildcard case, any key restricted with a wildcard subdomain pattern can be used from an attacker-controlled domain. For the JavaScript API, anyone who can modify their own traffic can use the API without a valid key on a local or internal application.
A later update, contributed by Gerard Arall, notes that the Embed API bypass applies only to the basic, free endpoints; the advanced endpoints still return 403. The practical risk to a customer is unexpected billing, and the author recommends a budget or quota limit, while warning that if the Maps integration is central to the business, an over-quota state can act as a denial of service, so the limit should be chosen with that in mind.
What was fixed, and what was not
The wildcard referer bypass was patched by Google without notifying the author. The other issues were not fixed at the time of writing: the missing-Referer bypass on Staticmap, Streetview and Embed was still present in production after 1.5 years, and the signature-less use of Google's own key still worked more than a year after it was reported. The report does not describe the code changes that would fix them; the implied fixes are to reject requests with no Referer header on those APIs, to require the signature parameter on Static Maps requests, and to enforce the JavaScript API authentication on the server rather than trusting a client-side response.
Things you can try yourself
These are the same checks the author ran, written as a checklist. Only test systems you own or are authorised to test.
- Strip the Referer header on any API that advertises referer restrictions, using the
no-referrermeta tag or a proxy. A positive result is a successful response where the same request with a disallowed Referer is blocked. - Remove the signature parameter from a signed Static Maps request. A positive result is a normal map image instead of an error.
- Try
#,?and\in front of an allowed wildcard domain in the Referer, for examplehttps://attacker.tld#.allowed.tld. A positive result is a successful response while the browser actually loads the attacker's domain. - Intercept the JavaScript API authentication response and replace the error body with the valid body
[1,null,0,null,null,[1]], and do the same for the quota recording request. A positive result is a working map without a valid key. - Run the author's scanner against keys found in documentation and public pages. A positive result is a key that responds successfully to API calls it should not be authorised for.
Glossary
- API: a defined way for one piece of software to ask another to do something, like a menu you order from.
- API key: a long string that identifies which application is making requests, and whose account to bill.
- Authentication: proving who you are.
- Authorisation: deciding what you are allowed to do once you have proved who you are.
- Black-box testing: testing a system only through its public interfaces, without seeing its source code.
- Budget: a cap on how much money you are willing to spend on a service.
- Burp Suite: a tool that sits between your browser and a website so you can inspect, pause and change the traffic.
- Client-id: an older way for premium Google Maps customers to identify themselves, now out of date.
- Client-side: happening in your browser or on your computer, where you control it.
- Cookie: a small piece of data a site asks your browser to store and send back later, so the server can recognise you.
- Denial of service: a situation where a service stops working for legitimate users, for example because a limit was hit.
- Embed API: a Google Maps API for putting a map inside a web page.
- Header: a small labelled piece of information sent along with a request or response.
- HTTP Referer: a header in which the browser says which page a request started from.
- JavaScript API: the Google Maps API used from JavaScript code running in a browser.
- Production: the live systems real customers use.
- Quota: a cap on how much of a service you may use.
- Request: one message sent to a server.
- Response: the server's answer to a request.
- Signature: a short code computed from a request using a secret, so the server can tell the request was not altered or forged.
- Staticmap API: a Google Maps API that returns a fixed map image for given parameters.
- Streetview API: a Google Maps API that returns street-level imagery.
- Subdomain: a name in front of a domain, as
mapsis inmaps.google.com. - Token: a value that proves you were authenticated earlier, similar in purpose to a cookie.
- 403: the HTTP status code meaning "forbidden": the server understood and refused.
- Wildcard: a pattern character, usually
*, meaning "anything here". gmapsapiscanner: the author's scanner for checking whether Google Maps API keys can be abused.