Skip to content
Access control Write-up Intermediate

Using a GraphQL introspection query to apply any discount to any

The GraphQL API left introspection enabled and exposed an order query and a discount mutation without proper authorisation. An attacker could read other users' order data and apply arbitrary discount amounts to any order, potentially obtaining goods for free.

Belal Follow

Published on medium.com

Without too many introductions, let’s dive straight into the details of a vulnerability I discovered in a public e-commerce program. But first, let’s briefly understand what GraphQL is.

Belal, on 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.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely missing authorisation checks on GraphQL queries and mutations, combined with introspection being enabled in production, allowed access to sensitive order data and the discount mutation.

Impact

An attacker could read other users' order details and apply arbitrary discounts to any order, potentially obtaining items for free.

What the attacker needed

GraphQL endpoint with introspection enabled; No authentication or authorisation required

The fix

The report does not state a fix; it should be fixed by disabling introspection in production and enforcing strict authorisation on sensitive queries and mutations.

How it was found

  1. Discover that the site uses a GraphQL API with introspection enabled.
  2. Find the order_intents query in the schema and use a limit to return a few orders.
  3. Use a where filter with a user_id to return detailed order information for a specific user.
  4. Find the insert_attempted_discount_codes mutation in the schema.
  5. Send the mutation with a chosen discount_amount and an order_intent_id to apply the discount.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

GraphQL is a way for apps to ask a server for exactly the data they need. If the server lets anyone list all its available queries and changes (introspection) and does not check who is asking, a stranger can read other people's orders and even change prices. Here the attacker used that openness to add fake discounts to orders.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.