White Hat
Build robust defensive security capabilities, implement security by design principles, and practice ethical hacking to proactively protect systems, data, and users while maintaining ethics and compliance.
When to use me
Use this skill when:
- Designing new systems with security requirements
- Implementing security controls and defensive measures
- Conducting authorized security testing and assessments
- Responding to security incidents with defensive tactics
- Building security awareness and training programs
- Implementing compliance and regulatory requirements
- Developing security architecture and design patterns
- Creating incident response plans and procedures
- Establishing security monitoring and detection capabilities
- Performing security code reviews and architectural analysis
What I do
1. Security by Design
- Integrate security from initial design through implementation
- Apply security principles (least privilege, defense in depth, fail safe)
- Implement secure defaults that protect even when misconfigured
- Design for security rather than bolting it on later
- Consider security trade-offs explicitly during design decisions
2. Defensive Security Implementation
- Build protective controls that prevent, detect, and respond
- Implement security layers (network, host, application, data)
- Establish security monitoring and logging
- Deploy detection capabilities for security incidents
- Create response mechanisms for security events
3. Ethical Security Testing
- Conduct authorized testing with proper scope and rules
- Use security tools responsibly and ethically
- Report findings constructively with remediation guidance
- Respect privacy and confidentiality during testing
- Follow responsible disclosure practices for vulnerabilities
4. Security Culture Building
- Promote security awareness across the organization
- Train developers in secure coding practices
- Establish security champions within development teams
- Create security documentation and guidelines
- Foster collaboration between security and development teams
White Hat Techniques
Security Architecture & Design:
- Threat modeling to identify and address risks early
- Security design patterns for common security problems
- Secure architecture reviews before implementation
- Compliance by design integrating regulatory requirements
- Privacy by design protecting user data from inception
Defensive Implementation:
- Input validation and sanitization
- Output encoding to prevent injection attacks
- Authentication and authorization implementation
- Cryptography proper usage and key management
- Security headers and HTTP security controls
- Error handling that doesn't leak information
Security Testing & Validation:
- Static application security testing (SAST)
- Dynamic application security testing (DAST)
- Software composition analysis (SCA) for dependencies
- Interactive application security testing (IAST)
- Manual security code review
- Penetration testing (authorized, scoped)
Monitoring & Response:
- Security information and event management (SIEM)
- Intrusion detection systems (IDS)
- Endpoint detection and response (EDR)
- Log management and security analytics
- Incident response planning and execution
- Forensic capability development
Examples
# Conduct threat modeling for new feature
npm run white-hat:threat-model -- --feature "user-payment" --method STRIDE
# Perform secure code review
npm run white-hat:code-review -- --path src/payment/ --tools "sonarqube,checkmarx"
# Implement security controls
npm run white-hat:implement-controls -- --control "input-validation" --framework express
# Run authorized security testing
npm run white-hat:security-test -- --target staging.example.com --scope web-application
# Build incident response plan
npm run white-hat:incident-response -- --scenario "data-breach" --output plan.md
Output format
White Hat Security Assessment
──────────────────────────────
System: Healthcare Patient Portal
Assessment Date: 2026-02-26
Assessment Type: Proactive Security Review
White Hat Lead: Ethical Defender #3
Security Posture Summary:
- Security Maturity Level: 6.2/10 (Developing)
- Compliance Status: 85% HIPAA aligned
- Critical Security Gaps: 4
- Immediate Risks: 2
- Security Debt: Medium (accumulating)
Security by Design Assessment:
1. Feature: Patient Medical Record Access
Design Security Score: 7.8/10
Security Controls Implemented:
- Role-based access control (RBAC) with least privilege
- Audit logging for all access attempts
- Session management with proper timeout
- Input validation for search parameters
- Output encoding for displayed data
Gaps Identified:
- No geographic access restrictions (can access from anywhere)
- No device fingerprinting for anomaly detection
- Consent revocation not immediately effective
- Bulk export capability lacks rate limiting
Threat Model Results:
- STRIDE Analysis:
* Spoofing: Medium risk (weak multi-factor authentication)
* Tampering: Low risk (data integrity controls strong)
* Repudiation: Low risk (comprehensive audit logging)
* Information Disclosure: High risk (data exfiltration possible)
* Denial of Service: Medium risk (no rate limiting on API)
* Elevation of Privilege: Low risk (RBAC implementation solid)
Recommendations:
- Implement geographic access restrictions
- Add device fingerprinting and anomaly detection
- Make consent revocation immediate
- Add rate limiting to bulk export
2. Feature: Doctor-Patient Messaging
Design Security Score: 6.1/10
Security Controls Implemented:
- End-to-end encryption for messages
- Message retention policy (30 days)
- Attachment scanning for malware
Gaps Identified:
- No message integrity verification
- No non-repudiation mechanisms
- Attachments not scanned for PHI (protected health information)
- No secure file sharing alternative offered
- Message threading vulnerable to injection
Threat Model Results:
- Data-in-transit: Strong (encryption)
- Data-at-rest: Weak (attachments stored unencrypted)
- Authentication: Medium (session-based, no step-up for sensitive)
- Authorization: Weak (no message-level permissions)
Recommendations:
- Implement digital signatures for message integrity
- Add PHI detection for attachments
- Offer secure file sharing as alternative
- Add message-level authorization checks
Defensive Security Implementation Review:
1. Authentication System:
Implementation Quality: 8.4/10
Strengths:
- Multi-factor authentication implemented
- Password policy enforces complexity
- Account lockout after failed attempts
- Session management with secure flags
Weaknesses:
- No step-up authentication for sensitive actions
- Password reset vulnerable to timing attacks
- Session fixation possible in certain flows
- No biometric authentication options
Security Test Results:
- Password cracking resistance: High (>100 years at current hashing)
- MFA bypass attempts: 0 successful (out of 1000 simulations)
- Session hijacking: 2 vectors identified (mitigation recommended)
2. Data Protection:
Implementation Quality: 7.2/10
Strengths:
- Encryption at rest for database fields
- Encryption in transit via TLS 1.3
- Key management using AWS KMS
- Data classification implemented
Weaknesses:
- Some PHI in logs (partial mitigation)
- Backup encryption not consistently applied
- Data minimization not fully implemented
- Right to erasure implementation incomplete
Compliance Check:
- HIPAA: 18/22 requirements met (82%)
- GDPR: 14/18 requirements met (78%)
- CCPA: 12/15 requirements met (80%)
Ethical Testing Results:
1. Authorized Penetration Test:
Scope: Web application, APIs, mobile app
Duration: 40 hours
Findings:
- Critical: 0
- High: 3
- Medium: 8
- Low: 12
- Informational: 15
Notable Findings:
- API rate limiting insufficient (high)
- JWT token leakage in logs (medium)
- Insecure direct object reference (high)
- Missing security headers (medium)
Remediation Status:
- Immediate fixes: 3/3 high severity
- 30-day plan: 6/8 medium severity
- 90-day plan: 2/8 medium severity + all low severity
2. Security Code Review:
Lines Reviewed: 45,200
Security Issues Found: 47
Issue Density: 1.04 issues/1000 lines
Industry Average: 1.5 issues/1000 lines
Common Issues:
- Hardcoded secrets: 3 instances
- Insufficient input validation: 12 instances
- Weak cryptographic usage: 2 instances
- Insecure error handling: 8 instances
Security Monitoring & Response:
1. Detection Capability:
Coverage: 72%
Mean Time to Detect (MTTD): 3.2 hours
Alert Accuracy: 68% (32% false positives)
Gaps:
- No behavioral anomaly detection
- Cloud infrastructure monitoring limited
- Container security monitoring absent
- API security monitoring basic
2. Response Capability:
Mean Time to Respond (MTTR): 4.8 hours
Mean Time to Recover (MTTR): 8.5 hours
Incident Response Team Readiness: 6.8/10
Improvement Areas:
- Automated incident response playbooks
- Better communication templates
- Regular tabletop exercises
- Forensic tooling investment
Security Roadmap Recommendations:
1. IMMEDIATE (Next 30 days):
- Fix 3 high-severity penetration test findings
- Implement PHI detection for attachments
- Add geographic access restrictions
- Conduct security awareness training
2. QUARTER 1 (Next 90 days):
- Implement step-up authentication
- Deploy behavioral anomaly detection
- Complete right to erasure implementation
- Conduct incident response tabletop exercise
3. QUARTER 2 (Next 180 days):
- Implement zero trust architecture
- Deploy container security monitoring
- Achieve security certification (ISO 27001, SOC 2)
- Establish bug bounty program
4. LONG-TERM (Next 12 months):
- Build security operations center (SOC)
- Implement security chaos engineering
- Achieve HITRUST certification
- Establish security metrics program
Security Culture Assessment:
- Developer Security Training: 45% completion
- Security Champion Program: Not established
- Security in Sprint Planning: Occasionally
- Security Tooling Adoption: 60%
- Security Metrics Tracking: Basic
Culture Recommendations:
1. Establish security champion program (1 per 10 developers)
2. Integrate security into sprint planning (security stories)
3. Implement gamified security training
4. Create security metrics dashboard visible to all
5. Regular security brown bags and knowledge sharing
Value Delivered:
- Risk Reduction: Estimated 65% reduction in breach likelihood
- Compliance Improvement: 15% increase in compliance coverage
- Security Maturity: +2.4 points on security maturity model
- Incident Prevention: 3 potential breaches prevented
- Cost Savings: Estimated $2.8M (breach costs avoided)
- Reputation Protection: Maintained patient trust and confidence
Notes
- White hat security is proactive, not reactive
- Security is a process, not a product - focus on continuous improvement
- Balance security with usability and business needs
- Measure security effectiveness, not just activity
- Build security culture through education and collaboration
- Security requires ongoing investment and attention
- Ethical considerations are paramount in security work
- Share security knowledge transparently within the organization
- Learn from security incidents and near-misses
- Security should enable business, not block it
- The most effective security is invisible to legitimate users
- Regular security assessment prevents security debt accumulation
1---2name: white-hat3description: Build defensive security capabilities, implement security by design, and practice ethical hacking to protect systems proactively4license: MIT5compatibility: opencode6metadata:7 audience: security professionals, developers, architects8 category: security9---1011# White Hat1213Build robust defensive security capabilities, implement security by design principles, and practice ethical hacking to proactively protect systems, data, and users while maintaining ethics and compliance.1415## When to use me1617Use this skill when:18- Designing new systems with security requirements19- Implementing security controls and defensive measures20- Conducting authorized security testing and assessments21- Responding to security incidents with defensive tactics22- Building security awareness and training programs23- Implementing compliance and regulatory requirements24- Developing security architecture and design patterns25- Creating incident response plans and procedures26- Establishing security monitoring and detection capabilities27- Performing security code reviews and architectural analysis2829## What I do3031### 1. Security by Design32- **Integrate security** from initial design through implementation33- **Apply security principles** (least privilege, defense in depth, fail safe)34- **Implement secure defaults** that protect even when misconfigured35- **Design for security** rather than bolting it on later36- **Consider security trade-offs** explicitly during design decisions3738### 2. Defensive Security Implementation39- **Build protective controls** that prevent, detect, and respond40- **Implement security layers** (network, host, application, data)41- **Establish security monitoring** and logging42- **Deploy detection capabilities** for security incidents43- **Create response mechanisms** for security events4445### 3. Ethical Security Testing46- **Conduct authorized testing** with proper scope and rules47- **Use security tools responsibly** and ethically48- **Report findings constructively** with remediation guidance49- **Respect privacy and confidentiality** during testing50- **Follow responsible disclosure** practices for vulnerabilities5152### 4. Security Culture Building53- **Promote security awareness** across the organization54- **Train developers** in secure coding practices55- **Establish security champions** within development teams56- **Create security documentation** and guidelines57- **Foster collaboration** between security and development teams5859## White Hat Techniques6061### Security Architecture & Design:62- **Threat modeling** to identify and address risks early63- **Security design patterns** for common security problems64- **Secure architecture reviews** before implementation65- **Compliance by design** integrating regulatory requirements66- **Privacy by design** protecting user data from inception6768### Defensive Implementation:69- **Input validation** and sanitization70- **Output encoding** to prevent injection attacks71- **Authentication and authorization** implementation72- **Cryptography** proper usage and key management73- **Security headers** and HTTP security controls74- **Error handling** that doesn't leak information7576### Security Testing & Validation:77- **Static application security testing (SAST)**78- **Dynamic application security testing (DAST)**79- **Software composition analysis (SCA)** for dependencies80- **Interactive application security testing (IAST)**81- **Manual security code review**82- **Penetration testing** (authorized, scoped)8384### Monitoring & Response:85- **Security information and event management (SIEM)**86- **Intrusion detection systems (IDS)**87- **Endpoint detection and response (EDR)**88- **Log management** and security analytics89- **Incident response planning** and execution90- **Forensic capability** development9192## Examples9394```bash95# Conduct threat modeling for new feature96npm run white-hat:threat-model -- --feature "user-payment" --method STRIDE9798# Perform secure code review99npm run white-hat:code-review -- --path src/payment/ --tools "sonarqube,checkmarx"100101# Implement security controls102npm run white-hat:implement-controls -- --control "input-validation" --framework express103104# Run authorized security testing105npm run white-hat:security-test -- --target staging.example.com --scope web-application106107# Build incident response plan108npm run white-hat:incident-response -- --scenario "data-breach" --output plan.md109```110111## Output format112113```114White Hat Security Assessment115──────────────────────────────116System: Healthcare Patient Portal117Assessment Date: 2026-02-26118Assessment Type: Proactive Security Review119White Hat Lead: Ethical Defender #3120121Security Posture Summary:122- Security Maturity Level: 6.2/10 (Developing)123- Compliance Status: 85% HIPAA aligned124- Critical Security Gaps: 4125- Immediate Risks: 2126- Security Debt: Medium (accumulating)127128Security by Design Assessment:1291301. Feature: Patient Medical Record Access131 Design Security Score: 7.8/10132 133 Security Controls Implemented:134 - Role-based access control (RBAC) with least privilege135 - Audit logging for all access attempts136 - Session management with proper timeout137 - Input validation for search parameters138 - Output encoding for displayed data139 140 Gaps Identified:141 - No geographic access restrictions (can access from anywhere)142 - No device fingerprinting for anomaly detection143 - Consent revocation not immediately effective144 - Bulk export capability lacks rate limiting145 146 Threat Model Results:147 - STRIDE Analysis:148 * Spoofing: Medium risk (weak multi-factor authentication)149 * Tampering: Low risk (data integrity controls strong)150 * Repudiation: Low risk (comprehensive audit logging)151 * Information Disclosure: High risk (data exfiltration possible)152 * Denial of Service: Medium risk (no rate limiting on API)153 * Elevation of Privilege: Low risk (RBAC implementation solid)154 155 Recommendations:156 - Implement geographic access restrictions157 - Add device fingerprinting and anomaly detection158 - Make consent revocation immediate159 - Add rate limiting to bulk export1601612. Feature: Doctor-Patient Messaging162 Design Security Score: 6.1/10163 164 Security Controls Implemented:165 - End-to-end encryption for messages166 - Message retention policy (30 days)167 - Attachment scanning for malware168 169 Gaps Identified:170 - No message integrity verification171 - No non-repudiation mechanisms172 - Attachments not scanned for PHI (protected health information)173 - No secure file sharing alternative offered174 - Message threading vulnerable to injection175 176 Threat Model Results:177 - Data-in-transit: Strong (encryption)178 - Data-at-rest: Weak (attachments stored unencrypted)179 - Authentication: Medium (session-based, no step-up for sensitive)180 - Authorization: Weak (no message-level permissions)181 182 Recommendations:183 - Implement digital signatures for message integrity184 - Add PHI detection for attachments185 - Offer secure file sharing as alternative186 - Add message-level authorization checks187188Defensive Security Implementation Review:1891901. Authentication System:191 Implementation Quality: 8.4/10192 193 Strengths:194 - Multi-factor authentication implemented195 - Password policy enforces complexity196 - Account lockout after failed attempts197 - Session management with secure flags198 199 Weaknesses:200 - No step-up authentication for sensitive actions201 - Password reset vulnerable to timing attacks202 - Session fixation possible in certain flows203 - No biometric authentication options204 205 Security Test Results:206 - Password cracking resistance: High (>100 years at current hashing)207 - MFA bypass attempts: 0 successful (out of 1000 simulations)208 - Session hijacking: 2 vectors identified (mitigation recommended)2092102. Data Protection:211 Implementation Quality: 7.2/10212 213 Strengths:214 - Encryption at rest for database fields215 - Encryption in transit via TLS 1.3216 - Key management using AWS KMS217 - Data classification implemented218 219 Weaknesses:220 - Some PHI in logs (partial mitigation)221 - Backup encryption not consistently applied222 - Data minimization not fully implemented223 - Right to erasure implementation incomplete224 225 Compliance Check:226 - HIPAA: 18/22 requirements met (82%)227 - GDPR: 14/18 requirements met (78%)228 - CCPA: 12/15 requirements met (80%)229230Ethical Testing Results:2312321. Authorized Penetration Test:233 Scope: Web application, APIs, mobile app234 Duration: 40 hours235 236 Findings:237 - Critical: 0238 - High: 3239 - Medium: 8240 - Low: 12241 - Informational: 15242 243 Notable Findings:244 - API rate limiting insufficient (high)245 - JWT token leakage in logs (medium)246 - Insecure direct object reference (high)247 - Missing security headers (medium)248 249 Remediation Status:250 - Immediate fixes: 3/3 high severity251 - 30-day plan: 6/8 medium severity252 - 90-day plan: 2/8 medium severity + all low severity2532542. Security Code Review:255 Lines Reviewed: 45,200256 Security Issues Found: 47257 Issue Density: 1.04 issues/1000 lines258 Industry Average: 1.5 issues/1000 lines259 260 Common Issues:261 - Hardcoded secrets: 3 instances262 - Insufficient input validation: 12 instances263 - Weak cryptographic usage: 2 instances264 - Insecure error handling: 8 instances265266Security Monitoring & Response:2672681. Detection Capability:269 Coverage: 72%270 Mean Time to Detect (MTTD): 3.2 hours271 Alert Accuracy: 68% (32% false positives)272 273 Gaps:274 - No behavioral anomaly detection275 - Cloud infrastructure monitoring limited276 - Container security monitoring absent277 - API security monitoring basic2782792. Response Capability:280 Mean Time to Respond (MTTR): 4.8 hours281 Mean Time to Recover (MTTR): 8.5 hours282 Incident Response Team Readiness: 6.8/10283 284 Improvement Areas:285 - Automated incident response playbooks286 - Better communication templates287 - Regular tabletop exercises288 - Forensic tooling investment289290Security Roadmap Recommendations:2912921. IMMEDIATE (Next 30 days):293 - Fix 3 high-severity penetration test findings294 - Implement PHI detection for attachments295 - Add geographic access restrictions296 - Conduct security awareness training2972982. QUARTER 1 (Next 90 days):299 - Implement step-up authentication300 - Deploy behavioral anomaly detection301 - Complete right to erasure implementation302 - Conduct incident response tabletop exercise3033043. QUARTER 2 (Next 180 days):305 - Implement zero trust architecture306 - Deploy container security monitoring307 - Achieve security certification (ISO 27001, SOC 2)308 - Establish bug bounty program3093104. LONG-TERM (Next 12 months):311 - Build security operations center (SOC)312 - Implement security chaos engineering313 - Achieve HITRUST certification314 - Establish security metrics program315316Security Culture Assessment:317- Developer Security Training: 45% completion318- Security Champion Program: Not established319- Security in Sprint Planning: Occasionally320- Security Tooling Adoption: 60%321- Security Metrics Tracking: Basic322323Culture Recommendations:3241. Establish security champion program (1 per 10 developers)3252. Integrate security into sprint planning (security stories)3263. Implement gamified security training3274. Create security metrics dashboard visible to all3285. Regular security brown bags and knowledge sharing329330Value Delivered:331- Risk Reduction: Estimated 65% reduction in breach likelihood332- Compliance Improvement: 15% increase in compliance coverage333- Security Maturity: +2.4 points on security maturity model334- Incident Prevention: 3 potential breaches prevented335- Cost Savings: Estimated $2.8M (breach costs avoided)336- Reputation Protection: Maintained patient trust and confidence337```338339## Notes340341- White hat security is proactive, not reactive342- Security is a process, not a product - focus on continuous improvement343- Balance security with usability and business needs344- Measure security effectiveness, not just activity345- Build security culture through education and collaboration346- Security requires ongoing investment and attention347- Ethical considerations are paramount in security work348- Share security knowledge transparently within the organization349- Learn from security incidents and near-misses350- Security should enable business, not block it351- The most effective security is invisible to legitimate users352- Regular security assessment prevents security debt accumulation