External integration security guidance
External integrations connect product features to payment providers, mobile platforms, and AI services. They also create trust boundaries where client input, provider messages, secrets, and paid resources meet. This guidance keeps those boundaries controlled by treating clients and external responses as untrusted, keeping private credentials on trusted servers, and limiting the cost and effect of each request.
Integration trust boundaries
An integration trust boundary separates the product from a client environment or an external provider. The product must verify data when it enters the boundary and must limit what can leave it. This prevents a browser, mobile app, webhook sender, or model from choosing prices, identities, permissions, or actions that belong to the server.
The security review should trace both directions of the exchange:
- Client to product: Treat request fields, deep-link values, and client flags as attacker-controlled.
- Product to provider: Send only the data and permissions needed for the requested feature.
- Provider to product: Verify signatures where the provider supports them, then validate the event before changing state.
- Product to client: Return only data the client needs. Never return private keys or trusted internal state that the client can reuse.
The following child pages cover the main integration groups:
| Integration group | Security focus | Guidance |
|---|---|---|
| Payments | Server-owned prices, verified provider events, and current subscription state | Payment security |
| Mobile clients | Secret-free app bundles, protected tokens, and safe deep links | Mobile security |
| AI services | Private provider keys, usage limits, prompt boundaries, and safe model output | AI integration security |
Server-side ownership
The server owns values that affect money, access, identity, or provider cost. A client can request an operation, but it cannot decide the price, role, subscription state, usage allowance, or provider credential used to perform it.
Keep provider secrets out of source code and client bundles. Values placed in browser or mobile configuration are visible to the user of that client. Use a server-side path for calls that need a secret key. Store only the minimum client-safe configuration in the client.
This boundary also applies to mobile and AI features. The mobile app calls the product server, and the product server calls the provider. AI requests use the same path so users cannot extract a provider key or bypass application limits.
Provider event handling
Provider events can update important product state, such as a payment or subscription. The product must confirm that an event came from the provider before it changes that state. It must also use the verified event data to find the related account instead of trusting user data supplied in an unverified request.
When a provider supports signed events, preserve the original request body for signature verification. After verification, validate the event type and its expected fields. Keep the product database as the source of truth for access decisions, and refresh that state from trusted provider events.
Request and output controls
Every integration needs limits on what it accepts, what it can do, and how often it can run. Validate input against an allowlist or schema before it reaches a provider or a sensitive action. Apply limits by both user and network source so that account creation or address rotation does not remove the control.
Model output and other provider responses are data, not instructions. Sanitize text before rendering it as HTML. Validate any returned action parameters against a narrow schema and allowlist before execution. Give tools the least access needed, prefer read-only access, and record actions that can change data or spend money.
The request path below shows the shared control points for a client-to-provider feature. It keeps the client outside the trust boundary for secrets, business rules, and privileged actions.
flowchart LR
C[Client or app] --> V[Validate identity and input]
V --> L[Apply user and network limits]
L --> S[Server-side business rules]
S --> P[External provider]
P --> E[Verify and validate provider response]
E --> D[Update product state]
D --> C
Integration review sequence
A review starts with the data and authority that cross each boundary. It then checks that the product can reject false events, excessive use, and unsafe output before those inputs affect users or systems.
- Identify each client, provider, webhook, deep link, and privileged tool.
- Mark secrets, personal data, payment data, identity data, and provider responses that cross the boundary.
- Confirm that the server owns prices, permissions, account links, subscription state, and usage limits.
- Confirm that client calls and provider events have authentication or signature checks.
- Confirm that input and provider output use validation before storage, rendering, or action.
- Confirm that limits and alerts protect provider spend and resource use.
- Confirm that the product can revoke or rotate credentials without shipping a new client.
Cross-integration controls
Some controls apply to every external integration because they protect the shared boundary rather than one provider type.
| Control | Expected result |
|---|---|
| Secret placement | Private keys stay on the server and are not committed to source or bundled into clients. |
| Authority checks | The server decides identity, access, price, plan, and quota. |
| Input validation | Requests, callback values, deep-link parameters, and provider output match an allowed shape. |
| Event authenticity | Signed provider events are checked before they change product state. |
| Usage protection | Per-user limits, network limits, provider caps, and billing alerts reduce abuse and cost. |
| Output safety | External text and action parameters are treated as untrusted until checked. |
| Credential recovery | Secret rotation and client credential revocation do not depend on trusting the client. |
Change checklist
When these files or sections are changed, remember to consider these:
- When a new provider call is added, confirm that its secret stays server-side and that its client entry point has identity and usage checks.
- When a webhook or callback changes, preserve the raw body and keep signature verification before state changes.
- When a mobile or browser configuration value changes, classify it as public or private before exposing it to the client bundle.
- When a payment or subscription rule changes, keep the server-side provider record as the source for price and access decisions.
- When an AI tool or output path changes, review its allowlist, parameter validation, privilege, and rendering boundary together.
- When a provider or credential changes, confirm that rotation, spend limits, alerts, and failure behavior still work without a client update.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A client supplies a price, plan, role, or subscription flag | An attacker gets a cheaper purchase or unauthorized access | Resolve the value on the server and check current provider state. |
| A secret enters a browser or mobile bundle | Anyone can use the provider account or spend against it | Keep the call behind a server proxy and rotate exposed keys. |
| An unsigned or unverified provider event changes state | An attacker can grant access or attach activity to another account | Verify the provider signature and validate the event before updating state. |
| A deep link or callback performs an action from raw parameters | Another app or site can trigger an unsafe action | Validate parameters and require confirmation for destructive actions. |
| A model response renders as trusted content or calls a tool without checks | The response can cause script execution or an unauthorized data change | Sanitize output and validate tool calls against a least-privilege allowlist. |
| An expensive integration has no server-side quota | One user or bot can exhaust provider or cloud spend | Combine per-user and per-network limits with hard provider caps and alerts. |
Key files
| File | Why to read it |
|---|---|
| vibe-security/SKILL.md | Defines the overall review principle and places external integrations in the security audit sequence. |
| vibe-security/…/payments.md | Explains the server-owned payment values, signed webhook flow, and subscription source of truth. |
| vibe-security/…/mobile.md | Explains the client-bundle, token-storage, deep-link, and biometric trust boundaries. |
| vibe-security/…/ai-integration.md | Explains provider-key protection, spend limits, prompt injection, output handling, and tool controls. |
| vibe-security/…/secrets-and-env.md | Defines which configuration may be public and which credentials must remain private. |
| vibe-security/…/rate-limiting.md | Defines the abuse and spend controls for provider-backed endpoints. |