Advanced Security model

Security model

Which keys and tokens live where, how a PayPal payment becomes verified access, and what client-side gating can and cannot protect.

What ExtensionBill trusts, what it never trusts, and where each secret lives. Read it before you decide how much paid functionality to gate inside the extension.

At a glance

Secrets and tokens

ItemLives inVisible to users?How it is protected
Publishable key pk_test_… / pk_live_…Your extension codeYes, by designPublic identifier. Can only do what an install of your extension can do.
Secret API key sk_test_… / sk_live_…Your server onlyNeverShown once; stored as a SHA-256 hash; revocable.
PayPal Client IDExtensionBillClient ID is public in PayPal’s modelShown in Settings → PayPal and to the hosted checkout.
PayPal client secretExtensionBillNeverEncrypted with AES-256-GCM at rest; never returned by any API or shown again.
Install token it_…The extension’s chrome.storage.local, mirrored to chrome.storage.syncTo someone inspecting their own browser, and via browser sync to their other browsers on the same profileStored server-side as a SHA-256 hash; identifies a single install.
Webhook signing secret whsec_…ExtensionBill and your serverNeverEncrypted at rest; shown only on create and rotate.
Entitlement token (ES256 JWT)The extension’s chrome.storage.localReadable, but cannot be forgedSigned with ExtensionBill’s private key; verifiable with the public JWKS.
Card and bank detailsPayPal onlyNot to you or ExtensionBillEntered in PayPal’s own buttons and windows.

ExtensionBill never logs secrets, and uses constant-time comparisons wherever a secret or signature is checked.

Threats and protections

ThreatProtectionDetails
Changing the price in the browserAmounts are computed on the server; the PayPal capture is checked against them.From payment to access
Forged or replayed PayPal eventsVerified with PayPal’s API and processed once per event id.PayPal webhooks
Editing the cached state in storageState carries an ES256-signed token.Signed entitlement token
Patching the extension’s codeCannot be prevented client-side; keep valuable work on your server.Limits of client-side gating
Other extensions reusing your publishable keyOptional allow list of extension IDs.Allowed extension IDs
Faking uninstalls or feedbackUninstall links are signed.Signed uninstall links
Guessing email sign-in codesHashed, short-lived codes with attempt and send limits.Email codes
Forged webhooks to your serverHMAC-SHA256 signature with a timestamp.Outbound webhook signatures
Leaking card dataCard details only ever reach PayPal.Card data and PCI

Keys and tokens

Publishable key

The publishable key identifies your app and environment (pk_test_… for sandbox, pk_live_… for live). It is meant to be shipped in your extension, where anyone can read it. With it, a caller can only do what any install of your extension can: register an install, read that install’s own state, list your public plans, and open checkout, portal and restore sessions. It cannot read other customers’ data, issue refunds or grant access.

You can roll the publishable key from the dashboard. The old key stops working immediately (invalid_publishable_key), so every published build that still contains it breaks. Only roll a key when you have to, and ship an update with the new key right away.

Secret API keys

sk_test_… and sk_live_… keys authenticate the Server API. They can read customer data and grant or revoke access, so they belong on your server only: never in the extension, a web page, or a repository. ExtensionBill stores only a SHA-256 hash and the first 12 characters for display. The full key is shown once on creation. Revoke a key in Developers → API keys the moment you suspect it leaked.

PayPal credentials

You connect your own PayPal REST app by pasting its Client ID and secret (see Connect PayPal). The secret is validated, encrypted with AES-256-GCM, and never returned by any endpoint or shown in the dashboard again. Credential changes are recorded in the audit log. To change credentials, paste new ones; to cut ExtensionBill off entirely, disconnect in Settings → PayPal or delete the REST app in the PayPal developer dashboard.

Install token

On first run the SDK registers the install and receives an install token (it_…). The SDK keeps it in chrome.storage.local under the extensionbill: prefix, mirrors it to chrome.storage.sync, and sends it as a bearer token on install-scoped calls. The sync copy lets the user’s other computers on the same synced browser profile share the same install, so the token travels with the user’s browser sync. Chrome deletes it on uninstall, so a reinstall gets a new install and token. ExtensionBill stores only its SHA-256 hash. A token only lets its holder read and act on that one install.

From payment to access

Access is never granted on the browser’s word. The chain is:

  1. The hosted checkout page asks ExtensionBill to create a PayPal order. Amounts, currency, discounts and tax are computed on the server from your catalog; nothing the browser sends can change the price.
  2. The buyer approves in PayPal’s buttons.
  3. ExtensionBill captures the payment server-to-server with PayPal and checks the captured amount, currency and checkout reference against what it computed. A mismatch is rejected (paypal_amount_mismatch) and nothing is unlocked.
  4. Only when PayPal reports the capture as COMPLETED is the order marked paid and the entitlement created. Pending captures (for example eCheck) leave the order pending with no access until PayPal confirms completion through a webhook.
  5. The extension refreshes and receives the new state from ExtensionBill.

Subscriptions follow the same rule: access starts when PayPal reports the subscription active and ends based on PayPal’s own status (canceled, suspended, expired, failed payments past your grace period).

PayPal webhooks

When you connect PayPal, ExtensionBill registers a webhook in your PayPal app pointing at its own endpoint. Every incoming PayPal event is:

  • verified by calling PayPal’s verify-webhook-signature API with the stored webhook id and the PAYPAL-* transmission headers,
  • stored before processing, with its verification result,
  • rejected if verification fails: unverified events are kept for inspection with status rejected and never change any data,
  • processed idempotently by PayPal event id, so redeliveries and replays cannot double-grant access or double-count refunds.

You can see every event, its verification result and processing status in Developers → PayPal events.

Signed entitlement token

Every UserState the SDK receives includes entitlementToken, an ES256 (ECDSA P-256 / SHA-256) JWT signed by ExtensionBill:

{
  "sub": "3f0b8f1e-6c1d-4f7a-9a52-1e7d0c4b9a21",
  "aud": "pk_live_...",
  "paid": true,
  "entitlements": ["pro"],
  "trialEndsAt": null,
  "iat": 1760277987,
  "exp": 1760537187
}

sub is the install id and aud is your publishable key. Tokens are valid for 72 hours. The SDK caches the public keys from the JWKS endpoint and verifies the signature with Web Crypto, which is how it keeps working offline: a cached state is trusted until the token expires, and a state with an invalid signature is treated as free. Editing the cached state in storage therefore does not unlock anything by itself.

The JWKS is public:

https://api.extensionbill.com/v1/sdk/jwks.json

Your own server can verify a token the extension sends it without calling ExtensionBill on every request:

// verify-entitlement-token.js (Node 18+)
import { webcrypto } from 'node:crypto'

const { subtle } = webcrypto
const JWKS_URL = 'https://api.extensionbill.com/v1/sdk/jwks.json'
const PUBLISHABLE_KEY = process.env.EXTENSIONBILL_PUBLISHABLE_KEY // pk_live_…
const JWKS_TTL_MS = 60 * 60 * 1000

let jwksCache = null

async function getSigningKeys() {
  if (jwksCache && Date.now() - jwksCache.fetchedAt < JWKS_TTL_MS) return jwksCache.keys
  const response = await fetch(JWKS_URL)
  if (!response.ok) throw new Error(`JWKS request failed with ${response.status}`)
  const { keys } = await response.json()
  jwksCache = { keys, fetchedAt: Date.now() }
  return keys
}

function decodeJson(segment) {
  return JSON.parse(Buffer.from(segment, 'base64url').toString('utf8'))
}

export async function verifyEntitlementToken(token) {
  const parts = typeof token === 'string' ? token.split('.') : []
  if (parts.length !== 3) return null
  const [encodedHeader, encodedPayload, encodedSignature] = parts

  let header
  let claims
  try {
    header = decodeJson(encodedHeader)
    claims = decodeJson(encodedPayload)
  } catch {
    return null
  }
  if (header.alg !== 'ES256') return null

  const signed = new TextEncoder().encode(`${encodedHeader}.${encodedPayload}`)
  const signature = new Uint8Array(Buffer.from(encodedSignature, 'base64url'))
  const candidates = (await getSigningKeys()).filter(
    (jwk) => jwk.kty === 'EC' && jwk.crv === 'P-256' && (!header.kid || jwk.kid === header.kid),
  )

  for (const jwk of candidates) {
    const key = await subtle.importKey(
      'jwk',
      { kty: jwk.kty, crv: jwk.crv, x: jwk.x, y: jwk.y },
      { name: 'ECDSA', namedCurve: 'P-256' },
      false,
      ['verify'],
    )
    const valid = await subtle.verify({ name: 'ECDSA', hash: 'SHA-256' }, key, signature, signed)
    if (!valid) continue

    const audiences = Array.isArray(claims.aud) ? claims.aud : [claims.aud]
    if (!audiences.includes(PUBLISHABLE_KEY)) return null
    if (typeof claims.exp !== 'number' || claims.exp <= Math.floor(Date.now() / 1000)) return null
    return claims // { sub: installId, paid, entitlements, trialEndsAt, iat, exp }
  }
  return null
}

A valid token proves what ExtensionBill said about that install at iat. It may be up to 72 hours old (a refund or cancellation in the meantime is not reflected), and whoever holds it can present it. When you need the current state, call GET /v1/installs/:installId from the Server API.

Limits of client-side gating

Everything that runs in the user’s browser is under the user’s control. A determined user can unpack your extension, edit the JavaScript so bill.hasAccess() returns true, and load the modified copy unpacked. No client-side check, signed token or obfuscation can prevent this, for ExtensionBill or any other approach.

What signed state does guarantee is that ExtensionBill’s own records cannot be faked from the client: nobody can create a paid order, entitlement or license without a real completed PayPal payment, and editing stored data doesn’t produce a valid signature.

Plan accordingly:

  • Low-value or local features (UI themes, local settings, limits on local actions): gating in the extension with bill.hasAccess() is fine. Most users pay rather than patch code.
  • Valuable work (AI calls, sync, storage, data you pay for per request): do it on your server and check access there, using the install id and the Server API, as in Verify an extension user from your backend. The extension then never holds anything worth stealing.

Platform protections

Allowed extension IDs

By default any extension that knows your publishable key can call the SDK endpoints with it. In Settings → General you can list your extension’s IDs (the 32-character a–p IDs Chromium browsers assign). When the list is non-empty, SDK requests whose Origin is a browser-extension origin with an ID not on the list are refused with 403 extension_not_allowed.

Remember to include every ID you use: the store ID, and the different ID of your unpacked development build (or pin it with a key in your manifest). This is a defense-in-depth measure: it stops other extensions from quietly reusing your key and polluting your install data. It does not stop a non-browser script that forges headers, which is why all real authority sits on the server.

CORS

  • SDK endpoints (/v1/sdk/*) accept browser requests from chrome-extension://, moz-extension:// and safari-web-extension:// origins plus ExtensionBill’s own hosted pages. Your extension needs no host_permissions.
  • Dashboard and hosted-page endpoints accept credentialed requests only from https://app.extensionbill.com.
  • The Server API and webhook receivers do not allow browser cross-origin requests at all. Call the Server API from your server.

Rate limits

Abuse-prone endpoints are rate limited and answer 429 rate_limited with a Retry-After header:

  • install registration: 30 per minute per IP,
  • public checkout changes: 60 per minute per IP,
  • email codes: 5 sends per 15 minutes per email and app, 5 attempts per code,
  • PayPal credential validation: 20 per 5 minutes per dashboard user.

See Error codes.

The SDK sets your extension’s uninstall URL to a link containing the install id, your publishable key and a signature: an HMAC-SHA256 of the install id, keyed with a server-side secret. ExtensionBill only marks an install as uninstalled, and only accepts uninstall feedback, when the signature matches. Nobody can mark other people’s installs as uninstalled or post feedback in their name by editing the URL.

Email codes

The customer portal and “Restore purchases” sign buyers in with a one-time code sent to their email. Codes are stored hashed, expire after 10 minutes and allow at most 5 wrong attempts; sends are rate limited. Portal sessions last 2 hours. Restoring links only the requesting install to the customer whose email was proven.

Outbound webhook signatures

Events ExtensionBill sends to your server are signed with an HMAC-SHA256 over the timestamp and raw body, using a per-endpoint whsec_… secret, and include the timestamp so you can reject replays older than 5 minutes. Endpoints must use HTTPS (plain http://localhost only in sandbox). See Webhooks for verification code.

Audit log

Every change made in the dashboard is recorded in Developers → Audit log: refunds, cancellations, pauses, access grants and revocations, license changes, key rolls, PayPal credential changes, go-live toggles and more. Changes made through the Server API are logged with the API key as the actor, and automatic changes (from PayPal events or schedules) as the system. Each entry includes who acted, what changed, when, and the IP address for dashboard actions.

Data and privacy

Data about your buyers

You are the seller: buyers pay you, and you decide what to do with their data. ExtensionBill stores only what it needs to run billing for you:

  • Customers: email, name (when provided or collected), PayPal payer id, country as reported by PayPal, and any note you add.
  • Commerce records: orders, subscriptions, refunds, licenses, entitlements, disputes and the related PayPal ids, plus any custom checkout fields you configure.
  • Installs: a random install id, extension ID, browser, extension version, locale, install/last-seen/uninstall timestamps, and optional uninstall feedback.

Each record belongs to one app and one environment; sandbox and live data are fully separate. Only you (the app owner) can see your apps’ data; requests for another owner’s app return 404.

What the SDK collects per install, and what it never collects, is listed in Install analytics.

Card data and PCI

Card and bank details are entered only into PayPal’s own payment buttons and windows. They go straight to PayPal; neither ExtensionBill nor your extension ever sees, transmits or stores card data. ExtensionBill only receives PayPal’s order, capture and subscription ids and statuses. This keeps your extension and ExtensionBill out of scope for handling raw card data. Your obligations as the seller toward PayPal are set by your PayPal account terms.

Manifest V3 and CSP

The SDK is built for Manifest V3’s content security policy:

  • It is bundled into your extension. There is no remote code, no eval, no new Function, and no script loaded from a CDN.
  • The service worker code never touches the DOM.
  • The optional paywall from @extensionbill/sdk/paywall renders into a shadow root with built-in styles and attaches listeners with addEventListener, never inline handlers or external CSS.
  • PayPal’s own scripts only run on the hosted checkout page at https://app.extensionbill.com/pay/…, which opens in a regular browser tab. You never relax your extension’s CSP or embed third-party scripts.

The only permissions the SDK needs are storage and, optionally, alarms. See Quickstart and SDK configuration.

Reporting a vulnerability

If you find a security issue in ExtensionBill, report it privately to support@extensionbill.com with details and steps to reproduce. Don’t disclose it publicly until it is fixed.