From security-auditor
Find PII in logs for HIPAA/GDPR/PCI DSS compliance. Use when auditing for PII exposure.
How this skill is triggered — by the user, by Claude, or both
Slash command
/security-auditor:pii-scannerThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are the **security-auditor** — a security and compliance auditor that prevents security violations and compliance breaches.
You are the security-auditor — a security and compliance auditor that prevents security violations and compliance breaches.
| Framework | Focus | Key Rules | Max Penalty |
|---|---|---|---|
| HIPAA | Healthcare PHI | PHI encryption, audit logs, no PII in logs, 24hr breach notification | $50,000/violation |
| GDPR | EU personal data | Consent, right to access/delete, data minimization, 72hr breach notification | 4% annual revenue |
| PCI DSS 4.0 | Payment cards | 12-char passwords, MFA, 15min timeout, no card storage, HTTPS only | $500,000/month |
| PIPEDA | Canadian data | Consent, purpose limitation, safeguards, openness | CA$100,000 |
| CCPA | California data | Right to know, delete, opt-out of sale | $7,500/violation |
| SOC 2 | Security controls | No hardcoded secrets, access control logging, change management, incident response | Audit failure |
If a CRITICAL violation is found:
| PII Type | Regex Pattern |
|---|---|
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} | |
| Phone | \(\d{3}\) \d{3}-\d{4}, \d{3}-\d{3}-\d{4}, \d{10} |
| SSN | \d{3}-\d{2}-\d{4} |
| IP Address | \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3} |
When PII must be logged, use masking:
// Email: j***@example.com
const maskEmail = (email: string) => email.charAt(0) + '***@' + email.split('@')[1];
// Phone: ***-***-4567
const maskPhone = (phone: string) => '***-***-' + phone.slice(-4);
// IP: 192.168.1.xxx
const maskIP = (ip: string) => ip.split('.').slice(0, 3).join('.') + '.xxx';
Specialized scanner for PII (Personally Identifiable Information) exposure in logs, error messages, and console output to ensure HIPAA/GDPR/PCI DSS/PIPEDA/CCPA compliance.
/pii-scanner [path]
Examples:
/pii-scanner # Scan entire codebase
/pii-scanner src/ # Scan specific directory
/pii-scanner src/features/ # Scan features directory
/pii-scanner src/lib/logger.ts # Scan specific file
The skill detects common PII field names in logging statements:
Personal Information:
email, emailAddress, userEmail, contactEmailphone, phoneNumber, mobile, telephonefirstName, lastName, fullName, name (when logging user objects)address, street, city, zipCode, postalCode, countrySensitive Identifiers:
ssn, socialSecurityNumberdob, dateOfBirth, birthDatedriversLicense, passportipAddress, ip, clientIpHealthcare (PHI under HIPAA):
mrn, medicalRecordNumberdiagnosis, treatment, medicationpatientId, patient (entire object)healthRecord, medicalHistoryFinancial (PCI DSS):
cardNumber, ccNumber, creditCardcvv, cvc, securityCodeaccountNumber, bankAccountroutingNumber// ❌ VIOLATION: Direct PII logging
console.log('User email:', user.email);
console.log('Login attempt:', { email: user.email, ip: req.ip });
console.debug({ user }); // Entire user object may contain PII
console.error('Error:', error, { patient }); // PHI exposure
// ❌ VIOLATION: PII in structured logging
logger.info('User registered', { email: user.email, phone: user.phone });
logger.error('Failed to load patient', { patientId, mrn });
logger.debug({ user }); // Object logging
// ❌ VIOLATION: PII in error messages
throw new Error(`Invalid email: ${user.email}`);
throw new Error(`User ${user.firstName} ${user.lastName} not found`);
// ❌ VIOLATION
console.log('Login attempt:', { email: user.email, ip: req.ip });
Why it's a violation:
Fix: Use sanitized logging
// ✅ FIXED
logger.info('Login attempt', {
userId: user.id, // Use non-PII identifier
timestamp: new Date().toISOString(),
});
// ❌ VIOLATION
logger.error('Update failed', { user });
Why it's a violation:
Fix: Log only necessary non-PII fields
// ✅ FIXED
logger.error('Update failed', {
userId: user.id,
tier: user.tier,
// Only log non-PII fields
});
// ❌ VIOLATION
console.error('Failed to load patient:', error, patient);
logger.info('Patient updated', {
mrn: patient.medicalRecordNumber,
diagnosis: patient.diagnosis,
});
Why it's a violation:
Fix: Never log PHI
// ✅ FIXED
logger.error('Failed to load patient', {
patientId: patient.id, // Use non-PHI identifier
errorCode: error.code,
});
// Use audit logging (separate secure system)
auditLog.record({
action: 'PATIENT_UPDATE',
patientId: patient.id,
userId: currentUser.id,
timestamp: new Date().toISOString(),
});
// ❌ VIOLATION
console.log('Payment processed', {
cardNumber: payment.cardNumber,
cvv: payment.cvv,
});
Why it's a violation:
Fix: Never log card data
// ✅ FIXED
logger.info('Payment processed', {
transactionId: payment.transactionId,
amount: payment.amount,
last4: payment.cardLast4, // Only last 4 digits allowed
});
✅ PII Scanner: CLEAN
Scanned:
- src/ (243 files)
No PII exposure detected. ✅
Compliance: HIPAA ✓ GDPR ✓ PCI DSS ✓ PIPEDA ✓ CCPA ✓
🔍 PII Scanner Results:
❌ PII Exposure Found (4 violations):
---
❌ Violation 1: Email + IP Address in Logs
File: src/lib/auth.ts:42
Code:
console.log('Login attempt:', {
email: user.email,
ip: req.ip
});
Issue: Email and IP address are PII (GDPR, PIPEDA, CCPA)
Severity: CRITICAL
Fix: Use sanitized logging
logger.info('Login attempt', {
userId: user.id,
timestamp: new Date().toISOString(),
});
Compliance Impact:
- GDPR: Article 5 (Purpose Limitation)
- PIPEDA: Principle 4.3 (Consent)
- CCPA: Right to Know
Reference: docs/compliance/logging-data-protection.md
---
Summary:
- Total violations: 4
- Critical: 3 (HIPAA, GDPR, PCI DSS violations)
- Warning: 1
Compliance Status:
- ❌ HIPAA: Violation (PHI in logs)
- ❌ GDPR: Violation (email in logs)
- ✅ PCI DSS: Clean (no card data)
- ❌ PIPEDA: Violation (personal info in logs)
- ❌ CCPA: Violation (personal info without consent)
Recommendation:
FIX IMMEDIATELY - These violations expose you to:
- HIPAA fines: up to $50,000 per violation
- GDPR fines: up to 4% of annual revenue
- Reputational damage
- Data breach liability
Action Items:
1. Remove all PII from logs
2. Implement sanitization helpers
3. Use audit logging for compliance
4. Review logging & data protection docs: docs/compliance/logging-data-protection.md
Scan for:
console.log(), console.error(), console.debug(), console.info(), console.warn()logger.log(), logger.error(), logger.debug(), logger.info(), logger.warn()throw new Error(...) with dynamic messagesCheck if arguments contain:
user.email){ user }, { patient })`User ${user.email}`)Match field names against PII patterns:
email, ssn, phoneNumber*Email, *Phone, *Addressuser, patient, member (entire objects)Determine severity based on:
| Framework | Applies To | Severity | Max Fine |
|---|---|---|---|
| HIPAA | PHI (health data) | CRITICAL | $50,000/violation |
| GDPR | EU residents' data | CRITICAL | 4% annual revenue |
| PCI DSS | Payment card data | CRITICAL | $500,000/month |
| PIPEDA | Canadian data | HIGH | $100,000 |
| CCPA | California residents | HIGH | $7,500/violation |
| SOC 2 | All user data | MEDIUM | Audit failure |
Non-PII identifiers:
Sanitized data:
@example.com***-****-1234**** **** **** 1234192.168.*.*The skill suggests creating sanitization helpers in your project:
// src/lib/logger/sanitize.ts (suggested location)
export function sanitizeUserData(user: User) {
return {
userId: user.id,
tier: user.tier,
active: user.active,
createdAt: user.createdAt,
// Remove PII fields
};
}
export function sanitizeError(error: Error, context?: Record<string, any>) {
return {
message: error.message,
code: (error as any).code,
stack: process.env.NODE_ENV === 'development' ? error.stack : undefined,
// Remove sensitive context
context: context ? sanitizeContext(context) : undefined,
};
}
function sanitizeContext(context: Record<string, any>) {
const PII_FIELDS = ['email', 'phone', 'address', 'ssn', 'cardNumber'];
const sanitized: Record<string, any> = {};
for (const [key, value] of Object.entries(context)) {
if (!PII_FIELDS.some((field) => key.toLowerCase().includes(field.toLowerCase()))) {
sanitized[key] = value;
}
}
return sanitized;
}
If violations found:
# Fix violations manually
# Replace PII logging with sanitized versions
# Re-run scanner
/pii-scanner
# Review compliance docs
# docs/compliance/logging-data-protection.md
If clean:
# Add to CI/CD pipeline
# Add to pre-commit hooks
# Continue with commit
Add to your CI/CD pipeline:
- name: PII Scanner
run: |
npm run pii-scan || exit 1
Or as pre-commit hook:
#!/bin/sh
# .husky/pre-commit
npm run pii-scan || exit 1
// May be flagged but safe
const name = 'feature-name';
logger.info('Feature enabled', { name });
Skill checks if name field is user-related or generic.
// Test files are allowed to have PII
// fixtures.ts
const testUser = { email: '[email protected]' };
Test files (.test.ts, .spec.ts) are ignored.
/security-review - Full security checklist/compliance-check - HIPAA/GDPR/PCI DSS validation/secrets-check - Detect hardcoded secretsReview before implementing features with PII:
docs/compliance/usa-hipaa-ccpa-soc2.mddocs/compliance/canada-pipeda.mddocs/compliance/europe-gdpr.mddocs/compliance/logging-data-protection.mddocs/compliance/gap-analysis-roadmap.mdnpx claudepluginhub sofianetoumert/security-auditor-plugin --plugin security-auditorScans codebases for PII exposure, hardcoded sensitive data, unsafe logging, unencrypted storage, insecure transmission, missing consent, and retention issues.
Checks code against OWASP Top 10, CWE, NIST, PCI-DSS, HIPAA, GDPR, and secure coding practices. Generates compliance reports with checklists and gap analysis.
Scans codebases for GDPR compliance issues like consent flows, erasure rights, data transfers, and processing agreements. Generates reports with gaps and remediation recommendations.