customerio-security-basics
Customer.ioのセキュリティベストプラクティスを適用します。セキュアな統合の実装、個人情報(PII)の取り扱い、適切なアクセス制御の設定が必要な場合に活用できます。「customer.io security」「customer.io pii」「secure customer.io」「customer.io gdpr」といったフレーズで起動されます。
description の原文を見る
Apply Customer.io security best practices. Use when implementing secure integrations, handling PII, or setting up proper access controls. Trigger with phrases like "customer.io security", "customer.io pii", "secure customer.io", "customer.io gdpr".
SKILL.md 本文
Customer.io セキュリティ基礎
概要
認証情報管理、PII処理、アクセス制御を含むCustomer.io統合のセキュリティベストプラクティスを実装します。
前提条件
- 管理者アクセス権付きのCustomer.ioアカウント
- データ分類の理解
- 環境変数管理
手順
ステップ1: セキュアな認証情報管理
// lib/secrets.ts
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
// Use a secrets manager instead of env vars for production
async function getCustomerIOCredentials(): Promise<{
siteId: string;
apiKey: string;
}> {
// Option 1: Google Cloud Secret Manager
const client = new SecretManagerServiceClient();
const [siteIdVersion] = await client.accessSecretVersion({
name: 'projects/PROJECT_ID/secrets/customerio-site-id/versions/latest'
});
const [apiKeyVersion] = await client.accessSecretVersion({
name: 'projects/PROJECT_ID/secrets/customerio-api-key/versions/latest'
});
return {
siteId: siteIdVersion.payload?.data?.toString() || '',
apiKey: apiKeyVersion.payload?.data?.toString() || ''
};
}
// Option 2: AWS Secrets Manager
import { SecretsManager } from '@aws-sdk/client-secrets-manager';
async function getCredentialsFromAWS() {
const client = new SecretsManager({ region: 'us-east-1' });
const response = await client.getSecretValue({
SecretId: 'customerio-credentials'
});
return JSON.parse(response.SecretString || '{}');
}
ステップ2: PIIデータ処理
// lib/pii-handler.ts
import crypto from 'crypto';
// Hash sensitive identifiers before sending
function hashPII(value: string): string {
return crypto
.createHash('sha256')
.update(value + process.env.PII_SALT)
.digest('hex');
}
// Sanitize attributes before sending to Customer.io
function sanitizeUserAttributes(attributes: Record<string, any>): Record<string, any> {
const sensitiveFields = ['ssn', 'credit_card', 'password', 'bank_account'];
const piiFields = ['phone', 'address', 'date_of_birth'];
const sanitized = { ...attributes };
// Remove highly sensitive fields
for (const field of sensitiveFields) {
delete sanitized[field];
}
// Hash PII fields if needed for matching but not display
for (const field of piiFields) {
if (sanitized[field]) {
sanitized[`${field}_hash`] = hashPII(sanitized[field]);
// Optionally remove plain text version
// delete sanitized[field];
}
}
return sanitized;
}
// Usage
const safeAttributes = sanitizeUserAttributes({
email: 'user@example.com',
phone: '+1234567890',
ssn: '123-45-6789', // Will be removed
plan: 'premium'
});
ステップ3: APIキーのローテーション
// scripts/rotate-api-key.ts
async function rotateAPIKey(): Promise<void> {
console.log('API Key Rotation Checklist:');
console.log('1. Generate new API key in Customer.io dashboard');
console.log('2. Update secrets manager with new key');
console.log('3. Deploy application with new key');
console.log('4. Verify integration works with new key');
console.log('5. Revoke old API key in dashboard');
console.log('6. Update documentation');
// Automated rotation (if using secrets manager)
// 1. Create new key via API (if supported)
// 2. Update secret in manager
// 3. Wait for propagation
// 4. Revoke old key
}
// Schedule rotation every 90 days
// Add to cron or scheduled task
ステップ4: Webhookセキュリティ
// lib/webhook-security.ts
import crypto from 'crypto';
import { Request, Response, NextFunction } from 'express';
// Verify Customer.io webhook signatures
function verifyWebhookSignature(
payload: string,
signature: string,
secret: string
): boolean {
const expectedSignature = crypto
.createHmac('sha256', secret)
.update(payload)
.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expectedSignature)
);
}
// Express middleware for webhook verification
export function webhookAuthMiddleware(webhookSecret: string) {
return (req: Request, res: Response, next: NextFunction) => {
const signature = req.headers['x-cio-signature'] as string;
if (!signature) {
return res.status(401).json({ error: 'Missing signature' });
}
const payload = JSON.stringify(req.body);
if (!verifyWebhookSignature(payload, signature, webhookSecret)) {
return res.status(401).json({ error: 'Invalid signature' });
}
next();
};
}
// Usage
app.post('/webhooks/customerio',
webhookAuthMiddleware(process.env.CUSTOMERIO_WEBHOOK_SECRET!),
(req, res) => {
// Handle verified webhook
}
);
ステップ5: アクセス制御
// lib/access-control.ts
interface TeamMember {
email: string;
role: 'admin' | 'editor' | 'viewer';
permissions: string[];
}
// Recommended role-based access
const rolePermissions = {
admin: [
'manage_api_keys',
'manage_team',
'manage_integrations',
'view_all_data',
'send_campaigns'
],
editor: [
'create_campaigns',
'edit_campaigns',
'view_analytics',
'manage_segments'
],
viewer: [
'view_campaigns',
'view_analytics'
]
};
// Audit logging for security-sensitive operations
function logSecurityEvent(event: {
action: string;
actor: string;
resource: string;
details?: Record<string, any>;
}) {
console.log(JSON.stringify({
type: 'security_audit',
timestamp: new Date().toISOString(),
...event
}));
}
ステップ6: データ保持
// lib/data-retention.ts
import { APIClient } from '@customerio/track';
// Suppress/delete users for GDPR/CCPA compliance
async function deleteUserData(client: APIClient, userId: string) {
// 1. Suppress the user (stops all messaging)
await client.suppress(userId);
// 2. Request full deletion through Customer.io dashboard or API
// Note: Full deletion may require support ticket
console.log(`User ${userId} suppressed and deletion requested`);
}
// Anonymous historical data retention
function anonymizeForAnalytics(userData: Record<string, any>) {
return {
...userData,
email: undefined,
phone: undefined,
first_name: undefined,
last_name: undefined,
// Keep aggregated/analytical data
plan: userData.plan,
signup_date: userData.created_at,
total_events: userData.event_count
};
}
セキュリティチェックリスト
- APIキーがシークレットマネージャーに保存されている(コード内の環境変数ではない)
- APIキーが90日ごとにローテーションされている
- Webhook署名が検証されている
- PII が送信前にサニタイズされている
- 最小限の必要なデータのみがCustomer.ioに送信されている
- チームアクセスが最小権限の原則に従っている
- 機密操作に対する監査ログが有効になっている
- GDPR/CCPA削除プロセスが文書化されている
- すべてのAPI呼び出しでSSL/TLSが強制されている
エラーハンドリング
| 問題 | 解決方法 |
|---|---|
| 認証情報の漏洩 | 直ちにローテーション、アクセスを監査 |
| PII漏洩 | Customer.ioから削除、DPO に通知 |
| 不正アクセス | アクセスログを確認、アクセスを取り消し |
リソース
次のステップ
セキュリティ実装後、customerio-prod-checklist に進んで本番環境対応を確認してください。
ライセンス: MIT(寛容ライセンスのため全文を引用しています) · 原本リポジトリ
詳細情報
- 作者
- Brmbobo
- リポジトリ
- Brmbobo/Web2podcast
- ライセンス
- MIT
- 最終更新
- 2026/1/26
Source: https://github.com/Brmbobo/Web2podcast / ライセンス: MIT
関連スキル
secure-code-guardian
認証・認可の実装、ユーザー入力の保護、OWASP Top 10の脆弱性対策が必要な場合に使用します。bcrypt/argon2によるパスワードハッシング、パラメータ化ステートメントによるSQLインジェクション対策、CORS/CSPヘッダーの設定、Zodによる入力検証、JWTトークンの構築などのカスタムセキュリティ実装に対応します。認証、認可、入力検証、暗号化、OWASP Top 10対策、セッション管理、セキュリティ強化全般で活用できます。ただし、構築済みのOAuth/SSO統合や単独のセキュリティ監査が必要な場合は、より特化したスキルの検討をお勧めします。
claude-authenticity
APIエンドポイントが本物のClaudeによって支えられているか(ラッパーやプロキシ、偽装ではないか)を、claude-verifyプロジェクトを模した9つの重み付きルールベースチェックで検証できます。また、Claudeの正体を上書きしているプロバイダーから注入されたシステムプロンプトも抽出します。完全に自己完結しており、httpx以外の追加パッケージは不要です。Claude APIキーまたはエンドポイントを検証したい場合、サードパーティのClaudeサービスが本物か確認したい場合、APIプロバイダーのClaude正当性を監査したい場合、複数モデルを並行してテストしたい場合、またはプロバイダーが注入したシステムプロンプトを特定したい場合に使用できます。
anth-security-basics
Anthropic Claude APIのセキュリティベストプラクティスを適用し、キー管理、入力値の検証、プロンプトインジェクション対策を実施します。APIキーの保護、Claudeに送信する前のユーザー入力検証、コンテンツセーフティガードレールの実装が必要な場合に活用できます。「anthropic security」「claude api key security」「secure anthropic」「prompt injection defense」といったフレーズでトリガーされます。
x-ray
x-ray.mdプレ監査レポートを生成します。概要、強化された脅威モデル(プロトコルタイプのプロファイリング、Gitの重み付け攻撃面分析、時間軸リスク分析、コンポーザビリティ依存関係マッピング)、不変条件、統合、ドキュメント品質、テスト分析、開発者・Gitの履歴をカバーしています。「x-ray」「audit readiness」「readiness report」「pre-audit report」「prep this protocol」「protocol prep」「summarize this protocol」のキーワードで実行されます。
semgrep
Semgrepスタティック分析スキャンを実行し、カスタム検出ルールを作成します。Semgrepでのコードスキャン、セキュリティ脆弱性の検出、カスタムYAMLルールの作成、または特定のバグパターンの検出が必要な場合に使用します。重要:ユーザーが「バグをスキャンしたい」「コード品質を確認したい」「脆弱性を見つけたい」「スタティック分析」「セキュリティlint」「コード監査」または「コーディング標準を適用したい」と尋ねた場合も、Semgrepという名称を明記していなくても、このスキルを使用してください。Semgrepは30以上の言語に対応したパターンベースのコードスキャンに最適なツールです。
ghost-bits-cast-attack
Java「ゴーストビッツ」/キャストアタック プレイブック(Black Hat Asia 2026)。16ビット文字が8ビットバイトに暗黙的に縮小されるJavaサービスへの攻撃時に使用します。WAF/IDSを回避して、SQLインジェクション、デシリアライゼーション型RCE、ファイルアップロード(Webシェル)、パストトラバーサル、CRLF インジェクション、リクエストスマグリング、SMTPインジェクションを実行できます。Tomcat、Spring、Jetty、Undertow、Vert.x、Jackson、Fastjson、Apache Commons BCEL、Apache HttpClient、Angus Mail、JDK HttpServer、Lettuce、Jodd、XMLWriterに影響し、WAFバイパスにより多くの「パッチ済み」CVEを再度有効化します。