Skip to main content
skill CX Codex GP ChatGPT official · OpenAI

twilio-security-hardening — Codex skill: what it does, how to install

Hardens Twilio apps against credential leaks, toll fraud, and compliance risks under PCI DSS or HIPAA. Useful when building and deploying production telephony or messaging.

Install into Codex · Skills CLI (Vercel) All methods and platforms ↓
npx skills add openai/plugins --skill twilio-security-hardening -a codex
Open on GitHub

What twilio-security-hardening does

The skill guides coding agents through hardening Twilio infrastructure against credential theft and spoofing. It enforces individual API keys over the master Auth Token for server environments. Rotating the primary Auth Token instantly revokes every active API key across the entire project. To prevent catastrophic outages, the guide insists on scoped keys and verifies incoming X-Twilio-Signature headers with the official SDK.

Compliance decisions also demand caution. Enabling account-wide PCI Mode is permanent. Once activated, you cannot disable it. The skill instructs you to isolate payment operations into dedicated sub-accounts, pause recording during card intake, or offload processing to the <Pay> verb. For healthcare builds bound by HIPAA, it covers BAA execution and patient data minimization in <Say> prompts.

To counter SMS pumping attacks, the skill configures layered defenses. It couples country-level geo-permissions with line-type intelligence lookups and strict verification rate limits.

What it helps with

  • verify inbound webhooks via X-Twilio-Signature validation
  • block toll fraud and SMS pumping using geo-permissions
  • rotate API credentials with zero service downtime
  • isolate cardholder data into sub-accounts for PCI DSS

Example prompts for the agent

  • Validate inbound Twilio webhooks in Node.js using request signatures.
  • Set up SMS pumping prevention with geo-permissions and rate limits.
  • Draft a zero-downtime rotation plan for Twilio API keys.

How to install twilio-security-hardening

1Skills CLI (Vercel)

npx skills add openai/plugins --skill twilio-security-hardening -a codex

2Manually: put the files in place

.agents/skills/twilio-security-hardening/SKILL.md

For all projects use ~/.agents/skills/

Step by step, with commands for each platform: Codex skills: how to install, where they live, how to call them

Questions about twilio-security-hardening

How do I install twilio-security-hardening in Codex?

Run npx skills add openai/plugins --skill twilio-security-hardening -a codex. The skill file is saved to .agents/skills/twilio-security-hardening/SKILL.md.

Why avoid using the Twilio Auth Token in production?

The Auth Token holds global permissions. Rotating it immediately invalidates all existing API keys, which can break live integrations simultaneously.

Why should PCI Mode be restricted to sub-accounts?

Turning on PCI Mode affects the whole account and is completely irreversible. Creating a dedicated sub-account keeps standard voice and SMS workflows separate from payment constraints.

Source text

SKILL.md · MIT
---
name: twilio-security-hardening
description: >
  Secure Twilio applications against common attacks. Covers credential
  management (API keys vs auth tokens), request validation (webhook
  signature verification), PCI DSS compliance, HIPAA account requirements,
  SMS pumping prevention, geo-permissions, and account isolation patterns.
  Use this skill when developers are building or deploying Twilio apps.
---

## Overview

Security hardening is an **ongoing** concern — not a one-time setup. This skill covers account-level security decisions and application-level protection patterns that prevent credential leaks, fraud, and compliance violations.

**Lifecycle:** Choose numbers (`twilio-numbers-senders`) → Register (`twilio-compliance-onboarding`) → Follow traffic rules (`twilio-compliance-traffic`) → Secure everything (this skill)

---

## Credential Management

### API Keys vs Auth Tokens

| Credential | Scope | Revocable | Use when |
|-----------|-------|-----------|----------|
| **Auth Token** | Full account access | Only by rotating (invalidates ALL API keys) | Never in production — use API keys instead |
| **API Key + Secret** | Scoped, revocable individually | Yes — revoke one without affecting others | Production applications, CI/CD, server-side code |
| **Access Tokens** | Short-lived, client-specific | Expire automatically | Client-side SDKs (Voice, Video, Conversations) |

**Critical gotcha:** Rotating your Auth Token **invalidates ALL existing API keys**. This is a one-way door that can break every integration simultaneously. Use API keys from the start so you never need to rotate the Auth Token.

### Best Practices

- Store credentials in environment variables or a secrets manager — never in code
- Use different API keys per application/environment
- Rotate API keys on a schedule (quarterly minimum, monthly for HIPAA)
- Use sub-accounts to isolate customer credentials for ISV platforms — see `twilio-account-setup`

**Docs:** See `twilio-iam-auth-setup` for full credential setup patterns.

---

## Request Validation (Webhook Security)

Verify that webhook requests actually come from Twilio — not spoofed by attackers.

### X-Twilio-Signature Validation

Always use the SDK validator — don't implement HMAC-SHA1 manually:

**Node.js**
```javascript
const twilio = require("twilio");

app.post("/sms", (req, res) => {
    const valid = twilio.validateRequest(
        process.env.TWILIO_AUTH_TOKEN,
        req.headers["x-twilio-signature"],
        `https://yourdomain.com/sms`,
        req.body
    );
    if (!valid) return res.status(403).send("Forbidden");
    // Process webhook...
});
```

**Common mistakes:**
- Using HTTP URL when Twilio sends to HTTPS (URL must match exactly)
- Forgetting to include query string parameters in validation URL
- Not validating in production because "it worked in dev without it"

**Docs:** See `twilio-webhook-architecture` for full webhook security patterns.

---

## Account-Level Compliance

### PCI DSS (Payment Card Industry)

**PCI Mode is IRREVERSIBLE and account-wide.** Once enabled, it cannot be disabled — ever.

- All recordings are encrypted
- Transcript access is restricted
- Affects every service on the account

**Recommendation:** If you need PCI compliance for one use case, create a **separate sub-account** dedicated to payment-related calls. See `twilio-account-setup` for sub-account patterns.

For call recording during payment, pause recording when the customer gives card numbers:
```python
client.calls(call_sid).recordings(recording_sid).update(status="paused")
```

Or use the `<Pay>` verb to handle payments without your application touching card data:
```xml
<Pay paymentConnector="stripe_connector" chargeAmount="49.99" currency="usd" />
```

### HIPAA (Healthcare)

Before handling Protected Health Information (PHI):
- **Execute a BAA** (Business Associate Agreement) with Twilio — contact your account manager or [submit a sales request](https://www.twilio.com/en-us/help/sales) if you don't have one
- **Encrypt all recordings** containing PHI
- **Minimize PHI in TTS** — don't speak full patient details via `<Say>`
- **Rotate API keys** on a regular schedule
- **Restrict access** to recordings and transcripts

---

## Fraud Prevention

### SMS Pumping Protection

Attackers trigger thousands of OTP messages to premium-rate numbers, generating toll charges.

**Layered defense:**
1. **Twilio Verify Fraud Guard** — built-in fraud detection (enable on Verify Service)
2. **Lookup pre-check** — call `twilio-lookup-phone-intelligence` to check line type + SMS pumping risk score before sending
3. **Geo-permissions** — restrict SMS/voice to countries where you have customers ([Console > Messaging > Geo Permissions](https://console.twilio.com))
4. **Rate limiting** — limit verification attempts per IP, per phone number, per time window

### Geo-Permissions

Restrict which countries can receive messages or calls from your account:
- Disable all countries you don't serve (SMS and Voice separately)
- Re-enable only as needed — [configure in Console](https://www.twilio.com/docs/messaging/guides/sms-geo-permissions)
- This is the single most effective anti-fraud measure for SMS pumping

**SMS pumping impact:** Incidents can climb into tens of thousands of dollars. Twilio does not publish most-targeted prefixes — the general guidance is to restrict message termination to countries where you do business via geo-permissions. Customers using Fraud Guard can view estimated fraud savings in their [Fraud Guard reports](https://www.twilio.com/docs/verify/preventing-toll-fraud/sms-fraud-guard).

---

## Common Mistakes

1. **Auth Token in code** — Pushed to GitHub, leaked. Use environment variables + API keys.
2. **No webhook validation** — Attackers can send fake webhook requests to your endpoints.
3. **PCI Mode on main account** — Irreversible. Use a sub-account for payment use cases.
4. **No geo-permissions** — Account is open to SMS pumping from any country.
5. **Auth Token rotation without planning** — Breaks all API keys simultaneously.

---

## Credential Rotation (Zero-Downtime)

Both API keys and Auth Tokens follow the same workflow:

1. **Create secondary** — generate a new API key (or note the new Auth Token)
2. **Operationalize secondary** — deploy the new credential to all services
3. **Promote secondary to primary** — verify all traffic uses the new credential
4. **Delete old primary** — revoke the previous credential

Manage keys at: `https://console.twilio.com/account/keys-credentials/api-keys` (per account).

**Key enabler: use a secrets manager** (AWS Secrets Manager, HashiCorp Vault, etc.) to inject credentials at runtime. This makes rotation near-instantaneous with no downtime — no code changes, no redeployments. Organizations that hard-code credentials into repos, deployment scripts, or `.env` files must manually update every location before deleting the old key.

For ISVs managing many sub-accounts, automate this with the API Keys REST API across accounts.

---

## Next Steps

- **Credential setup and API key management:** `twilio-iam-auth-setup`
- **Webhook security and signature validation:** `twilio-webhook-architecture`
- **Account structure and sub-accounts:** `twilio-account-setup`
- **Phone intelligence for fraud scoring:** `twilio-lookup-phone-intelligence`
- **Traffic compliance rules:** `twilio-compliance-traffic`

© Twilio · MIT · openai/plugins

Similar skills

All skills for Security →

From the same set596

The whole set →
twilio-sendgrid-email-settings Configure SendGrid templates, email tracking, and branded links with this skill. Use it when changing message content or delivery settings. CX Codex GP ChatGPT ★ 7,604repo stars twilio-sendgrid-email-send A skill that shows the agent how to send mail through the SendGrid v3 Mail Send API: single sends, batch sends with templates, scheduled sends and attachments. Requires an SG-prefixed API key. CX Codex GP ChatGPT ★ 7,604repo stars twilio-sendgrid-deliverability-advisor Diagnoses SendGrid email delivery issues, spam placement, and domain blocks. Guides senders through authentication checks and automated IP warmup routines. CX Codex GP ChatGPT ★ 7,604repo stars twilio-sendgrid-account-setup Prepares SendGrid for email delivery with API keys, sender checks, domain authentication, and SDK setup. Use it before other SendGrid skills. CX Codex GP ChatGPT ★ 7,604repo stars twilio-security-compliance-hipaa This skill walks through preparing Twilio for HIPAA workflows, from BAA and project designation to product-specific limits. Use it when building healthcare features that handle PHI. CX Codex GP ChatGPT ★ 7,604repo stars twilio-security-api-auth Walks you through Twilio's four auth methods and helps you wire up the right one before shipping API calls to production. CX Codex GP ChatGPT ★ 7,604repo stars twilio-reliability-patterns Codex and ChatGPT skill detailing Twilio production reliability patterns: handling 429 rate limits, managing number throughput, and receiving StatusCallbacks safely. CX Codex GP ChatGPT ★ 7,604repo stars twilio-regulatory-compliance-bundles Prepare Twilio Regulatory Bundles for international numbers, from checking country rules to submitting a bundle for review. CX Codex GP ChatGPT ★ 7,604repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor