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: MIT5---67# White Hat89Build 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.1011## When to use me1213Use this skill when:14- Designing new systems with security requirements15- Implementing security controls and defensive measures16- Conducting authorized security testing and assessments17- Responding to security incidents with defensive tactics18- Building security awareness and training programs19- Implementing compliance and regulatory requirements20- Developing security architecture and design patterns21- Creating incident response plans and procedures22- Establishing security monitoring and detection capabilities23- Performing security code reviews and architectural analysis2425## What I do2627### 1. Security by Design28- **Integrate security** from initial design through implementation29- **Apply security principles** (least privilege, defense in depth, fail safe)30- **Implement secure defaults** that protect even when misconfigured31- **Design for security** rather than bolting it on later32- **Consider security trade-offs** explicitly during design decisions3334### 2. Defensive Security Implementation35- **Build protective controls** that prevent, detect, and respond36- **Implement security layers** (network, host, application, data)37- **Establish security monitoring** and logging38- **Deploy detection capabilities** for security incidents39- **Create response mechanisms** for security events4041### 3. Ethical Security Testing42- **Conduct authorized testing** with proper scope and rules43- **Use security tools responsibly** and ethically44- **Report findings constructively** with remediation guidance45- **Respect privacy and confidentiality** during testing46- **Follow responsible disclosure** practices for vulnerabilities4748### 4. Security Culture Building49- **Promote security awareness** across the organization50- **Train developers** in secure coding practices51- **Establish security champions** within development teams52- **Create security documentation** and guidelines53- **Foster collaboration** between security and development teams5455## White Hat Techniques5657### Security Architecture & Design:58- **Threat modeling** to identify and address risks early59- **Security design patterns** for common security problems60- **Secure architecture reviews** before implementation61- **Compliance by design** integrating regulatory requirements62- **Privacy by design** protecting user data from inception6364### Defensive Implementation:65- **Input validation** and sanitization66- **Output encoding** to prevent injection attacks67- **Authentication and authorization** implementation68- **Cryptography** proper usage and key management69- **Security headers** and HTTP security controls70- **Error handling** that doesn't leak information7172### Security Testing & Validation:73- **Static application security testing (SAST)**74- **Dynamic application security testing (DAST)**75- **Software composition analysis (SCA)** for dependencies76- **Interactive application security testing (IAST)**77- **Manual security code review**78- **Penetration testing** (authorized, scoped)7980### Monitoring & Response:81- **Security information and event management (SIEM)**82- **Intrusion detection systems (IDS)**83- **Endpoint detection and response (EDR)**84- **Log management** and security analytics85- **Incident response planning** and execution86- **Forensic capability** development8788## Examples8990```bash91# Conduct threat modeling for new feature92npm run white-hat:threat-model -- --feature "user-payment" --method STRIDE9394# Perform secure code review95npm run white-hat:code-review -- --path src/payment/ --tools "sonarqube,checkmarx"9697# Implement security controls98npm run white-hat:implement-controls -- --control "input-validation" --framework express99100# Run authorized security testing101npm run white-hat:security-test -- --target staging.example.com --scope web-application102103# Build incident response plan104npm run white-hat:incident-response -- --scenario "data-breach" --output plan.md105```106107## Output format108109```110White Hat Security Assessment111──────────────────────────────112System: Healthcare Patient Portal113Assessment Date: 2026-02-26114Assessment Type: Proactive Security Review115White Hat Lead: Ethical Defender #3116117Security Posture Summary:118- Security Maturity Level: 6.2/10 (Developing)119- Compliance Status: 85% HIPAA aligned120- Critical Security Gaps: 4121- Immediate Risks: 2122- Security Debt: Medium (accumulating)123124Security by Design Assessment:1251261. Feature: Patient Medical Record Access127 Design Security Score: 7.8/10128 129 Security Controls Implemented:130 - Role-based access control (RBAC) with least privilege131 - Audit logging for all access attempts132 - Session management with proper timeout133 - Input validation for search parameters134 - Output encoding for displayed data135 136 Gaps Identified:137 - No geographic access restrictions (can access from anywhere)138 - No device fingerprinting for anomaly detection139 - Consent revocation not immediately effective140 - Bulk export capability lacks rate limiting141 142 Threat Model Results:143 - STRIDE Analysis:144 * Spoofing: Medium risk (weak multi-factor authentication)145 * Tampering: Low risk (data integrity controls strong)146 * Repudiation: Low risk (comprehensive audit logging)147 * Information Disclosure: High risk (data exfiltration possible)148 * Denial of Service: Medium risk (no rate limiting on API)149 * Elevation of Privilege: Low risk (RBAC implementation solid)150 151 Recommendations:152 - Implement geographic access restrictions153 - Add device fingerprinting and anomaly detection154 - Make consent revocation immediate155 - Add rate limiting to bulk export1561572. Feature: Doctor-Patient Messaging158 Design Security Score: 6.1/10159 160 Security Controls Implemented:161 - End-to-end encryption for messages162 - Message retention policy (30 days)163 - Attachment scanning for malware164 165 Gaps Identified:166 - No message integrity verification167 - No non-repudiation mechanisms168 - Attachments not scanned for PHI (protected health information)169 - No secure file sharing alternative offered170 - Message threading vulnerable to injection171 172 Threat Model Results:173 - Data-in-transit: Strong (encryption)174 - Data-at-rest: Weak (attachments stored unencrypted)175 - Authentication: Medium (session-based, no step-up for sensitive)176 - Authorization: Weak (no message-level permissions)177 178 Recommendations:179 - Implement digital signatures for message integrity180 - Add PHI detection for attachments181 - Offer secure file sharing as alternative182 - Add message-level authorization checks183184Defensive Security Implementation Review:1851861. Authentication System:187 Implementation Quality: 8.4/10188 189 Strengths:190 - Multi-factor authentication implemented191 - Password policy enforces complexity192 - Account lockout after failed attempts193 - Session management with secure flags194 195 Weaknesses:196 - No step-up authentication for sensitive actions197 - Password reset vulnerable to timing attacks198 - Session fixation possible in certain flows199 - No biometric authentication options200 201 Security Test Results:202 - Password cracking resistance: High (>100 years at current hashing)203 - MFA bypass attempts: 0 successful (out of 1000 simulations)204 - Session hijacking: 2 vectors identified (mitigation recommended)2052062. Data Protection:207 Implementation Quality: 7.2/10208 209 Strengths:210 - Encryption at rest for database fields211 - Encryption in transit via TLS 1.3212 - Key management using AWS KMS213 - Data classification implemented214 215 Weaknesses:216 - Some PHI in logs (partial mitigation)217 - Backup encryption not consistently applied218 - Data minimization not fully implemented219 - Right to erasure implementation incomplete220 221 Compliance Check:222 - HIPAA: 18/22 requirements met (82%)223 - GDPR: 14/18 requirements met (78%)224 - CCPA: 12/15 requirements met (80%)225226Ethical Testing Results:2272281. Authorized Penetration Test:229 Scope: Web application, APIs, mobile app230 Duration: 40 hours231 232 Findings:233 - Critical: 0234 - High: 3235 - Medium: 8236 - Low: 12237 - Informational: 15238 239 Notable Findings:240 - API rate limiting insufficient (high)241 - JWT token leakage in logs (medium)242 - Insecure direct object reference (high)243 - Missing security headers (medium)244 245 Remediation Status:246 - Immediate fixes: 3/3 high severity247 - 30-day plan: 6/8 medium severity248 - 90-day plan: 2/8 medium severity + all low severity2492502. Security Code Review:251 Lines Reviewed: 45,200252 Security Issues Found: 47253 Issue Density: 1.04 issues/1000 lines254 Industry Average: 1.5 issues/1000 lines255 256 Common Issues:257 - Hardcoded secrets: 3 instances258 - Insufficient input validation: 12 instances259 - Weak cryptographic usage: 2 instances260 - Insecure error handling: 8 instances261262Security Monitoring & Response:2632641. Detection Capability:265 Coverage: 72%266 Mean Time to Detect (MTTD): 3.2 hours267 Alert Accuracy: 68% (32% false positives)268 269 Gaps:270 - No behavioral anomaly detection271 - Cloud infrastructure monitoring limited272 - Container security monitoring absent273 - API security monitoring basic2742752. Response Capability:276 Mean Time to Respond (MTTR): 4.8 hours277 Mean Time to Recover (MTTR): 8.5 hours278 Incident Response Team Readiness: 6.8/10279 280 Improvement Areas:281 - Automated incident response playbooks282 - Better communication templates283 - Regular tabletop exercises284 - Forensic tooling investment285286Security Roadmap Recommendations:2872881. IMMEDIATE (Next 30 days):289 - Fix 3 high-severity penetration test findings290 - Implement PHI detection for attachments291 - Add geographic access restrictions292 - Conduct security awareness training2932942. QUARTER 1 (Next 90 days):295 - Implement step-up authentication296 - Deploy behavioral anomaly detection297 - Complete right to erasure implementation298 - Conduct incident response tabletop exercise2993003. QUARTER 2 (Next 180 days):301 - Implement zero trust architecture302 - Deploy container security monitoring303 - Achieve security certification (ISO 27001, SOC 2)304 - Establish bug bounty program3053064. LONG-TERM (Next 12 months):307 - Build security operations center (SOC)308 - Implement security chaos engineering309 - Achieve HITRUST certification310 - Establish security metrics program311312Security Culture Assessment:313- Developer Security Training: 45% completion314- Security Champion Program: Not established315- Security in Sprint Planning: Occasionally316- Security Tooling Adoption: 60%317- Security Metrics Tracking: Basic318319Culture Recommendations:3201. Establish security champion program (1 per 10 developers)3212. Integrate security into sprint planning (security stories)3223. Implement gamified security training3234. Create security metrics dashboard visible to all3245. Regular security brown bags and knowledge sharing325326Value Delivered:327- Risk Reduction: Estimated 65% reduction in breach likelihood328- Compliance Improvement: 15% increase in compliance coverage329- Security Maturity: +2.4 points on security maturity model330- Incident Prevention: 3 potential breaches prevented331- Cost Savings: Estimated $2.8M (breach costs avoided)332- Reputation Protection: Maintained patient trust and confidence333```334335## Notes336337- White hat security is proactive, not reactive338- Security is a process, not a product - focus on continuous improvement339- Balance security with usability and business needs340- Measure security effectiveness, not just activity341- Build security culture through education and collaboration342- Security requires ongoing investment and attention343- Ethical considerations are paramount in security work344- Share security knowledge transparently within the organization345- Learn from security incidents and near-misses346- Security should enable business, not block it347- The most effective security is invisible to legitimate users348- Regular security assessment prevents security debt accumulation