When to Use This Skill
- Before merging any PR that touches source code, config, infrastructure, or dependencies
- When the user asks for a compliance or security review
- When triggered via
/secure-hipaa command
- When assigned an issue related to security or HIPAA
- Before an OCR audit or third-party HIPAA assessment
- After adding new data storage, APIs, or third-party integrations touching PHI
- After a security incident to assess breach notification obligations
- Quarterly as a comprehensive compliance health check
- When onboarding a new Business Associate or subcontractor
How It Works
┌──────────────────────────────────────────────────────────────────────────┐
│ SECURE-HIPAA EXECUTION FLOW │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ PHASE 0: AUTO-DETECT PROJECT │ │
│ │ Scan for marker files → determine stacks → adapt all gates │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ PART A: 26-GATE SECURITY PIPELINE │ │
│ │ │ │
│ │ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ ┌────────┐ │ │
│ │ │Secrets │ │ SAST │ │ Deps │ │Container│ │ IaC │ │ │
│ │ │G1 │ │G3-G5 │ │G6-G8 │ │G9-G12 │ │G13-G17 │ │ │
│ │ └────────┘ └────────┘ └────────┘ └────────┘ └────────┘ │ │
│ │ ┌────────┐ ┌────────┐ ┌─────────────────────────────────┐ │ │
│ │ │ SBOM │ │ Build │ │ HIPAA Gates (G20-G26) │ │ │
│ │ │G18-G19 │ │G2,G10 │ │ PHI, Encrypt, Audit, Access, │ │ │
│ │ └────────┘ └────────┘ │ License, BAA, Aggregate │ │ │
│ │ └─────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ PART B: 7-PHASE HIPAA REGULATORY AUDIT │ │
│ │ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ Phase 1 │ │ Phase 2 │ │ Phase 3 │ │ Phase 4 │ │ │
│ │ │ PHI ID │→│ Tech │→│ Admin │→│ Encrypt │ │ │
│ │ │ 18 IDs │ │ §164.312 │ │ §164.308 │ │ Layers │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ └──────────┘ │ │
│ │ ┌──────────┐ ┌──────────┐ ┌──────────┐ │ │
│ │ │ Phase 5 │ │ Phase 6 │ │ Phase 7 │ │ │
│ │ │ BAA │→│ Breach │→│ De-ID │ │ │
│ │ │ §164.314 │ │ HITECH │ │ §164.514 │ │ │
│ │ └──────────┘ └──────────┘ └──────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ UNIFIED REPORT → docs/SECURE-HIPAA-REPORT.md │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌──────────────────────────────────────────────────────────────┐ │
│ │ SEVERITY LEVELS │ │
│ │ │ │
│ │ CRITICAL — PHI exposed, breach risk, injection found │ │
│ │ Unencrypted PHI in logs, hardcoded secrets, SQLi, RCE │ │
│ │ → Stop deployment. Remediate immediately. │ │
│ │ │ │
│ │ HIGH — HIPAA violation or security gap, not yet a breach │ │
│ │ Missing audit trail, no encryption at rest, weak auth │ │
│ │ → Fix before any PHI touches this code path. │ │
│ │ │ │
│ │ MEDIUM — Safeguard gap, compliance risk │ │
│ │ Missing log retention, no automatic logoff, CSRF off │ │
│ │ → Fix within the sprint. Document risk acceptance. │ │
│ │ │ │
│ │ LOW — Best practice gap, audit finding │ │
│ │ Missing documentation, training gap, policy update │ │
│ │ → Track and address in next compliance review. │ │
│ │ │ │
│ │ WARNING — Deferred (needs external tooling) │ │
│ │ Trivy, Snyk, Grype, OWASP plugin not available locally │ │
│ │ → Run in CI. Document the command to execute. │ │
│ └──────────────────────────────────────────────────────────────┘ │
└──────────────────────────────────────────────────────────────────────────┘
Phase 0: Auto-Detect Project Type
Before running any gate, scan the repository to identify all technology stacks present. This determines which checks each gate executes.
┌──────────────────────────────────────────────────────────────┐
│ AUTO-DETECT PROJECT TYPE │
│ │
│ Scan repo root (and common subdirectories) for: │
│ │
│ BACKEND STACKS │
│ □ pom.xml or build.gradle → Java (Spring/Quarkus) │
│ □ requirements.txt, pyproject.toml, Pipfile → Python │
│ □ package.json + server framework → Node.js │
│ (express, fastify, nestjs, hapi, koa) │
│ □ .csproj or .sln → .NET (ASP.NET) │
│ □ go.mod → Go │
│ □ Gemfile → Ruby (Rails/Sinatra) │
│ □ Cargo.toml → Rust │
│ □ composer.json → PHP (Laravel/Symfony) │
│ │
│ FRONTEND STACKS │
│ □ package.json + react/next → React / Next.js │
│ □ package.json + angular → Angular │
│ □ package.json + vue/nuxt → Vue / Nuxt │
│ □ package.json + svelte → Svelte / SvelteKit │
│ □ package.json (generic frontend) → Vanilla JS / Other │
│ │
│ INFRASTRUCTURE │
│ □ Dockerfile → Container builds │
│ □ docker-compose*.yml → Docker Compose │
│ □ **/k8s/ or kind: Deployment → Kubernetes │
│ □ .tf or .tf.json → Terraform │
│ □ policies/*.rego → OPA / Conftest │
│ □ serverless.yml / sam-template → Serverless │
│ │
│ CONFIG FILES (auto-mapped per detected stack) │
│ □ application.properties / application.yml → Spring │
│ □ appsettings.json / appsettings.*.json → ASP.NET │
│ □ settings.py / .env → Django/Flask │
│ □ .env / .env.* → Any stack │
│ □ next.config. / nuxt.config. → Next/Nuxt │
│ □ angular.json → Angular │
│ □ config/database.yml, config/secrets.yml → Rails │
│ □ config/.go, .yaml → Go │
│ │
│ HEALTH DATA STANDARDS │
│ □ FHIR references (Bundle, Patient, Observation) │
│ □ HL7v2 (MSH, PID, OBX segments) │
│ □ DICOM (DCM files, DIMSE references) │
│ □ X12 (837, 835, 270/271 transactions) │
│ □ CDA (ClinicalDocument references) │
│ │
│ → Record ALL detected stacks │
│ → Run gate checks for EVERY detected stack │
│ → If no stack detected, run generic checks │
│ → Report detected stacks at top of output report │
└──────────────────────────────────────────────────────────────┘
The 18 HIPAA Identifiers — Reference
Every audit must check whether these identifiers appear in code, databases, logs, API responses, error messages, analytics events, or third-party transmissions — regardless of technology stack.
┌──────────────────────────────────────────────────────────────┐
│ 18 HIPAA IDENTIFIERS (§164.514(b)(2)) │
│ │
│ # Identifier Code Search Patterns │
│ ─── ────────────────────────── ───────────────────────── │
│ 1 Names name, patient_name, │
│ first_name, last_name, │
│ getName, getFamily, │
│ given_name, family_name │
│ 2 Geographic (< state) address, street, city, │
│ zip, postal_code, addr │
│ 3 Dates (except year) dob, date_of_birth, │
│ birthDate, admission_date, │
│ birth_date, dateOfBirth │
│ 4 Phone numbers phone, telecom, mobile, │
│ phone_number, tel │
│ 5 Fax numbers fax, fax_number │
│ 6 Email addresses email, email_address │
│ 7 SSN ssn, social_security, │
│ social_security_number │
│ 8 Medical record numbers mrn, medical_record, │
│ identifier, MRN, │
│ medical_record_number │
│ 9 Health plan beneficiary beneficiary_id, member_id, │
│ plan_id, subscriber_id │
│ 10 Account numbers account_number, acct_num │
│ 11 Certificate/license # license_number, dea, │
│ npi, provider_id │
│ 12 Vehicle identifiers vin, license_plate │
│ 13 Device identifiers device_id, serial_number, │
│ udi, device_identifier │
│ 14 Web URLs url, patient_portal_url, │
│ callback_url │
│ 15 IP addresses ip_address, client_ip, │
│ remote_addr, x_forwarded │
│ 16 Biometric identifiers fingerprint, voiceprint, │
│ retina, face_encoding │
│ 17 Full-face photographs photo, face_image, │
│ profile_picture, avatar │
│ 18 Any other unique ID any unique code that could │
│ identify an individual │
└──────────────────────────────────────────────────────────────┘
Part A: 26-Gate Security Pipeline
Run all 26 gates sequentially. For each gate, inspect the relevant files based on
detected project type, record findings with exact file:line, and classify severity.
Gate 1: Secret Scanning
Scan the codebase for hardcoded secrets and credentials.
Check for: API keys, passwords, private keys, database connection strings with embedded credentials, cloud provider keys, tokens,
.env files with plaintext secrets, base64-encoded credentials
Patterns (all stacks):
password=, passwd=, secret=, token=, apikey=, api_key=
AKIA (AWS), ghp_ (GitHub), sk- (OpenAI/Stripe), xoxb- (Slack), SG. (SendGrid)
-----BEGIN RSA PRIVATE KEY-----, -----BEGIN OPENSSH PRIVATE KEY-----
postgres://user:pass@, mysql://user:pass@, mongodb://user:pass@, redis://:pass@
- Connection strings with embedded credentials in any format
Files (adapt per detected stack):
- All stacks:
.env, .env., .yml, .yaml, .json, .toml, .ini, *.cfg
- Java:
application.properties, application.yml, src/**
- Python:
settings.py, config.py, *.cfg, src/, app/
- Node.js:
config/, .env, src/, app/, lib/**
- .NET:
appsettings.json, appsettings..json, web.config, src/*
- Go:
.go, config/, cmd/*
- Ruby:
config/, .rb, app/*
- PHP:
.env, config/, *.php
Gate 2: Build & Dependency Pinning
Verify all dependencies are pinned to specific versions and builds are reproducible.
Check for (per detected stack):
| Stack | Manifest | Lockfile Required | Snapshot/Range Check | |
|---|
| Java | pom.xml / build.gradle | N/A (version in manifest) | No -SNAPSHOT in production, no version ranges | |
| Python | requirements.txt / pyproject.toml | poetry.lock / pip-compile output | All versions pinned with ==, no >= or ~= | |
| Node.js | package.json | package-lock.json / yarn.lock / pnpm-lock.yaml | Lockfile committed and in sync | |
| .NET | .csproj | packages.lock.json | No floating versions (), restore locked | |
| Go | go.mod | go.sum | go.sum committed | |
| Ruby | Gemfile | Gemfile.lock | Lockfile committed | |
| Rust | Cargo.toml | Cargo.lock | Lockfile committed for binaries | |
| PHP | composer.json | composer.lock | Lockfile committed | |
Gate 3: SAST — Code Security
Static analysis for injection, command execution, path traversal, deserialization, weak crypto, SSRF, and XXE — adapted to the detected language.
Check for (per detected stack):
| Vulnerability | Java | Python | Node.js | .NET | Go | Ruby | PHP | |
|---|
| SQL Injection | String concat in queries, no PreparedStatement | f-string/format in queries, raw SQL | String concat in queries, no parameterized | String concat in SqlCommand | String concat in db.Query() | String interpolation in where() | Variable in mysql_query() | |
| Command Injection | Runtime.exec(), ProcessBuilder with user input | subprocess(shell=True), os.system() | child_process.exec(), eval() | Process.Start() with user args | os/exec.Command() with user args | ` backticks , system() | exec(), shell_exec(), system()` | |
| Path Traversal | new File(userInput) | open(user_path), os.path.join without validation | fs.readFile(userInput), path.join without validation | Path.Combine(userInput) | os.Open(userInput) | File.read(user_path) | file_get_contents($userInput) | |
| Deserialization | ObjectInputStream | pickle.loads(), yaml.load() (unsafe) | node-serialize, JSON parse of untrusted | BinaryFormatter, DataContractSerializer | encoding/gob from untrusted | Marshal.load(), YAML.load() | unserialize() | |
| Weak Crypto | MD5, SHA1 without salt | hashlib.md5(), hashlib.sha1() | crypto.createHash('md5') | MD5.Create(), SHA1.Create() | md5.New(), sha1.New() | Digest::MD5 | md5(), sha1() | |
| XSS (frontend) | — | Django \ | safe, Jinja \ | safe | React dangerouslySetInnerHTML, v-html | Razor @Html.Raw() | template.HTML() | raw() in ERB | echo without htmlspecialchars | |
| SSRF | URL, HttpURLConnection with user URL | requests.get(user_url) | axios/fetch with user-controlled URL | HttpClient with user URL | http.Get(userURL) | open-uri, Net::HTTP with user URL | file_get_contents($url), curl_exec | |
Gate 4: Framework Security Configuration
Check authentication, authorization, CSRF, CORS, and security middleware — adapted to the detected framework.
Check for (per detected stack):
| Check | Java/Spring | Python/Django | Python/FastAPI | Node/Express | .NET/ASP.NET | Ruby/Rails | Go | PHP/Laravel | |
|---|
| Auth on endpoints | @PreAuthorize / @Secured | @login_required / DRF permission_classes | Depends() with auth | Auth middleware on routes | [Authorize] attribute | before_action :authenticate! | Auth middleware | middleware('auth') | |
| CSRF protection | .csrf() enabled | CsrfViewMiddleware enabled | N/A (API-only) | csurf middleware or SameSite cookies | [ValidateAntiForgeryToken] | protect_from_forgery | Custom CSRF token | VerifyCsrfToken middleware | |
| CORS config | No allowedOrigins("*") | CORS_ALLOWED_ORIGINS specific | CORSMiddleware origins | cors() whitelist | CORS policy specific origins | rack-cors config | CORS middleware | cors.php config | |
| Rate limiting | Filter/interceptor | django-ratelimit / DRF throttle | slowapi | express-rate-limit | AspNetCoreRateLimit | rack-attack | Rate limit middleware | ThrottleRequests | |
| Input validation | Bean Validation (@Valid) | Django Forms / DRF serializers | Pydantic models | Joi / Zod / express-validator | Data Annotations / FluentValidation | Strong params | Struct validation | Form Request validation | |
| Security headers | Spring Security headers | SecurityMiddleware | Middleware | helmet | Security headers middleware | secure_headers gem | Custom middleware | SecureHeaders middleware | |
Gate 5: HIPAA Application Rules
Check for health-data-specific security violations — PHI in logs, health records returned without access checks, patient identifiers in URLs, PHI in error responses.
Check for (all stacks):
- Patient/health data logged in any logger call (
log.(), console.log(), logger.(), print(), logging.*())
- Health records returned without access checks (FHIR, HL7v2, custom health APIs)
- Patient identifiers in URL paths or query strings
- PHI in error responses or exception messages returned to clients
- Missing audit trail for health data access
- Bulk export or data dump endpoints without authorization
- Health data in client-side state management (Redux, NgRx, Vuex, Zustand) — frontend only
Files: All source code directories, API route definitions, controller/handler files, middleware, frontend stores
Gate 6: Dependency Vulnerability Scanning
Scan all dependencies for known CVEs using the appropriate tool for each detected stack.
Commands (per detected stack):
| Stack | Primary Command | Alternative | |
|---|
| Java (Maven) | mvn org.owasp:dependency-check-maven:check | mvn versions:display-dependency-updates | |
| Java (Gradle) | gradle dependencyCheckAnalyze | gradle dependencyUpdates | |
| Python | pip-audit | safety check, pip install --dry-run --report | |
| Node.js (npm) | npm audit --audit-level=critical | yarn audit, pnpm audit | |
| .NET | dotnet list package --vulnerable | dotnet list package --outdated | |
| Go | govulncheck ./... | go list -m -json all | |
| Ruby | bundle-audit check | bundler-audit | |
| Rust | cargo audit | cargo deny check | |
| PHP | composer audit | local-php-security-checker | |
Mark as
WARNING if the tool is not available locally — document the command to run in CI.
Gate 7: Secondary Dependency Scanning
Cross-reference with a second scanner for broader coverage. No single vulnerability database is complete.
Commands: snyk test --all-projects,
trivy fs ., or equivalent. These tools auto-detect the project type.
Mark as
WARNING if not available locally.
Gate 8: Filesystem Vulnerability Scan
Scan the entire project filesystem for vulnerable libraries, misconfigured files, and secrets in configuration.
Command: trivy fs . (auto-detects all ecosystems)
Mark as
WARNING if not available locally.
Gate 9: Hadolint — Dockerfile Lint
Skip if no Dockerfile detected.
Check for: Running as root,
:latest tags, missing HEALTHCHECK,
ADD instead of
COPY, secrets in
ARG/
ENV, missing
.dockerignore
Files: Dockerfile,
Dockerfile.*,
.dockerignore
Gate 10: Docker Build Verification
Skip if no Dockerfile detected.
Check for: Syntax errors, base image availability, multi-stage correctness, build reproducibility
Gate 11: Container Image Scan
Skip if no Dockerfile detected.
Check for: HIGH/CRITICAL CVEs in base image, vulnerable application deps in image, root user
Command: trivy image — mark as
WARNING if not available locally.
Gate 12: Container Best Practices
Skip if no Dockerfile detected.
Check for: CIS Docker Benchmark compliance — root execution, sensitive files, missing image signing/trust
Gate 13: Infrastructure as Code Security
Skip if no IaC files detected.
Check for (per detected IaC):
- Kubernetes: Privileged pods, missing security contexts (
runAsNonRoot, readOnlyRootFilesystem), missing resource limits, missing network policies, secrets as env vars
- Terraform: Public S3 buckets, open security groups, unencrypted resources, wildcard IAM policies
- CloudFormation / SAM: Same as Terraform checks for AWS resources
- Docker Compose: Privileged mode, host network, exposed ports, secrets in environment
Files: deploy/,
infra/,
infrastructure/,
k8s/,
terraform/,
.tf,
docker-compose.yml
Gate 14: Configuration Scan
Scan all configuration and infrastructure files for misconfigurations.
Command: trivy config . (auto-detects K8s, Docker, Terraform, CloudFormation)
Mark as
WARNING if not available locally.
Gate 15: Policy Enforcement
Skip if no policy files detected.
Check for: OPA/Rego policy violations against deployments and configurations — privileged containers, missing labels, missing resource limits, HIPAA-specific gateway policies
Files: policies/*.rego, deployment manifests
Gate 16: Runtime Security Rules
Skip if no runtime security config detected.
Check for: Falco rules, Sysdig rules, or equivalent runtime monitoring — container escape detection, file access monitoring, privilege escalation detection, valid YAML/config syntax
Files: security/,
falco.yaml,
sysdig.yaml
Gate 17: Application Configuration Security
Check application configuration files (auto-detected per stack) for security settings.
Check for (per detected stack):
| Check | Spring | Django | Express | ASP.NET | Rails | FastAPI | Go | Laravel | |
|---|
| TLS/HTTPS enforced | server.ssl.* | SECURE_SSL_REDIRECT | helmet HSTS | UseHttpsRedirection | force_ssl | HTTPS middleware | TLS config | APP_URL=https | |
| Debug mode off | debug=false | DEBUG=False | NODE_ENV=production | ASPNETCORE_ENVIRONMENT=Production | config.consider_all_requests_local=false | debug=False | Build tags | APP_DEBUG=false | |
| DB encryption | JDBC with SSL params | sslmode=require in DB URL | ssl: true in connection | Encrypt=True in conn string | sslmode: require | SSL in DB URL | tls in DSN | DB SSL config | |
| Session security | Cookie secure/httpOnly | SESSION_COOKIE_SECURE | Cookie flags | Cookie policy | secure_cookies | Session config | Cookie flags | SESSION_SECURE_COOKIE | |
| Actuator/debug endpoints | Actuator exposure restricted | Debug toolbar removed | No /debug routes | Swagger disabled in prod | No /rails/info in prod | No /docs in prod | No pprof in prod | No Telescope in prod | |
Gate 18: SBOM Generation
Verify a Software Bill of Materials can be generated covering all dependencies.
Check for: All dependencies tracked, valid SBOM format, no undeclared dependencies
Commands: syft . or
cyclonedx-cli or equivalent — auto-detects all ecosystems. Mark as
WARNING if not available locally.
Gate 19: SBOM Vulnerability Scan
Scan the generated SBOM for vulnerabilities.
Command: grype sbom:./sbom.json or equivalent. Mark as
WARNING if not available locally.
Gate 20: HIPAA — PHI Detection
CRITICAL GATE. Scan for all 18 HIPAA identifiers across the entire codebase — source code, logs, error handlers, API responses, test fixtures, demo files, comments, frontend components, client-side stores.
Check for (all stacks):
- Patient names, DOB, SSN, MRN, phone, address in source code or test data
- PHI in logger calls —
log.(), console.log(), logger.(), print(), logging.(), Log.(), slog.(), Rails.logger.
- PHI in error messages or exceptions returned to clients
- PHI in API responses (REST, GraphQL, gRPC, WebSocket)
- Health records with identifiable patient data in test fixtures or seed files
- Demo/sample files with realistic patient data (JSON, CSV, XML, YAML)
- PHI in frontend state stores (Redux, NgRx, Vuex, Zustand, Pinia, MobX)
- PHI in analytics events (Google Analytics, Mixpanel, Segment, Amplitude)
- PHI in browser console logs or error boundaries
Files: ALL source code, config, test, demo, and documentation files
Gate 21: HIPAA — Encryption Validation
Check for (per detected stack):
http:// URLs anywhere in source or config (must be https://)
- Database connections without TLS/SSL parameters
- Missing TLS configuration in application server settings
- Weak crypto algorithms (MD5, SHA1, DES, RC4, 3DES)
- Unencrypted storage in IaC (S3 without SSE, RDS without encryption, EBS without encryption)
- Missing HSTS headers
- WebSocket connections over
ws:// instead of wss://
Files: All config files (auto-detected), source code, IaC files
Gate 22: HIPAA — Audit Logging
Check for (per detected stack):
| Check | Java | Python | Node.js | .NET | Go | Ruby | PHP | |
|---|
| Audit on CRUD | AOP/interceptor, @Audited | Django signals, middleware | Express middleware, ORM hooks | Action filters, EF interceptors | Middleware, GORM hooks | ActiveRecord callbacks | Eloquent events | |
| User identity in logs | SecurityContext | request.user | req.user | HttpContext.User | Context values | current_user | Auth::user() | |
| Structured logging | logback/log4j2 JSON | structlog, python-json-logger | pino, winston JSON | Serilog structured | slog, zap, zerolog | lograge | monolog JSON | |
- Missing audit for CRUD operations on patient data
- No user identity alongside PHI-touching operations
- No structured logging format (JSON) for machine-parseable audit trail
- No log retention or immutability configuration
- No separation of audit logs from application logs
Gate 23: HIPAA — Access Controls
Check for (per detected stack):
- Missing auth middleware/decorator/annotation on endpoints handling PHI
- No role-based access control (RBAC) or attribute-based access control (ABAC)
- Default "allow all authenticated" without fine-grained roles
- No tenant isolation for multi-tenant systems
- No MFA or step-up authentication for PHI access
- SMART-on-FHIR scopes not enforced (if FHIR is detected)
- OAuth2/OIDC scopes not matched to data access level
- GraphQL resolvers without per-field authorization
Refer to Gate 4 table for framework-specific auth patterns.
Gate 24: HIPAA — License Compliance
Check for (all stacks):
- GPL-family licenses in production dependencies (copyleft risk)
- AGPL licenses (network use triggers disclosure)
- Missing license declarations in project metadata
- Dependencies with no license (defaults to all rights reserved)
- Copyleft licenses in transitive dependencies
Tools: License checker plugins per ecosystem —
license-checker (npm),
pip-licenses (Python), Maven License Plugin,
dotnet-project-licenses (.NET),
go-licenses (Go),
license_finder (Ruby)
Gate 25: HIPAA — BAA Visibility
Check for (all stacks):
- Third-party services handling PHI without documented BAA — cloud providers, databases, analytics, monitoring, email, error tracking
- External API integrations that receive or process PHI
- No
docs/BAA-STATUS.md or equivalent tracking document
- SaaS tools receiving error reports that may contain PHI (Sentry, Datadog, New Relic, Bugsnag)
Files: Dependency manifests, config files, source code (outbound HTTP calls, SDK initializations)
Gate 26: HIPAA Aggregate Report
Combine findings from gates 20–25 into overall HIPAA status (PASS / FAIL / WARN).
Part B: 7-Phase HIPAA Regulatory Audit
After completing the 26 gates, perform the deep regulatory audit. This is technology-neutral — it maps findings to specific HIPAA Security Rule sections and assesses organizational readiness regardless of implementation stack.
Phase 1: PHI Identification Scan
Find every location where PHI exists — code, database schemas, logs, APIs, caches, file storage, frontend state.
┌──────────────────────────────────────────────────────────────┐
│ PHI IDENTIFICATION SCAN │
│ │
│ STEP 1: SCAN SOURCE CODE (all detected languages) │
│ → Search for all 18 identifiers in source files │
│ → Check every log statement for PHI leakage │
│ → Check every error handler for PHI in messages │
│ → Check API responses for unnecessary PHI fields │
│ │
│ STEP 2: SCAN CONFIGURATION & TEST DATA │
│ → Check config files for embedded credentials │
│ → Check test fixtures/seeds for realistic patient data │
│ → Check demo/sample files for PHI │
│ │
│ STEP 3: SCAN API RESPONSES │
│ → Does any endpoint return the full patient record? │
│ (violates minimum necessary — §164.502(b)) │
│ → Are PHI fields present in error responses? │
│ → Are PHI fields filtered based on user role? │
│ → Are GraphQL queries unrestricted on PHI fields? │
│ │
│ STEP 4: SCAN FRONTEND (if detected) │
│ → Is PHI stored in client-side state? │
│ → Is PHI logged to browser console? │
│ → Is PHI sent to analytics services? │
│ → Are source maps exposing PHI-handling code? │
│ │
│ For each PHI field found: │
│ □ Is it encrypted at the column/field level? │
│ □ Is access restricted by role? │
│ □ Is it included in audit logging? │
│ □ Can it be de-identified for analytics? │
└──────────────────────────────────────────────────────────────┘
Phase 2: Technical Safeguards (§164.312)
┌──────────────────────────────────────────────────────────────┐
│ §164.312(a) — ACCESS CONTROL │
│ □ Unique user identification — §164.312(a)(2)(i) │
│ □ Emergency access procedure — §164.312(a)(2)(ii) │
│ □ Automatic logoff — §164.312(a)(2)(iii) │
│ □ Encryption and decryption — §164.312(a)(2)(iv) │
│ □ RBAC/ABAC matrix enforced in code, not just policy │
│ │
│ §164.312(b) — AUDIT CONTROLS │
│ □ All PHI access events logged (read, write, delete) │
│ □ Required fields: who, what, when, where, outcome │
│ □ Logs immutable and tamper-evident │
│ □ Retained 6+ years, searchable by patient/user/date │
│ │
│ §164.312(c) — INTEGRITY │
│ □ Detect unauthorized PHI modifications │
│ □ Checksums or version history for PHI records │
│ □ Soft deletes for PHI (no hard delete) │
│ │
│ §164.312(d) — PERSON/ENTITY AUTHENTICATION │
│ □ MFA for PHI access │
│ □ Token validation (signature, expiry, issuer) │
│ □ API key rotation, certificate-based auth for services │
│ │
│ §164.312(e) — TRANSMISSION SECURITY │
│ □ TLS 1.2+ on all connections │
│ □ DB connections encrypted (SSL/TLS) │
│ □ No http:// for any PHI-carrying path │
│ □ WebSocket connections use wss:// │
│ □ Webhook payloads with PHI encrypted/signed │
└──────────────────────────────────────────────────────────────┘
Phase 3: Administrative Safeguards (§164.308)
┌──────────────────────────────────────────────────────────────┐
│ §164.308 — ADMINISTRATIVE SAFEGUARDS (Code Implications) │
│ │
│ §164.308(a)(1) — RISK ANALYSIS │
│ □ Formal risk analysis documented? │
│ □ Updated when systems change? │
│ │
│ §164.308(a)(3) — WORKFORCE SECURITY │
│ □ Access termination on employee departure? │
│ □ Access change events in audit trail? │
│ │
│ §164.308(a)(6) — SECURITY INCIDENT PROCEDURES │
│ □ Anomalous PHI access detection? │
│ □ Alerting for suspicious activity? │
│ □ Can affected patients be identified post-breach? │
│ │
│ §164.308(a)(7) — CONTINGENCY PLAN │
│ □ Encrypted backups? Tested restoration? │
│ □ Disaster recovery documented? │
└──────────────────────────────────────────────────────────────┘
Phase 4: Encryption Verification
┌──────────────────────────────────────────────────────────────┐
│ LAYER 1: DATA AT REST │
│ □ Database encryption (AES-256 or equivalent) │
│ □ File/object storage encryption (SSE-KMS or equivalent) │
│ □ Backup encryption │
│ □ Cache encryption or no-PHI policy │
│ │
│ LAYER 2: DATA IN TRANSIT │
│ □ Client → Server (TLS 1.2+, HSTS) │
│ □ Server → DB (SSL/TLS in connection string) │
│ □ Server → Server (mTLS or TLS) │
│ □ Webhooks (HTTPS + HMAC signing) │
│ □ WebSockets (wss://) │
│ │
│ LAYER 3: FIELD-LEVEL ENCRYPTION │
│ □ SSN encrypted at application layer before DB? │
│ □ DOB encrypted or stored as year-only? │
│ □ MRN encrypted or tokenized? │
│ │
│ KEY MANAGEMENT │
│ □ Keys in KMS/HSM, not hardcoded │
│ □ Key rotation on schedule │
│ □ Key access logged │
└──────────────────────────────────────────────────────────────┘
Phase 5: BAA Compliance (§164.314)
┌──────────────────────────────────────────────────────────────┐
│ For each third-party service in the codebase: │
│ □ Does it access PHI (even accidentally via error logs)? │
│ □ Is a BAA signed? │
│ □ Are subcontractor BAAs in place? │
│ □ Is PHI stripped before sending to services without BAAs? │
│ □ Is a docs/BAA-STATUS.md tracking document maintained? │
└──────────────────────────────────────────────────────────────┘
Phase 6: Breach Detection & Notification (HITECH §13402)
┌──────────────────────────────────────────────────────────────┐
│ □ Can the system identify which records were affected? │
│ □ Can the system identify which identifiers were exposed? │
│ □ Is there an accounting of disclosures? (§164.528, 6yr) │
│ □ Is there a breach notification workflow? │
│ □ Is there a breach risk assessment template? │
│ □ 60-day notification clock — is tooling in place? │
│ □ 500+ records → HHS + media notification supported? │
│ │
│ FOUR-FACTOR RISK ASSESSMENT (§164.402) │
│ 1. Nature/extent of PHI involved │
│ 2. Who received/accessed the PHI │
│ 3. Whether PHI was actually viewed or acquired │
│ 4. Extent of risk mitigation applied │
└──────────────────────────────────────────────────────────────┘
Phase 7: De-identification Review (§164.514)
┌──────────────────────────────────────────────────────────────┐
│ SAFE HARBOR METHOD — §164.514(b) │
│ □ Are all 18 identifiers removed for analytics/research? │
│ □ Zip codes truncated to 3 digits (pop > 20k)? │
│ □ Ages 90+ grouped? │
│ □ Dates reduced to year only? │
│ □ Re-identification risk assessed? │
│ □ Is there a de-identification function in the codebase? │
│ □ Are de-identified datasets tracked separately? │
└──────────────────────────────────────────────────────────────┘
Report Template
After completing Phase 0, all 26 gates, and 7 phases, save the report to
docs/SECURE-HIPAA-REPORT.md:
# Secure HIPAA Report
System: [application name and version]
Date: [date]
Scope: [files/directories audited]
Detected Stacks: [e.g. Java/Spring, React, Docker, Kubernetes]
Executive Summary
| Severity | Count | |
|---|
| CRITICAL | X | |
| HIGH | X | |
| MEDIUM | X | |
| LOW | X | |
| WARNING | X | |
Verdict: [PASS / FAIL / WARN]
Part A: 26-Gate Security Pipeline
Gate Results Overview
| Gate | Name | Status | Applies To | |
|---|
| 0 | Project Detection | [stacks found] | All | |
| 1 | Secret Scanning | [PASS/FAIL/WARN] | All | |
| ... | ... | ... | ... | |
| 26 | HIPAA Aggregate | [PASS/FAIL] | All | |
Gate Findings
[For each failed gate:]
Gate N — [Name] | [SEVERITY]
| # | File | Line | Finding | |
|---|
| 1 | path/to/file | NN | Description | |
Remediation: [specific fix]
Part B: 7-Phase HIPAA Regulatory Audit
Phase 1: PHI Inventory
| # | HIPAA Identifier | Found? | Location | |
|---|
| 1 | Names | YES/NO | file:line | |
| ... | ... | ... | ... | |
Phase 2: Technical Safeguards (§164.312)
| # | Requirement | §Section | Status | |
|---|
| 1 | Unique user identification | §164.312(a)(2)(i) | [PASS/FAIL] | |
| ... | ... | ... | ... | |
Phase 3: Administrative Safeguards (§164.308)
[same table format]
Phase 4: Encryption Verification
| Layer | Required | Status | Evidence | |
|---|
| DB at rest | AES-256 | [PASS/FAIL/UNKNOWN] | [evidence] | |
| ... | ... | ... | ... | |
Phase 5: BAA Compliance
| Service | PHI Access | BAA Status | |
|---|
| ... | ... | ... | |
Phase 6: Breach Notification Readiness
| Requirement | Status | Gap | |
|---|
| ... | ... | ... | |
Phase 7: De-identification
[Status and findings]
HIPAA Compliance Checklist (§164 Mapped)
| # | Requirement | §Section | Status | |
|---|
| 1 | ... | ... | ... | |
Passed Controls
Prioritized Remediation Plan
| Priority | Action | Fixes | Effort | |
|---|
| P0 | ... | ... | ... | |
| P1 | ... | ... | ... | |
| P2 | ... | ... | ... | |
| P3 | ... | ... | ... |
Tips for Best Results
- Start with the PHI inventory — you cannot protect what you cannot find. Map every location where PHI exists before checking any safeguard. Most violations come from PHI in places no one realized it existed.
- Search logs relentlessly in every language — search production log output for every one of the 18 identifiers. A single patient name in a log file is a reportable breach. Structured loggers are especially dangerous because they serialize entire objects, including PHI fields no one explicitly logged.
- Test the encryption chain end-to-end — it is not enough that the database is encrypted. Verify that PHI is encrypted from the moment it enters the system (TLS in transit) through processing to storage (AES-256 at rest) and back out. One unencrypted hop breaks the entire chain.
- Check every third-party integration — if a service can see PHI (even accidentally via error tracking like Sentry, Datadog, or New Relic), it needs a BAA. Map every outbound data flow and verify BAA coverage.
- Run the external tool gates in CI — Gates 6–8, 11, 14, and 18–19 require external tools (Trivy, Snyk, Grype, OWASP). The skill marks these as WARNING when running locally. Ensure they run in your CI pipeline.
- Think about the breach notification clock — if something goes wrong, can your system answer: How many records were affected? Which identifiers? Who accessed them? If not, you are not prepared for a breach.
- Minimum necessary is not optional — every API endpoint (REST, GraphQL, gRPC) should return only the PHI fields required for the specific function. Returning a full patient record when only the name is needed is a §164.502(b) violation.
- Frontend is an attack surface — PHI in Redux/NgRx/Vuex stores, browser localStorage, console.log statements, and analytics events are all breach vectors. Audit the frontend as strictly as the backend.
- The report is the deliverable — always save findings to
docs/SECURE-HIPAA-REPORT.md with exact file:line references so developers can act on them immediately.
- Auto-detection adapts, not limits — the skill detects your stack to run the right checks, but it also runs generic checks that apply to all projects. If your stack is not recognized, you still get full HIPAA coverage.