Privacy Audit
SecurityScan your app for privacy compliance issues. Checks data collection, consent management, personal data handling, data retention, cookie usage, and compliance with major privacy regulations in Europe, California, and beyond.
Skill prompt
Privacy Audit Skill
Perform a comprehensive privacy and data protection audit of a TypeScript codebase. All findings must reference specific files and line numbers, map to regulatory requirements (GDPR Article X, CCPA Section X), and include severity ratings.
Severity Ratings
- CRITICAL: Active violation likely to trigger regulatory enforcement (e.g., PII transmitted unencrypted, no consent mechanism, no deletion capability)
- HIGH: Significant compliance gap requiring prompt remediation (e.g., PII in logs, missing cookie flags, over-broad data collection)
- MEDIUM: Best-practice violation that increases risk (e.g., missing data retention policy, excessive API response fields)
- LOW: Minor improvement opportunity (e.g., missing audit trail for non-sensitive access, informational cookie without flag)
1. PII Detection
Scan the entire codebase for collection, storage, and transmission of personally identifiable information.
What to Search For
Checklist
- Inventory all PII fields in database schemas (ORM models, migration files, SQL definitions)
- Inventory all PII in API request/response types and interfaces
- Inventory all form fields collecting user data
- Identify PII transmitted in analytics/tracking events
- Verify PII classification labels exist (sensitivity level, data category)
- Check that PII fields have documented legal basis for collection
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| PII collected without documented purpose | GDPR | Article 5(1)(b) - Purpose limitation |
| PII collected without legal basis | GDPR | Article 6(1) - Lawfulness of processing |
| No PII inventory maintained | GDPR | Article 30 - Records of processing activities |
| PII collected from California residents without disclosure | CCPA | Section 1798.100(b) - Right to know |
2. Consent Management
Audit cookie consent implementation, consent-before-tracking enforcement, and opt-out mechanisms.
What to Search For
Checklist
- Cookie consent banner exists and blocks tracking until accepted
- Consent is obtained BEFORE any tracking scripts execute
- Opt-out mechanism is functional and accessible
- Consent state persists across sessions
- Granular consent categories exist (necessary, analytics, marketing, preferences)
- Consent withdrawal is as easy as giving consent
- Consent records are stored with timestamp and version
- Third-party scripts load only after relevant consent category is accepted
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| No consent obtained before tracking | GDPR | Article 7 - Conditions for consent |
| No granular consent categories | GDPR | Recital 43 - Freely given consent |
| No opt-out mechanism | CCPA | Section 1798.120 - Right to opt-out |
| Consent withdrawal harder than granting | GDPR | Article 7(3) - Right to withdraw consent |
| Pre-checked consent boxes | GDPR | Article 4(11) - Definition of consent (must be affirmative) |
Code Pattern: Consent-Gated Tracking
3. Data Minimization
Check for collection of excessive data, unnecessary storage, and PII leakage.
What to Search For
Checklist
- No
SELECT *on tables containing PII — use explicit column lists - API responses do not include unnecessary PII fields
- PII is not logged in application logs
- PII is not included in error messages or stack traces
- Data retention policies are defined and enforced programmatically
- Temporary data (uploads, caches) has expiration configured
- Form fields do not collect data unnecessary for the stated purpose
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| Collecting data beyond stated purpose | GDPR | Article 5(1)(c) - Data minimization |
| No data retention limits | GDPR | Article 5(1)(e) - Storage limitation |
| PII in application logs | GDPR | Article 5(1)(f) - Integrity and confidentiality |
| Excessive data collection without business need | CCPA | Section 1798.100(c) - Collect only what is necessary |
Code Pattern: Minimal Query Responses
In Convex, queries return whatever you send back from the handler. Returning the whole document leaks every field on it — including ones meant only for the server. Always pick out just the fields the client needs.
4. Third-Party Data Sharing
Audit analytics scripts, advertising pixels, social embeds, CDN exposure, and SDK data flows.
What to Search For
Checklist
- Inventory all third-party scripts loaded in the application
- Each third-party has a documented Data Processing Agreement (DPA)
- Third-party scripts are gated behind consent categories
- Data sent to third parties is minimized (no unnecessary PII)
- Social media embeds do not load until user interaction (two-click pattern)
- CDN requests include
crossorigin="anonymous"where applicable - Referrer-Policy header is set to limit data leakage to third parties
- Subresource Integrity (SRI) hashes on third-party scripts
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| PII shared with third party without consent | GDPR | Article 44-49 - Transfer of personal data |
| No DPA with third-party processor | GDPR | Article 28 - Processor agreements |
| Selling/sharing personal information without opt-out | CCPA | Section 1798.120 - Right to opt-out of sale |
| Third-party tracking without disclosure | CCPA | Section 1798.140(e) - Definition of business purpose |
5. Data Storage & Encryption
Audit PII encryption at rest, secure transmission, and sensitive data in client-side storage.
What to Search For
Checklist
- PII columns in database are encrypted at rest (application-level or database-level)
- All data transmission uses HTTPS — HTTP redirects to HTTPS
- HSTS header is configured with appropriate max-age
- Passwords are hashed with Argon2 or bcrypt (never MD5/SHA1/SHA256 alone)
- Encryption keys are managed securely (environment variables, KMS, vault)
- Sensitive data is not stored in localStorage or sessionStorage
- Database backups are encrypted
- API keys and secrets are not hardcoded in source
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| PII stored unencrypted | GDPR | Article 32 - Security of processing |
| Data transmitted over HTTP | GDPR | Article 5(1)(f) - Integrity and confidentiality |
| Passwords not properly hashed | GDPR | Article 32(1)(a) - Pseudonymisation and encryption |
| Sensitive data in client-side storage | GDPR | Article 25 - Data protection by design and by default |
Code Pattern: Encrypted PII Column
6. User Rights (GDPR / CCPA)
Audit data export, account deletion, data portability, access requests, and consent withdrawal.
What to Search For
Checklist
- Data export endpoint exists and returns all user data in machine-readable format (JSON/CSV)
- Account deletion fully removes or anonymizes all PII (including backups, logs, caches)
- Account deletion cascades to third-party services (analytics, email providers, CRMs)
- Data access request can be fulfilled within 30 days (GDPR) / 45 days (CCPA)
- Consent withdrawal mechanism exists and halts all non-essential processing
- Deleted accounts cannot be reconstructed from remaining data
- Soft-delete includes a hard-delete schedule (e.g., 30 days to final purge)
- Data portability format is interoperable (standard JSON schema)
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| No data export capability | GDPR | Article 20 - Right to data portability |
| No account deletion mechanism | GDPR | Article 17 - Right to erasure |
| No data access request process | GDPR | Article 15 - Right of access |
| Cannot fulfill access requests within 45 days | CCPA | Section 1798.130 - Timing of response |
| No opt-out of data sale | CCPA | Section 1798.120 - Right to opt-out |
| Deletion does not cascade to processors | GDPR | Article 17(2) - Inform processors of erasure |
Code Pattern: Account Deletion
7. Cookie & Tracking Audit
Inventory all cookies, check security flags, audit localStorage/sessionStorage, and detect fingerprinting.
What to Search For
Checklist
- Complete cookie inventory with purpose, duration, and category
- All session cookies use
Secure,HttpOnly, andSameSite=Strict(orLax) - Session cookies have appropriate expiration (not excessively long)
- Persistent cookies have justified retention periods
- No sensitive data (tokens, PII) in localStorage or sessionStorage
- No browser fingerprinting without explicit consent
- Cookie names do not reveal technology stack or internal identifiers
- Third-party cookies are inventoried and consent-gated
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| Non-essential cookies set without consent | GDPR | Article 5(3) ePrivacy Directive |
| Cookies missing Secure/HttpOnly flags | GDPR | Article 32 - Security of processing |
| Browser fingerprinting without consent | GDPR | Recital 30 - Online identifiers |
| No cookie inventory disclosed to users | GDPR | Article 13 - Information to be provided |
Code Pattern: Secure Cookie Configuration
8. Logging & Monitoring
Audit logs for PII leakage, retention policies, access logging, and audit trails.
What to Search For
Checklist
- No PII appears in application logs (use redaction/masking)
- Log retention policy is defined and enforced (auto-rotation/deletion)
- Access to sensitive data is logged with user identity and timestamp
- Audit trail exists for PII access, modification, and deletion
- Log files are not publicly accessible
- Log aggregation services (Datadog, Sentry, etc.) have PII scrubbing configured
- Stack traces in production do not expose PII
- Structured logging format used (not string interpolation of user data)
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| PII in application logs | GDPR | Article 5(1)(f) - Integrity and confidentiality |
| No log retention policy | GDPR | Article 5(1)(e) - Storage limitation |
| No audit trail for PII access | GDPR | Article 30 - Records of processing activities |
| Logs accessible without access control | GDPR | Article 32 - Security of processing |
Code Pattern: PII-Safe Logging
9. API Privacy
Audit API responses for unnecessary data, missing field-level permissions, over-fetching, and caching of sensitive data.
What to Search For
Checklist
- API responses include only fields necessary for the client
- Sensitive fields are excluded from default serialization (use allowlists, not denylists)
- GraphQL queries cannot fetch arbitrary depth/breadth of PII
- API responses containing PII use
Cache-Control: no-store - Field-level permissions enforce who can see which fields
- Pagination limits prevent bulk data extraction
- API rate limiting prevents enumeration attacks
- Response schemas are documented and reviewed for data exposure
Regulatory Mapping
| Finding | Regulation | Reference |
|---|---|---|
| API returns unnecessary PII | GDPR | Article 5(1)(c) - Data minimization |
| No field-level access control on PII | GDPR | Article 25 - Data protection by design |
| PII cached in CDN or shared cache | GDPR | Article 32 - Security of processing |
| Bulk data extraction possible | CCPA | Section 1798.150 - Personal information security |
| No rate limiting on PII endpoints | GDPR | Article 32(1)(b) - Ability to ensure ongoing confidentiality |
Code Pattern: Privacy-Safe Convex Query
In a Hercules app, the signed-in user comes from Hercules Auth via ctx.auth.getUserIdentity(). Throw a ConvexError so the client can handle the failure cleanly.
Audit Output Format
Structure audit findings as follows:
- Recommended Fix:
Compliance Matrix
| Regulation | Requirement | Status | Finding Reference |
|---|---|---|---|
| GDPR Art. 5(1)(c) | Data minimization | FAIL | #3 |
| GDPR Art. 7 | Consent | PASS | - |
| CCPA 1798.120 | Opt-out of sale | FAIL | #7 |