Shopify security

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Shopify security is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Secure Shopify applications — HMAC webhook verification, session token validation, OAuth scope management, Content Security Policy, GDPR mandatory webhooks, input validation, and secure coding practices. Use when implementing Shopify security features.

How to use this skill

Skill file

Shopify Security

Before writing code

Fetch live docs:

  1. Web-search site:shopify.dev security best practices for security guidelines
  2. Web-search site:shopify.dev webhook verification hmac for HMAC implementation
  3. Web-search site:shopify.dev session token for session token verification

HMAC Webhook Verification

Every webhook includes X-Shopify-Hmac-SHA256:

import crypto from 'crypto';

function verifyShopifyWebhook(
  rawBody: Buffer,
  hmacHeader: string,
  secret: string,
): boolean {
  const calculated = crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('base64');

  return crypto.timingSafeEqual(
    Buffer.from(calculated),
    Buffer.from(hmacHeader),
  );
}

Critical: Use timingSafeEqual to prevent timing attacks. Use raw body buffer, not parsed JSON.

Session Token Verification

For embedded apps using App Bridge:

import jwt from 'jsonwebtoken';

function verifySessionToken(token: string, apiSecret: string) {
  const decoded = jwt.verify(token, apiSecret, {
    algorithms: ['HS256'],
  });

  // Verify issuer is a valid Shopify shop
  const iss = decoded.iss as string;
  if (!iss.match(/^https:\/\/[a-zA-Z0-9-]+\.myshopify\.com\/admin$/)) {
    throw new Error('Invalid issuer');
  }

  return decoded;
}

Session token claims:

OAuth Scope Management

Principle of Least Privilege

Scope Verification

Verify the access token has expected scopes:

Content Security Policy (CSP)

For embedded apps in Shopify admin:

```

Content-Security-Policy: frame-ancestors https://*.myshopify.com https://admin.shopify.com;

```

GDPR Mandatory Webhooks

Every app MUST implement:

  1. customers/data_request — respond within 30 days with customer data
  2. customers/redact — delete customer data within 30 days
  3. shop/redact — delete ALL store data within 48 hours of uninstall

Failing to implement these results in app rejection.

Input Validation

API Data

Theme/Liquid

GraphQL

Secrets Management

Best Practices

Fetch the Shopify security documentation for exact HMAC implementation, session token structure, and CSP requirements before implementing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.