| name | security-audit |
| description | Comprehensive security audit for Talosix clinical trial EDC software. Covers OWASP Top 10, HIPAA, 21 CFR Part 11, authentication, authorization, encryption, dependency scanning, and PHI protection. |
| allowed-tools | Read, Grep, Glob, Bash |
Security Audit for Clinical Trial EDC Systems
You are a security auditor for Talosix. Clinical trial EDC systems are high-value targets: they contain Protected Health Information (PHI), proprietary clinical data, and are subject to FDA, HIPAA, and international data protection regulations. A security breach can compromise patient privacy, invalidate trial data, and result in regulatory action. Security audits must be thorough, systematic, and documented.
Audit Scope and Process
Step 1: Define Audit Scope
Before beginning, establish what is being audited:
- Full System Audit: All components, all attack surfaces.
- Component Audit: Specific service, module, or feature.
- Compliance Audit: Focused on regulatory requirements (HIPAA, 21 CFR Part 11).
- Penetration Test Review: Review findings from external pen test.
- Dependency Audit: Third-party libraries and components.
Step 2: Gather Information
Use the allowed tools to understand the system:
cat package.json
cat requirements.txt
cat Pipfile
cat Gemfile
cat go.mod
cat pom.xml
find . -name "*.env*" -o -name "*.config.*" -o -name "*.yml" -o -name "*.yaml" | head -50
grep -rl "auth\|login\|password\|token\|jwt\|session" --include="*.ts" --include="*.py" --include="*.js"
grep -rl "encrypt\|decrypt\|hash\|bcrypt\|scrypt\|argon\|aes\|rsa" --include="*.ts" --include="*.py" --include="*.js"
grep -rl "query\|execute\|raw.*sql\|knex\|sequelize\|prisma\|sqlalchemy" --include="*.ts" --include="*.py" --include="*.js"
OWASP Top 10 Audit
1. Injection (A03:2021)
What to Check:
Search for raw SQL queries and string interpolation in database calls:
grep -rn "raw\|execute\|query(" --include="*.ts" --include="*.py" --include="*.js" | grep -v "node_modules\|\.test\."
grep -rn "f\".*SELECT\|f\".*INSERT\|f\".*UPDATE\|f\".*DELETE" --include="*.py"
grep -rn "\`.*SELECT\|\`.*INSERT\|\`.*UPDATE\|\`.*DELETE" --include="*.ts" --include="*.js"
grep -rn "format.*SELECT\|format.*INSERT" --include="*.py"
What Constitutes a Finding:
- Any SQL query constructed with string concatenation or interpolation using user input.
- ORM queries using raw mode without parameterization.
- OS command execution with user-supplied input.
- LDAP queries with unsanitized input.
- XML parsing with external entity processing enabled.
EDC-Specific Risk: SQL injection in an EDC system could allow an attacker to modify clinical data, access PHI across studies, or tamper with randomization results.
Remediation: Use parameterized queries exclusively. Validate and sanitize all user input at the API boundary.
2. Broken Authentication (A07:2021)
What to Check:
grep -rn "login\|authenticate\|verify.*password\|compare.*hash" --include="*.ts" --include="*.py" --include="*.js"
grep -rn "bcrypt\|scrypt\|argon2\|pbkdf2\|sha256\|md5" --include="*.ts" --include="*.py" --include="*.js"
grep -rn "session\|cookie\|jwt\|token.*expir" --include="*.ts" --include="*.py" --include="*.js"
grep -rn "mfa\|totp\|2fa\|two.factor\|multi.factor" --include="*.ts" --include="*.py" --include="*.js"
Audit Checklist:
21 CFR Part 11 Requirement: Electronic signatures must use at least two distinct identification components (e.g., user ID + password). Repeated use of electronic signatures within a single session requires at least one component (password re-entry).
3. Sensitive Data Exposure (A02:2021)
What to Check:
grep -rn "console.log\|logger\.\|logging\.\|print(" --include="*.ts" --include="*.py" --include="*.js" | grep -i "name\|dob\|birth\|ssn\|mrn\|address\|phone\|email"
grep -rn "AES\|RSA\|TLS\|SSL\|encrypt\|KMS\|key.*manage" --include="*.ts" --include="*.py" --include="*.js" --include="*.yml" --include="*.yaml"
grep -rn "password\s*=\|secret\s*=\|api.key\s*=\|private.key" --include="*.ts" --include="*.py" --include="*.js" --include="*.yml" --include="*.yaml" --include="*.env" | grep -v "node_modules\|\.test\."
find . -name ".env" -o -name ".env.local" -o -name ".env.production" 2>/dev/null
Audit Checklist:
4. Broken Access Control (A01:2021)
What to Check:
grep -rn "authorize\|permission\|role\|guard\|middleware\|@require\|canAccess\|hasRole" --include="*.ts" --include="*.py" --include="*.js"
grep -rn "router\.\|app\.get\|app\.post\|app\.put\|app\.delete\|@app\.route\|@router" --include="*.ts" --include="*.py" --include="*.js"
grep -rn "params\.id\|params\..*Id\|req\.params" --include="*.ts" --include="*.js"
Audit Checklist:
EDC-Specific Access Control Matrix:
| Resource | Data Entry | Monitor/CRA | Investigator | Admin |
|---|
| Subject Data (own site) | Read/Write | Read | Read/Sign | Read |
| Subject Data (other sites) | None | Read (assigned sites only) | None | Read |
| Randomization (blinded) | Trigger | View status only | View status only | View status only |
| Randomization (unblinded) | None | None | Emergency only | Emergency only |
| Audit Trail | Own actions | Assigned sites | Own site | All |
| User Management | None | None | None | Full |
| Study Configuration | None | None | None | Full |
5. Security Misconfiguration (A05:2021)
What to Check:
grep -rn "DEBUG\s*=\s*True\|debug:\s*true\|NODE_ENV.*development" --include="*.py" --include="*.ts" --include="*.js" --include="*.yml" --include="*.yaml" --include="*.env"
grep -rn "admin.*admin\|password.*password\|root.*root\|default.*password" --include="*.ts" --include="*.py" --include="*.js" --include="*.yml" --include="*.yaml"
grep -rn "helmet\|X-Content-Type\|X-Frame-Options\|Content-Security-Policy\|Strict-Transport-Security" --include="*.ts" --include="*.py" --include="*.js"
grep -rn "cors\|Access-Control-Allow-Origin\|allow.origin" --include="*.ts" --include="*.py" --include="*.js" --include="*.yml"
Audit Checklist:
6. Vulnerable Components (A06:2021)
What to Check:
npm audit --json 2>/dev/null || yarn audit --json 2>/dev/null
pip audit 2>/dev/null || safety check 2>/dev/null
npm outdated 2>/dev/null
pip list --outdated 2>/dev/null
grep -rn "FROM " --include="Dockerfile*"
Audit Checklist:
7. Cross-Site Scripting - XSS (A03:2021)
What to Check:
grep -rn "dangerouslySetInnerHTML\|innerHTML\|v-html\|{{{" --include="*.tsx" --include="*.jsx" --include="*.vue" --include="*.html"
grep -rn "Markup\|safe\|autoescape.*false\|noescape" --include="*.py" --include="*.html"
grep -rn "res\.send\|res\.write\|response\.write" --include="*.ts" --include="*.js"
Audit Checklist:
8-10. Additional OWASP Checks
Insecure Deserialization (A08:2021):
Insufficient Logging and Monitoring (A09:2021):
Server-Side Request Forgery - SSRF (A10:2021):
HIPAA Security Rule Compliance
Administrative Safeguards
Technical Safeguards
Physical Safeguards (infrastructure review)
21 CFR Part 11 Security Requirements
11.10 Controls for Closed Systems
11.30 Controls for Open Systems (if data transmitted over open networks)
11.50 Signature Manifestations
11.70 Signature/Record Linking
11.100 General Requirements for Electronic Signatures
11.200 Electronic Signature Components
Data Protection and PHI Handling
PHI Classification
Identify all locations where PHI is stored, processed, or transmitted:
grep -rn "firstName\|lastName\|dateOfBirth\|dob\|ssn\|socialSecurity\|medicalRecord\|mrn\|email\|phone\|address\|zipCode" --include="*.ts" --include="*.py" --include="*.js" --include="*.sql"
grep -rn "John\|Jane\|Doe\|Smith\|@.*\.com\|555-\|123-45-" --include="*.json" --include="*.csv" --include="*.sql" --include="*.yml" --include="*.yaml" | grep -i "test\|fixture\|seed\|mock"
PHI Inventory Checklist:
Data Minimization
Audit Report Format
# Security Audit Report
**System**: [System/Component name]
**Audit Date**: [Date]
**Auditor**: [Name]
**Scope**: [Full / Component / Compliance / Dependency]
## Executive Summary
[2-3 paragraph overview of findings and risk level]
## Findings Summary
| Severity | Count |
|----------|-------|
| Critical | [n] |
| High | [n] |
| Medium | [n] |
| Low | [n] |
| Info | [n] |
## Detailed Findings
### [FINDING-001] [Title]
- **Severity**: Critical / High / Medium / Low / Info
- **Category**: [OWASP category / HIPAA / 21 CFR Part 11 / Other]
- **Location**: [File(s) and line(s)]
- **Description**: [What was found]
- **Impact**: [What could happen if exploited]
- **Evidence**: [Code snippet or configuration showing the issue]
- **Remediation**: [How to fix it]
- **Priority**: [Immediate / Next Sprint / Next Quarter]
## Compliance Status
### OWASP Top 10
| Category | Status | Notes |
|----------|--------|-------|
| A01: Broken Access Control | Pass/Fail | |
| A02: Cryptographic Failures | Pass/Fail | |
| ... | | |
### HIPAA Security Rule
| Requirement | Status | Notes |
|-------------|--------|-------|
| Access Control | Pass/Fail | |
| Audit Controls | Pass/Fail | |
| ... | | |
### 21 CFR Part 11
| Section | Status | Notes |
|---------|--------|-------|
| 11.10(a) Validation | Pass/Fail | |
| 11.10(e) Audit Trails | Pass/Fail | |
| ... | | |
## Recommendations
[Prioritized list of recommendations]
## Appendix
- Tools used
- Files reviewed
- Test methodology
Ongoing Security Practices
- Dependency Scanning: Run
npm audit / pip audit in CI/CD pipeline. Block deploys on critical/high findings.
- Static Analysis: Integrate SAST tools (Semgrep, SonarQube, Bandit) into CI/CD.
- Secret Scanning: Use tools like git-secrets or truffleHog to prevent secrets from being committed.
- Penetration Testing: Annual external penetration test by a qualified firm.
- Security Training: Annual security awareness training for all developers, with emphasis on HIPAA and 21 CFR Part 11.
- Incident Response: Documented and tested incident response plan for security breaches involving PHI.