Skip to content
Info disclosure Write-up Intermediate

Path-Disclosure-In-Instagram-Ads-Graphql

An Instagram GraphQL endpoint returned a stack trace when given specific UTF characters, causing a UnicodeDecodeError. This disclosed internal file paths and details about the language and framework used.

Philippe Harewood Follow

Published on philippeharewood.com

The endpoint https://i.instagram.com/api/v1/wwwgraphql/ig/query has an area for GraphQL queries against what was assumed to be a custom schema for ads served in Instagram.

Philippe, on philippeharewood.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.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 4 min read.

What the report shows

The target was the Instagram endpoint https://i.instagram.com/api/v1/wwwgraphql/ig/query, an area for GraphQL queries that the researcher understood to run against a custom schema for ads served in Instagram.

By sending specific UTF characters, the researcher was able to trigger a UnicodeDecodeError. The error response also disclosed stack information. The paths revealed in that stack trace differed from those seen in other path disclosure findings, and they exposed details about the language and framework used to handle the calls.

The report does not include the exact characters used, the full request, or the stack trace itself.

Impact

As the report puts it, an Instagram endpoint was providing a stack trace improperly. The endpoint was subsequently updated to omit the stack trace information.

Timeline

Date Event
Jan 22, 2018 Report sent
Jan 23, 2018 Further investigation by Facebook
Feb 27, 2018 Fixed by Facebook
Feb 27, 2018 Bounty awarded by Facebook

The report gives no severity rating or CVSS score.

Root cause

The report does not explain the underlying cause; it only records that specific UTF characters raised a UnicodeDecodeError. The paths obtained showed details about the language and framework used for the calls.

Impact

The report's own framing is narrow: an endpoint returned a stack trace when it should not have. What an attacker gains is information, not direct access. The disclosed paths revealed the language and framework in use and differed from paths seen in other disclosures, which the report notes differed from paths seen in other disclosures. That kind of detail helps an attacker plan further work against the stack, but the report does not claim any exploitation beyond the disclosure itself.

How this kind of bug works

Stack traces are debugging output. Frameworks and language runtimes produce them when an unhandled exception escapes application code, and many development configurations render them to the response body. In production they should be suppressed, but this fails in predictable ways: a debug flag left on, a custom error handler that only covers some exception types, a middleware layer that catches application errors but not decoding errors raised before the handler runs, or an API gateway that passes upstream error bodies through unchanged.

Input decoding is a common trigger because it happens early, often in the framework or in a proxy in front of it, before any application-level error handling is in scope. Invalid UTF-8, overlong encodings, lone surrogates and truncated multi-byte sequences can all raise decode errors. When the resulting exception is serialised into the response, the trace typically includes absolute file paths, module and package names, function names, line numbers and sometimes configuration values. Each of these narrows an attacker's picture of the target: the framework and version, the directory layout, the names of internal services, and which code paths are reachable.

Defences are layered. Error handlers should catch all exceptions at the outermost boundary and return a generic body with a correlation identifier, logging the detail server-side. Debug modes must be off in production. Reverse proxies and API gateways should replace upstream error bodies rather than forward them. Input validation should reject malformed encodings before they reach deeper code, and responses should never include file paths or internal identifiers.

How to test for it

  1. Identify endpoints that accept structured input: JSON bodies, GraphQL queries, form fields, path segments and query parameters. GraphQL endpoints are worth attention because the query string is parsed and decoded before execution.
  2. Send well-formed requests first to establish the normal error shape: a malformed query, a missing field, an invalid content type. Note whether errors are generic or detailed.
  3. Then send input that is valid at the transport level but invalid as text: byte sequences that are not valid UTF-8, truncated multi-byte characters, lone surrogate escapes in JSON strings, and mixed encodings in a single field. Vary where the bytes sit: inside a string literal, in a key, in a path segment, in a header value.
  4. A positive result is an error response whose body contains stack frames, absolute paths, module names, line numbers or framework identifiers, or a distinct error class name such as a decoding exception that differs from the normal error shape.
  5. Common false positives: a generic error page that merely echoes the input back, a WAF block page, a 400 with a fixed message, or a trace that only appears for requests from your own IP because of a debug header you sent. Confirm the disclosure is reachable without special headers and is stable across repeated requests.

How it is fixed

The standard fix is to catch exceptions at the outermost boundary and return a generic error body, while logging the full detail server-side. Debug and verbose error modes should be disabled in production, and framework defaults that render traces should be overridden explicitly. Proxies and gateways should not forward upstream error bodies. Input should be validated and decoded defensively, with decode failures mapped to a client error rather than an unhandled exception. The report notes only that the endpoint was updated to omit the stack trace.

Hunting notes

This bug class tends to hide in newer or less-travelled API surfaces: GraphQL gateways, mobile API endpoints, internal-looking paths under a public host, and services that sit behind a different framework from the main application. Recon signals include endpoints that return verbose errors for malformed input, responses containing framework-specific error formats, and hosts whose error pages differ from the rest of the estate. Comparing error output across endpoints often shows which ones were built separately and may have weaker handling.

Redact anything sensitive in the excerpt. If the trace leads to a further weakness, demonstrate it separately rather than folding it into the disclosure report.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 7 min read.

What happened, in plain words

Instagram runs a service that delivers ads inside the app. Part of that service is an API endpoint, which is simply a web address that an app or a script can send requests to and get data back from. The endpoint in question was:

Text
https://i.instagram.com/api/v1/wwwgraphql/ig/query

This endpoint speaks GraphQL. GraphQL is a way of asking a server for exactly the data you want, a bit like filling in a very precise order form instead of taking whatever set menu the kitchen sends out. The researcher understood this endpoint to run queries against a custom schema built for Instagram ads. A schema is the description of what questions the server will answer and what shape the answers take.

When you send text to a server, the server has to turn the raw bytes into characters it can read. That translation is called decoding, and UTF-8 is the most common scheme for it. If the bytes do not form valid UTF-8, the decoding step fails. In this case, sending specific UTF characters caused the server to raise a UnicodeDecodeError, which is the name of the error a program throws when it cannot decode text.

The important part is what came back with that error. Instead of a short, polite "something went wrong" message, the response included a stack trace. A stack trace is the debugging printout a program produces when it crashes: it lists the chain of function calls that led to the failure, along with file paths and other internal details. Think of it as the difference between a shop assistant saying "sorry, that did not work" and handing you the internal staff rota, the stockroom map and the manager's notes.

The paths revealed in that trace were different from those seen in other path disclosure findings, and they showed details about the language and framework used to handle the calls. A framework is the collection of pre-built code a developer uses as the foundation of an application. Knowing which language and framework a service uses tells an attacker what kinds of mistakes that stack tends to make and where to look next.

The report does not include the exact characters used, the full request, or the stack trace itself.

Impact

In the report's own words, an Instagram endpoint was providing a stack trace improperly. The endpoint was later updated to omit the stack trace information.

Timeline

Date Event
Jan 22, 2018 Report sent
Jan 23, 2018 Further investigation by Facebook
Feb 27, 2018 Fixed by Facebook
Feb 27, 2018 Bounty awarded by Facebook

The report gives no severity rating or CVSS score.

Why this happens

The report does not explain the underlying cause; it only records that specific UTF characters raised a UnicodeDecodeError. The error response also disclosed stack information. The paths obtained showed details about the language and framework used for the calls.

Decoding happens early, often inside the framework or a proxy sitting in front of it, before the application's own error handling is in scope. That is why this kind of mistake slips through: a team may have careful error handling for its own code and still miss an exception raised by the layer underneath.

What an attacker gains

The report's framing is narrow: an endpoint returned a stack trace when it should not have. What an attacker gets is information, not direct access. The disclosed paths revealed the language and framework in use and differed from paths seen in other disclosures, which the report notes differed from paths seen in other disclosures. That kind of detail helps an attacker plan further work against the stack, but the report does not claim any exploitation beyond the disclosure itself.

In general, how this kind of bug works

Stack traces are debugging output. Frameworks and language runtimes produce them when an unhandled exception escapes application code, and many development configurations render them straight into the response body. In production they should be suppressed, but this fails in predictable ways: a debug flag left on, a custom error handler that only covers some exception types, a middleware layer that catches application errors but not decoding errors raised before the handler runs, or an API gateway that passes upstream error bodies through unchanged.

Input decoding is a common trigger because it happens early. Invalid UTF-8, overlong encodings, lone surrogates and truncated multi-byte sequences can all raise decode errors. When the resulting exception is serialised into the response, the trace typically includes absolute file paths, module and package names, function names, line numbers and sometimes configuration values. Each of these narrows an attacker's picture of the target: the framework and version, the directory layout, the names of internal services, and which code paths are reachable.

Defences are layered. Error handlers should catch all exceptions at the outermost boundary and return a generic body with a correlation identifier, logging the detail server-side. Debug modes must be off in production. Reverse proxies and API gateways should replace upstream error bodies rather than forward them. Input validation should reject malformed encodings before they reach deeper code, and responses should never include file paths or internal identifiers.

In general, how to test for it

  1. Identify endpoints that accept structured input: JSON bodies, GraphQL queries, form fields, path segments and query parameters. GraphQL endpoints are worth attention because the query string is parsed and decoded before execution.
  2. Send well-formed requests first to establish the normal error shape: a malformed query, a missing field, an invalid content type. Note whether errors are generic or detailed.
  3. Then send input that is valid at the transport level but invalid as text: byte sequences that are not valid UTF-8, truncated multi-byte characters, lone surrogate escapes in JSON strings, and mixed encodings in a single field. Vary where the bytes sit: inside a string literal, in a key, in a path segment, in a header value.
  4. A positive result is an error response whose body contains stack frames, absolute paths, module names, line numbers or framework identifiers, or a distinct error class name such as a decoding exception that differs from the normal error shape.
  5. Common false positives: a generic error page that merely echoes the input back, a WAF block page, a 400 with a fixed message, or a trace that only appears for requests from your own IP because of a debug header you sent. Confirm the disclosure is reachable without special headers and is stable across repeated requests.

In general, how it is fixed

The standard fix is to catch exceptions at the outermost boundary and return a generic error body, while logging the full detail server-side. Debug and verbose error modes should be disabled in production, and framework defaults that render traces should be overridden explicitly. Proxies and gateways should not forward upstream error bodies. Input should be validated and decoded defensively, with decode failures mapped to a client error rather than an unhandled exception. The report notes only that the endpoint was updated to omit the stack trace.

In general, where to look

This bug class tends to hide in newer or less-travelled API surfaces: GraphQL gateways, mobile API endpoints, internal-looking paths under a public host, and services that sit behind a different framework from the main application. Signals worth watching include endpoints that return verbose errors for malformed input, responses containing framework-specific error formats, and hosts whose error pages differ from the rest of the estate. Comparing error output across endpoints often shows which ones were built separately and may have weaker handling.

Redact anything sensitive in the excerpt. If the trace leads to a further weakness, demonstrate it separately rather than folding it into the disclosure report.

Glossary

  • API endpoint: a web address that an app or script sends requests to in order to get data back.
  • GraphQL: a way of asking a server for exactly the data you want, using a query language, rather than receiving a fixed response.
  • Schema: the description of what questions a GraphQL server will answer and what shape the answers take.
  • Decoding: turning raw bytes into readable characters.
  • UTF-8: the most common scheme for encoding text as bytes.
  • UnicodeDecodeError: the error a program raises when it cannot decode text as valid UTF-8.
  • Stack trace: a debugging printout listing the chain of function calls that led to a crash, often with file paths and line numbers.
  • Path disclosure: leaking internal file or directory paths through an error or response.
  • Framework: the collection of pre-built code a developer uses as the foundation of an application.
  • Exception: an error raised while a program is running.
  • Middleware: a layer of code that sits between the incoming request and the application, handling things like parsing or logging.
  • API gateway: a component that sits in front of services and forwards requests to them.
  • Proxy: a server that passes requests through to another server.
  • WAF: a web application firewall, which filters requests before they reach the application.
  • False positive: a result that looks like a finding but is not one.
  • CVSS: a standard scoring system for rating the severity of a vulnerability.

More by Philippe Harewood

View all

56 more disclosed reports, best first.

More from Meta

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.