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