Senior SecOps Engineer
Complete toolkit for Security Operations including vulnerability management, compliance verification, secure coding practices, and security automation.
Table of Contents
Trigger Terms
Use this skill when you encounter:
| Category |
Terms |
| Vulnerability Management |
CVE, CVSS, vulnerability scan, security patch, dependency audit, npm audit, pip-audit |
| OWASP Top 10 |
injection, XSS, CSRF, broken authentication, security misconfiguration, sensitive data exposure |
| Compliance |
SOC 2, PCI-DSS, HIPAA, GDPR, compliance audit, security controls, access control |
| Secure Coding |
input validation, output encoding, parameterized queries, prepared statements, sanitization |
| Secrets Management |
API key, secrets vault, environment variables, HashiCorp Vault, AWS Secrets Manager |
| Authentication |
JWT, OAuth, MFA, 2FA, TOTP, password hashing, bcrypt, argon2, session management |
| Security Testing |
SAST, DAST, penetration test, security scan, Snyk, Semgrep, CodeQL, Trivy |
| Incident Response |
security incident, breach notification, incident response, forensics, containment |
| Network Security |
TLS, HTTPS, HSTS, CSP, CORS, security headers, firewall rules, WAF |
| Infrastructure Security |
container security, Kubernetes security, IAM, least privilege, zero trust |
| Cryptography |
encryption at rest, encryption in transit, AES-256, RSA, key management, KMS |
| Monitoring |
security monitoring, SIEM, audit logging, intrusion detection, anomaly detection |
Core Capabilities
1. Security Scanner
Scan source code for security vulnerabilities including hardcoded secrets, SQL injection, XSS, command injection, and path traversal.
# Scan project for security issues
python scripts/security_scanner.py /path/to/project
# Filter by severity
python scripts/security_scanner.py /path/to/project --severity high
# JSON output for CI/CD
python scripts/security_scanner.py /path/to/project --json --output report.json
Detects:
- Hardcoded secrets (API keys, passwords, AWS credentials, GitHub tokens, private keys)
- SQL injection patterns (string concatenation, f-strings, template literals)
- XSS vulnerabilities (innerHTML assignment, unsafe DOM manipulation, React unsafe patterns)
- Command injection (shell=True, exec, eval with user input)
- Path traversal (file operations with user input)
2. Vulnerability Assessor
Scan dependencies for known CVEs across npm, Python, and Go ecosystems.
# Assess project dependencies
python scripts/vulnerability_assessor.py /path/to/project
# Critical/high only
python scripts/vulnerability_assessor.py /path/to/project --severity high
# Export vulnerability report
python scripts/vulnerability_assessor.py /path/to/project --json --output vulns.json
Scans:
package.json and package-lock.json (npm)
requirements.txt and pyproject.toml (Python)
go.mod (Go)
Output:
- CVE IDs with CVSS scores
- Affected package versions
- Fixed versions for remediation
- Overall risk score (0-100)
3. Compliance Checker
Verify security compliance against SOC 2, PCI-DSS, HIPAA, and GDPR frameworks.
# Check all frameworks
python scripts/compliance_checker.py /path/to/project
# Specific framework
python scripts/compliance_checker.py /path/to/project --framework soc2
python scripts/compliance_checker.py /path/to/project --framework pci-dss
python scripts/compliance_checker.py /path/to/project --framework hipaa
python scripts/compliance_checker.py /path/to/project --framework gdpr
# Export compliance report
python scripts/compliance_checker.py /path/to/project --json --output compliance.json
Verifies:
- Access control implementation
- Encryption at rest and in transit
- Audit logging
- Authentication strength (MFA, password hashing)
- Security documentation
- CI/CD security controls
Workflows
Workflow 1: Security Audit
Complete security assessment of a codebase.
# Step 1: Scan for code vulnerabilities
python scripts/security_scanner.py . --severity medium
# Step 2: Check dependency vulnerabilities
python scripts/vulnerability_assessor.py . --severity high
# Step 3: Verify compliance controls
python scripts/compliance_checker.py . --framework all
# Step 4: Generate combined report
python scripts/security_scanner.py . --json --output security.json
python scripts/vulnerability_assessor.py . --json --output vulns.json
python scripts/compliance_checker.py . --json --output compliance.json
Workflow 2: CI/CD Security Gate
Integrate security checks into deployment pipeline.
# .github/workflows/security.yml
name: Security Scan
on:
pull_request:
branches: [main, develop]
jobs:
security-scan:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Security Scanner
run: python scripts/security_scanner.py . --severity high
- name: Vulnerability Assessment
run: python scripts/vulnerability_assessor.py . --severity critical
- name: Compliance Check
run: python scripts/compliance_checker.py . --framework soc2
Workflow 3: CVE Triage
Respond to a new CVE affecting your application.
1. ASSESS (0-2 hours)
- Identify affected systems using vulnerability_assessor.py
- Check if CVE is being actively exploited
- Determine CVSS environmental score for your context
2. PRIORITIZE
- Critical (CVSS 9.0+, internet-facing): 24 hours
- High (CVSS 7.0-8.9): 7 days
- Medium (CVSS 4.0-6.9): 30 days
- Low (CVSS < 4.0): 90 days
3. REMEDIATE
- Update affected dependency to fixed version
- Run security_scanner.py to verify fix
- Test for regressions
- Deploy with enhanced monitoring
4. VERIFY
- Re-run vulnerability_assessor.py
- Confirm CVE no longer reported
- Document remediation actions
Workflow 4: Incident Response
Security incident handling procedure.
PHASE 1: DETECT & IDENTIFY (0-15 min)
- Alert received and acknowledged
- Initial severity assessment (SEV-1 to SEV-4)
- Incident commander assigned
- Communication channel established
PHASE 2: CONTAIN (15-60 min)
- Affected systems identified
- Network isolation if needed
- Credentials rotated if compromised
- Preserve evidence (logs, memory dumps)
PHASE 3: ERADICATE (1-4 hours)
- Root cause identified
- Malware/backdoors removed
- Vulnerabilities patched (run security_scanner.py)
- Systems hardened
PHASE 4: RECOVER (4-24 hours)
- Systems restored from clean backup
- Services brought back online
- Enhanced monitoring enabled
- User access restored
PHASE 5: POST-INCIDENT (24-72 hours)
- Incident timeline documented
- Root cause analysis complete
- Lessons learned documented
- Preventive measures implemented
- Stakeholder report delivered
Tool Reference
security_scanner.py
| Option |
Description |
target |
Directory or file to scan |
--severity, -s |
Minimum severity: critical, high, medium, low |
--verbose, -v |
Show files as they're scanned |
--json |
Output results as JSON |
--output, -o |
Write results to file |
Exit Codes:
0: No critical/high findings
1: High severity findings
2: Critical severity findings
vulnerability_assessor.py
| Option |
Description |
target |
Directory containing dependency files |
--severity, -s |
Minimum severity: critical, high, medium, low |
--verbose, -v |
Show files as they're scanned |
--json |
Output results as JSON |
--output, -o |
Write results to file |
Exit Codes:
0: No critical/high vulnerabilities
1: High severity vulnerabilities
2: Critical severity vulnerabilities
compliance_checker.py
| Option |
Description |
target |
Directory to check |
--framework, -f |
Framework: soc2, pci-dss, hipaa, gdpr, all |
--verbose, -v |
Show checks as they run |
--json |
Output results as JSON |
--output, -o |
Write results to file |
Exit Codes:
0: Compliant (90%+ score)
1: Non-compliant (50-69% score)
2: Critical gaps (<50% score)
Security Standards
OWASP Top 10 Prevention
| Vulnerability |
Prevention |
| A01: Broken Access Control |
Implement RBAC, deny by default, validate permissions server-side |
| A02: Cryptographic Failures |
Use TLS 1.2+, AES-256 encryption, secure key management |
| A03: Injection |
Parameterized queries, input validation, escape output |
| A04: Insecure Design |
Threat modeling, secure design patterns, defense in depth |
| A05: Security Misconfiguration |
Hardening guides, remove defaults, disable unused features |
| A06: Vulnerable Components |
Dependency scanning, automated updates, SBOM |
| A07: Authentication Failures |
MFA, rate limiting, secure password storage |
| A08: Data Integrity Failures |
Code signing, integrity checks, secure CI/CD |
| A09: Security Logging Failures |
Comprehensive audit logs, SIEM integration, alerting |
| A10: SSRF |
URL validation, allowlist destinations, network segmentation |
Secure Coding Checklist
## Input Validation
- [ ] Validate all input on server side
- [ ] Use allowlists over denylists
- [ ] Sanitize for specific context (HTML, SQL, shell)
## Output Encoding
- [ ] HTML encode for browser output
- [ ] URL encode for URLs
- [ ] JavaScript encode for script contexts
## Authentication
- [ ] Use bcrypt/argon2 for passwords
- [ ] Implement MFA for sensitive operations
- [ ] Enforce strong password policy
## Session Management
- [ ] Generate secure random session IDs
- [ ] Set HttpOnly, Secure, SameSite flags
- [ ] Implement session timeout (15 min idle)
## Error Handling
- [ ] Log errors with context (no secrets)
- [ ] Return generic messages to users
- [ ] Never expose stack traces in production
## Secrets Management
- [ ] Use environment variables or secrets manager
- [ ] Never commit secrets to version control
- [ ] Rotate credentials regularly
Compliance Frameworks
SOC 2 Type II Controls
| Control |
Category |
Description |
| CC1 |
Control Environment |
Security policies, org structure |
| CC2 |
Communication |
Security awareness, documentation |
| CC3 |
Risk Assessment |
Vulnerability scanning, threat modeling |
| CC6 |
Logical Access |
Authentication, authorization, MFA |
| CC7 |
System Operations |
Monitoring, logging, incident response |
| CC8 |
Change Management |
CI/CD, code review, deployment controls |
PCI-DSS v4.0 Requirements
| Requirement |
Description |
| Req 3 |
Protect stored cardholder data (encryption at rest) |
| Req 4 |
Encrypt transmission (TLS 1.2+) |
| Req 6 |
Secure development (input validation, secure coding) |
| Req 8 |
Strong authentication (MFA, password policy) |
| Req 10 |
Audit logging (all access to cardholder data) |
| Req 11 |
Security testing (SAST, DAST, penetration testing) |
HIPAA Security Rule
| Safeguard |
Requirement |
| 164.312(a)(1) |
Unique user identification for PHI access |
| 164.312(b) |
Audit trails for PHI access |
| 164.312(c)(1) |
Data integrity controls |
| 164.312(d) |
Person/entity authentication (MFA) |
| 164.312(e)(1) |
Transmission encryption (TLS) |
GDPR Requirements
| Article |
Requirement |
| Art 25 |
Privacy by design, data minimization |
| Art 32 |
Security measures, encryption, pseudonymization |
| Art 33 |
Breach notification (72 hours) |
| Art 17 |
Right to erasure (data deletion) |
| Art 20 |
Data portability (export capability) |
Best Practices
Secrets Management
# BAD: Hardcoded secret
API_KEY = "sk-1234567890abcdef"
# GOOD: Environment variable
import os
API_KEY = os.environ.get("API_KEY")
# BETTER: Secrets manager
from your_vault_client import get_secret
API_KEY = get_secret("api/key")
SQL Injection Prevention
# BAD: String concatenation
query = f"SELECT * FROM users WHERE id = {user_id}"
# GOOD: Parameterized query
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
XSS Prevention
// BAD: Direct innerHTML assignment is vulnerable
// GOOD: Use textContent (auto-escaped)
element.textContent = userInput;
// GOOD: Use sanitization library for HTML
import DOMPurify from 'dompurify';
const safeHTML = DOMPurify.sanitize(userInput);
Authentication
// Password hashing
const bcrypt = require('bcrypt');
const SALT_ROUNDS = 12;
// Hash password
const hash = await bcrypt.hash(password, SALT_ROUNDS);
// Verify password
const match = await bcrypt.compare(password, hash);
Security Headers
// Express.js security headers
const helmet = require('helmet');
app.use(helmet());
// Or manually set headers:
app.use((req, res, next) => {
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '1; mode=block');
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
res.setHeader('Content-Security-Policy', "default-src 'self'");
next();
});
Reference Documentation
| Document |
Description |
references/security_standards.md |
OWASP Top 10, secure coding, authentication, API security |
references/vulnerability_management_guide.md |
CVE triage, CVSS scoring, remediation workflows |
references/compliance_requirements.md |
SOC 2, PCI-DSS, HIPAA, GDPR requirements |
Tech Stack
Security Scanning:
- Snyk (dependency scanning)
- Semgrep (SAST)
- CodeQL (code analysis)
- Trivy (container scanning)
- OWASP ZAP (DAST)
Secrets Management:
- HashiCorp Vault
- AWS Secrets Manager
- Azure Key Vault
- 1Password Secrets Automation
Authentication:
- bcrypt, argon2 (password hashing)
- jsonwebtoken (JWT)
- passport.js (authentication middleware)
- speakeasy (TOTP/MFA)
Logging & Monitoring:
- Winston, Pino (Node.js logging)
- Datadog, Splunk (SIEM)
- PagerDuty (alerting)
Compliance:
- Vanta (SOC 2 automation)
- Drata (compliance management)
- AWS Config (configuration compliance)
1---2name: senior-secops3description: Comprehensive SecOps skill for application security, vulnerability management, compliance, and secure development practices. Includes security scanning, vulnerability assessment, compliance checking, and security automation. Use when implementing security controls, conducting security audits, responding to vulnerabilities, or ensuring compliance requirements.4---5
6# Senior SecOps Engineer
7
8Complete toolkit for Security Operations including vulnerability management, compliance verification, secure coding practices, and security automation.
9
10---
11
12## Table of Contents
13
14- [Trigger Terms](#trigger-terms)
15- [Core Capabilities](#core-capabilities)
16- [Workflows](#workflows)
17- [Tool Reference](#tool-reference)
18- [Security Standards](#security-standards)
19- [Compliance Frameworks](#compliance-frameworks)
20- [Best Practices](#best-practices)
21
22---
23
24## Trigger Terms
25
26Use this skill when you encounter:
27
28| Category | Terms |
29|----------|-------|
30| **Vulnerability Management** | CVE, CVSS, vulnerability scan, security patch, dependency audit, npm audit, pip-audit |
31| **OWASP Top 10** | injection, XSS, CSRF, broken authentication, security misconfiguration, sensitive data exposure |
32| **Compliance** | SOC 2, PCI-DSS, HIPAA, GDPR, compliance audit, security controls, access control |
33| **Secure Coding** | input validation, output encoding, parameterized queries, prepared statements, sanitization |
34| **Secrets Management** | API key, secrets vault, environment variables, HashiCorp Vault, AWS Secrets Manager |
35| **Authentication** | JWT, OAuth, MFA, 2FA, TOTP, password hashing, bcrypt, argon2, session management |
36| **Security Testing** | SAST, DAST, penetration test, security scan, Snyk, Semgrep, CodeQL, Trivy |
37| **Incident Response** | security incident, breach notification, incident response, forensics, containment |
38| **Network Security** | TLS, HTTPS, HSTS, CSP, CORS, security headers, firewall rules, WAF |
39| **Infrastructure Security** | container security, Kubernetes security, IAM, least privilege, zero trust |
40| **Cryptography** | encryption at rest, encryption in transit, AES-256, RSA, key management, KMS |
41| **Monitoring** | security monitoring, SIEM, audit logging, intrusion detection, anomaly detection |
42
43---
44
45## Core Capabilities
46
47### 1. Security Scanner
48
49Scan source code for security vulnerabilities including hardcoded secrets, SQL injection, XSS, command injection, and path traversal.
50
51```bash
52# Scan project for security issues
53python scripts/security_scanner.py /path/to/project
54
55# Filter by severity
56python scripts/security_scanner.py /path/to/project --severity high
57
58# JSON output for CI/CD
59python scripts/security_scanner.py /path/to/project --json --output report.json
60```
61
62**Detects:**
63- Hardcoded secrets (API keys, passwords, AWS credentials, GitHub tokens, private keys)
64- SQL injection patterns (string concatenation, f-strings, template literals)
65- XSS vulnerabilities (innerHTML assignment, unsafe DOM manipulation, React unsafe patterns)
66- Command injection (shell=True, exec, eval with user input)
67- Path traversal (file operations with user input)
68
69### 2. Vulnerability Assessor
70
71Scan dependencies for known CVEs across npm, Python, and Go ecosystems.
72
73```bash
74# Assess project dependencies
75python scripts/vulnerability_assessor.py /path/to/project
76
77# Critical/high only
78python scripts/vulnerability_assessor.py /path/to/project --severity high
79
80# Export vulnerability report
81python scripts/vulnerability_assessor.py /path/to/project --json --output vulns.json
82```
83
84**Scans:**
85- `package.json` and `package-lock.json` (npm)
86- `requirements.txt` and `pyproject.toml` (Python)
87- `go.mod` (Go)
88
89**Output:**
90- CVE IDs with CVSS scores
91- Affected package versions
92- Fixed versions for remediation
93- Overall risk score (0-100)
94
95### 3. Compliance Checker
96
97Verify security compliance against SOC 2, PCI-DSS, HIPAA, and GDPR frameworks.
98
99```bash
100# Check all frameworks
101python scripts/compliance_checker.py /path/to/project
102
103# Specific framework
104python scripts/compliance_checker.py /path/to/project --framework soc2
105python scripts/compliance_checker.py /path/to/project --framework pci-dss
106python scripts/compliance_checker.py /path/to/project --framework hipaa
107python scripts/compliance_checker.py /path/to/project --framework gdpr
108
109# Export compliance report
110python scripts/compliance_checker.py /path/to/project --json --output compliance.json
111```
112
113**Verifies:**
114- Access control implementation
115- Encryption at rest and in transit
116- Audit logging
117- Authentication strength (MFA, password hashing)
118- Security documentation
119- CI/CD security controls
120
121---
122
123## Workflows
124
125### Workflow 1: Security Audit
126
127Complete security assessment of a codebase.
128
129```bash
130# Step 1: Scan for code vulnerabilities
131python scripts/security_scanner.py . --severity medium
132
133# Step 2: Check dependency vulnerabilities
134python scripts/vulnerability_assessor.py . --severity high
135
136# Step 3: Verify compliance controls
137python scripts/compliance_checker.py . --framework all
138
139# Step 4: Generate combined report
140python scripts/security_scanner.py . --json --output security.json
141python scripts/vulnerability_assessor.py . --json --output vulns.json
142python scripts/compliance_checker.py . --json --output compliance.json
143```
144
145### Workflow 2: CI/CD Security Gate
146
147Integrate security checks into deployment pipeline.
148
149```yaml
150# .github/workflows/security.yml
151name: Security Scan
152
153on:
154 pull_request:
155 branches: [main, develop]
156
157jobs:
158 security-scan:
159 runs-on: ubuntu-latest
160 steps:
161 - uses: actions/checkout@v4
162
163 - name: Set up Python
164 uses: actions/setup-python@v5
165 with:
166 python-version: '3.11'
167
168 - name: Security Scanner
169 run: python scripts/security_scanner.py . --severity high
170
171 - name: Vulnerability Assessment
172 run: python scripts/vulnerability_assessor.py . --severity critical
173
174 - name: Compliance Check
175 run: python scripts/compliance_checker.py . --framework soc2
176```
177
178### Workflow 3: CVE Triage
179
180Respond to a new CVE affecting your application.
181
182```
1831. ASSESS (0-2 hours)
184 - Identify affected systems using vulnerability_assessor.py
185 - Check if CVE is being actively exploited
186 - Determine CVSS environmental score for your context
187
1882. PRIORITIZE
189 - Critical (CVSS 9.0+, internet-facing): 24 hours
190 - High (CVSS 7.0-8.9): 7 days
191 - Medium (CVSS 4.0-6.9): 30 days
192 - Low (CVSS < 4.0): 90 days
193
1943. REMEDIATE
195 - Update affected dependency to fixed version
196 - Run security_scanner.py to verify fix
197 - Test for regressions
198 - Deploy with enhanced monitoring
199
2004. VERIFY
201 - Re-run vulnerability_assessor.py
202 - Confirm CVE no longer reported
203 - Document remediation actions
204```
205
206### Workflow 4: Incident Response
207
208Security incident handling procedure.
209
210```
211PHASE 1: DETECT & IDENTIFY (0-15 min)
212- Alert received and acknowledged
213- Initial severity assessment (SEV-1 to SEV-4)
214- Incident commander assigned
215- Communication channel established
216
217PHASE 2: CONTAIN (15-60 min)
218- Affected systems identified
219- Network isolation if needed
220- Credentials rotated if compromised
221- Preserve evidence (logs, memory dumps)
222
223PHASE 3: ERADICATE (1-4 hours)
224- Root cause identified
225- Malware/backdoors removed
226- Vulnerabilities patched (run security_scanner.py)
227- Systems hardened
228
229PHASE 4: RECOVER (4-24 hours)
230- Systems restored from clean backup
231- Services brought back online
232- Enhanced monitoring enabled
233- User access restored
234
235PHASE 5: POST-INCIDENT (24-72 hours)
236- Incident timeline documented
237- Root cause analysis complete
238- Lessons learned documented
239- Preventive measures implemented
240- Stakeholder report delivered
241```
242
243---
244
245## Tool Reference
246
247### security_scanner.py
248
249| Option | Description |
250|--------|-------------|
251| `target` | Directory or file to scan |
252| `--severity, -s` | Minimum severity: critical, high, medium, low |
253| `--verbose, -v` | Show files as they're scanned |
254| `--json` | Output results as JSON |
255| `--output, -o` | Write results to file |
256
257**Exit Codes:**
258- `0`: No critical/high findings
259- `1`: High severity findings
260- `2`: Critical severity findings
261
262### vulnerability_assessor.py
263
264| Option | Description |
265|--------|-------------|
266| `target` | Directory containing dependency files |
267| `--severity, -s` | Minimum severity: critical, high, medium, low |
268| `--verbose, -v` | Show files as they're scanned |
269| `--json` | Output results as JSON |
270| `--output, -o` | Write results to file |
271
272**Exit Codes:**
273- `0`: No critical/high vulnerabilities
274- `1`: High severity vulnerabilities
275- `2`: Critical severity vulnerabilities
276
277### compliance_checker.py
278
279| Option | Description |
280|--------|-------------|
281| `target` | Directory to check |
282| `--framework, -f` | Framework: soc2, pci-dss, hipaa, gdpr, all |
283| `--verbose, -v` | Show checks as they run |
284| `--json` | Output results as JSON |
285| `--output, -o` | Write results to file |
286
287**Exit Codes:**
288- `0`: Compliant (90%+ score)
289- `1`: Non-compliant (50-69% score)
290- `2`: Critical gaps (<50% score)
291
292---
293
294## Security Standards
295
296### OWASP Top 10 Prevention
297
298| Vulnerability | Prevention |
299|--------------|------------|
300| **A01: Broken Access Control** | Implement RBAC, deny by default, validate permissions server-side |
301| **A02: Cryptographic Failures** | Use TLS 1.2+, AES-256 encryption, secure key management |
302| **A03: Injection** | Parameterized queries, input validation, escape output |
303| **A04: Insecure Design** | Threat modeling, secure design patterns, defense in depth |
304| **A05: Security Misconfiguration** | Hardening guides, remove defaults, disable unused features |
305| **A06: Vulnerable Components** | Dependency scanning, automated updates, SBOM |
306| **A07: Authentication Failures** | MFA, rate limiting, secure password storage |
307| **A08: Data Integrity Failures** | Code signing, integrity checks, secure CI/CD |
308| **A09: Security Logging Failures** | Comprehensive audit logs, SIEM integration, alerting |
309| **A10: SSRF** | URL validation, allowlist destinations, network segmentation |
310
311### Secure Coding Checklist
312
313```markdown
314## Input Validation
315- [ ] Validate all input on server side
316- [ ] Use allowlists over denylists
317- [ ] Sanitize for specific context (HTML, SQL, shell)
318
319## Output Encoding
320- [ ] HTML encode for browser output
321- [ ] URL encode for URLs
322- [ ] JavaScript encode for script contexts
323
324## Authentication
325- [ ] Use bcrypt/argon2 for passwords
326- [ ] Implement MFA for sensitive operations
327- [ ] Enforce strong password policy
328
329## Session Management
330- [ ] Generate secure random session IDs
331- [ ] Set HttpOnly, Secure, SameSite flags
332- [ ] Implement session timeout (15 min idle)
333
334## Error Handling
335- [ ] Log errors with context (no secrets)
336- [ ] Return generic messages to users
337- [ ] Never expose stack traces in production
338
339## Secrets Management
340- [ ] Use environment variables or secrets manager
341- [ ] Never commit secrets to version control
342- [ ] Rotate credentials regularly
343```
344
345---
346
347## Compliance Frameworks
348
349### SOC 2 Type II Controls
350
351| Control | Category | Description |
352|---------|----------|-------------|
353| CC1 | Control Environment | Security policies, org structure |
354| CC2 | Communication | Security awareness, documentation |
355| CC3 | Risk Assessment | Vulnerability scanning, threat modeling |
356| CC6 | Logical Access | Authentication, authorization, MFA |
357| CC7 | System Operations | Monitoring, logging, incident response |
358| CC8 | Change Management | CI/CD, code review, deployment controls |
359
360### PCI-DSS v4.0 Requirements
361
362| Requirement | Description |
363|-------------|-------------|
364| Req 3 | Protect stored cardholder data (encryption at rest) |
365| Req 4 | Encrypt transmission (TLS 1.2+) |
366| Req 6 | Secure development (input validation, secure coding) |
367| Req 8 | Strong authentication (MFA, password policy) |
368| Req 10 | Audit logging (all access to cardholder data) |
369| Req 11 | Security testing (SAST, DAST, penetration testing) |
370
371### HIPAA Security Rule
372
373| Safeguard | Requirement |
374|-----------|-------------|
375| 164.312(a)(1) | Unique user identification for PHI access |
376| 164.312(b) | Audit trails for PHI access |
377| 164.312(c)(1) | Data integrity controls |
378| 164.312(d) | Person/entity authentication (MFA) |
379| 164.312(e)(1) | Transmission encryption (TLS) |
380
381### GDPR Requirements
382
383| Article | Requirement |
384|---------|-------------|
385| Art 25 | Privacy by design, data minimization |
386| Art 32 | Security measures, encryption, pseudonymization |
387| Art 33 | Breach notification (72 hours) |
388| Art 17 | Right to erasure (data deletion) |
389| Art 20 | Data portability (export capability) |
390
391---
392
393## Best Practices
394
395### Secrets Management
396
397```python
398# BAD: Hardcoded secret
399API_KEY = "sk-1234567890abcdef"
400
401# GOOD: Environment variable
402import os
403API_KEY = os.environ.get("API_KEY")
404
405# BETTER: Secrets manager
406from your_vault_client import get_secret
407API_KEY = get_secret("api/key")
408```
409
410### SQL Injection Prevention
411
412```python
413# BAD: String concatenation
414query = f"SELECT * FROM users WHERE id = {user_id}"
415
416# GOOD: Parameterized query
417cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
418```
419
420### XSS Prevention
421
422```javascript
423// BAD: Direct innerHTML assignment is vulnerable
424// GOOD: Use textContent (auto-escaped)
425element.textContent = userInput;
426
427// GOOD: Use sanitization library for HTML
428import DOMPurify from 'dompurify';
429const safeHTML = DOMPurify.sanitize(userInput);
430```
431
432### Authentication
433
434```javascript
435// Password hashing
436const bcrypt = require('bcrypt');
437const SALT_ROUNDS = 12;
438
439// Hash password
440const hash = await bcrypt.hash(password, SALT_ROUNDS);
441
442// Verify password
443const match = await bcrypt.compare(password, hash);
444```
445
446### Security Headers
447
448```javascript
449// Express.js security headers
450const helmet = require('helmet');
451app.use(helmet());
452
453// Or manually set headers:
454app.use((req, res, next) => {
455 res.setHeader('X-Content-Type-Options', 'nosniff');
456 res.setHeader('X-Frame-Options', 'DENY');
457 res.setHeader('X-XSS-Protection', '1; mode=block');
458 res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
459 res.setHeader('Content-Security-Policy', "default-src 'self'");
460 next();
461});
462```
463
464---
465
466## Reference Documentation
467
468| Document | Description |
469|----------|-------------|
470| `references/security_standards.md` | OWASP Top 10, secure coding, authentication, API security |
471| `references/vulnerability_management_guide.md` | CVE triage, CVSS scoring, remediation workflows |
472| `references/compliance_requirements.md` | SOC 2, PCI-DSS, HIPAA, GDPR requirements |
473
474---
475
476## Tech Stack
477
478**Security Scanning:**
479- Snyk (dependency scanning)
480- Semgrep (SAST)
481- CodeQL (code analysis)
482- Trivy (container scanning)
483- OWASP ZAP (DAST)
484
485**Secrets Management:**
486- HashiCorp Vault
487- AWS Secrets Manager
488- Azure Key Vault
489- 1Password Secrets Automation
490
491**Authentication:**
492- bcrypt, argon2 (password hashing)
493- jsonwebtoken (JWT)
494- passport.js (authentication middleware)
495- speakeasy (TOTP/MFA)
496
497**Logging & Monitoring:**
498- Winston, Pino (Node.js logging)
499- Datadog, Splunk (SIEM)
500- PagerDuty (alerting)
501
502**Compliance:**
503- Vanta (SOC 2 automation)
504- Drata (compliance management)
505- AWS Config (configuration compliance)