heimdall-agent 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -26
- package/README.pt-BR.md +443 -0
- package/agents/cloud-engineer.md +77 -0
- package/agents/code-sentinel.md +71 -34
- package/agents/database-architect.md +31 -25
- package/agents/frontend-designer.md +30 -28
- package/agents/mobile-designer.md +25 -24
- package/agents/modernizer.md +68 -0
- package/agents/orchestrator.md +107 -93
- package/agents/reviewer.md +102 -71
- package/agents/security-auditor.md +27 -27
- package/agents/tester.md +97 -90
- package/commands/grill-me.md +20 -4
- package/commands/orchestrate.md +16 -0
- package/commands/orchestrator.md +16 -0
- package/commands/plan.md +17 -1
- package/config/agents.json +31 -3
- package/config/mcp.json +72 -0
- package/config/models.json +26 -16
- package/config/profiles.json +2 -4
- package/config/skills.json +762 -573
- package/docs/SKILLS.md +393 -275
- package/docs/designs/old/2026-10-31 plan-lifecycle-backlog-and-clean-code-skill.md +87 -0
- package/docs/designs/old/2026-11-02 skill-upstream-audit-and-update.md +105 -0
- package/docs/designs/old/2026-11-05 communication-doctrine-bluf-ste.md +94 -0
- package/docs/designs/old/2026-11-06-cloud-engineer-and-resilience-synthesis.md +67 -0
- package/docs/designs/old/2026-11-06-herdr-native-agent-orchestration.md +45 -0
- package/docs/runs/skill-audit/2026-11-12-compare-report.json +1028 -0
- package/docs/runs/skill-audit/2026-11-12-upstream-audit.json +275 -0
- package/docs/runs/skill-audit/add_progressive_disclosure.cjs +30 -0
- package/docs/runs/skill-audit/check_heimdall_skills.ps1 +9 -0
- package/docs/runs/skill-audit/compare_classics.ps1 +26 -0
- package/docs/runs/skill-audit/compare_taste.ps1 +12 -0
- package/docs/runs/skill-audit/customization-report.json +380 -0
- package/docs/runs/skill-audit/diff_pending_skills.cjs +94 -0
- package/docs/runs/skill-audit/fetch_and_apply_skill.cjs +58 -0
- package/docs/runs/skill-audit/fetch_and_apply_taste_v2.cjs +65 -0
- package/docs/runs/skill-audit/inspect_pending_skills.cjs +71 -0
- package/docs/runs/skill-audit/inventory.json +308 -0
- package/docs/runs/skill-audit/list_local_taste.ps1 +1 -0
- package/docs/runs/skill-audit/phase5-update-plan.json +595 -0
- package/docs/runs/skill-audit/phase5-update-plan.md +138 -0
- package/docs/runs/skill-audit/probe.ps1 +16 -0
- package/docs/runs/skill-audit/probe_classics_branches.ps1 +3 -0
- package/docs/runs/skill-audit/probe_commits.ps1 +15 -0
- package/docs/runs/skill-audit/probe_repos.ps1 +17 -0
- package/docs/runs/skill-audit/probe_sentry_sec.ps1 +3 -0
- package/docs/runs/skill-audit/probe_sentry_sweep.ps1 +5 -0
- package/docs/runs/skill-audit/probe_snyk.ps1 +3 -0
- package/docs/runs/skill-audit/probe_snyk_recipes.ps1 +5 -0
- package/docs/runs/skill-audit/probe_taste_branches.ps1 +8 -0
- package/docs/runs/skill-audit/probe_taste_v19.ps1 +3 -0
- package/docs/runs/skill-audit/probe_user_repos.ps1 +19 -0
- package/docs/runs/skill-audit/prune_taste_skills.cjs +22 -0
- package/docs/runs/skill-audit/run_phase1_2.cjs +142 -0
- package/docs/runs/skill-audit/run_phase6_verification.cjs +107 -0
- package/docs/runs/skill-audit/show_16_details.ps1 +25 -0
- package/docs/runs/skill-audit/show_20_skills.ps1 +28 -0
- package/docs/runs/skill-audit/show_classics_diff.cjs +37 -0
- package/docs/runs/skill-audit/sync_agent_markdowns.cjs +30 -0
- package/docs/runs/skill-audit/taste-skill-upstream.md +542 -0
- package/docs/runs/skill-audit/update-manifest.md +88 -0
- package/docs/runs/skill-audit/update_config_skills.cjs +52 -0
- package/docs/runs/skill-audit/update_registry_phase7.cjs +83 -0
- package/docs/runs/skill-audit/upstream-status.json +563 -0
- package/docs/runs/skill-audit/verification-results.json +252 -0
- package/doctrine/AGENTS.md +42 -77
- package/hooks/git/pre-commit +11 -0
- package/hooks/heimdall-hook.cjs +81 -2
- package/hooks/herdr-agent-state.ps1 +55 -0
- package/hooks/hooks.json +0 -11
- package/lib/catalog-sync.cjs +167 -0
- package/lib/hermes-context.cjs +57 -0
- package/lib/model-context.cjs +123 -0
- package/lib/path-discovery.cjs +94 -0
- package/package.json +7 -3
- package/playbooks/01-interactive-grilling-gate.md +23 -6
- package/playbooks/02-fast-code-deep-verification.md +3 -2
- package/playbooks/03-adversarial-code-review.md +15 -7
- package/playbooks/05-canonical-plan-template.md +35 -19
- package/playbooks/06-model-registry-matrix.md +24 -13
- package/playbooks/07-legacy-code-modernization.md +74 -0
- package/playbooks/08-backlog-and-change-request-flow.md +122 -0
- package/setup.mjs +592 -172
- package/skills/antislop/SKILL.md +76 -56
- package/skills/antislop/VERSION +1 -0
- package/skills/antislop-copywriting/SKILL.md +407 -372
- package/skills/antislop-human/LICENSE-web-quality-skills +21 -0
- package/skills/antislop-human/SKILL.md +204 -147
- package/skills/antislop-human/contrast-check.py +168 -165
- package/skills/antislop-human/contrast-mcp.py +6 -3
- package/skills/antislop-human/references/A11Y-PATTERNS.md +249 -0
- package/skills/antislop-human/references/WCAG.md +127 -0
- package/skills/antislop-ui/LICENSE-web-quality-skills +21 -0
- package/skills/antislop-ui/SKILL.md +344 -304
- package/skills/antislop-ui/references/CORE-WEB-VITALS.md +181 -0
- package/skills/antislop-ui/references/WEB-BASELINE.md +28 -0
- package/skills/brainstorming/SKILL.md +296 -265
- package/skills/brainstorming/builder-check-prompt.md +23 -0
- package/skills/brainstorming/scripts/frame-template.html +213 -213
- package/skills/brainstorming/scripts/server.cjs +723 -723
- package/skills/brandkit/SKILL.md +798 -798
- package/skills/brutalist-skill/SKILL.md +93 -92
- package/skills/caveman/README.md +68 -0
- package/skills/caveman/SKILL.md +73 -38
- package/skills/claude-collaborator/SKILL.md +24 -44
- package/skills/clean-code/SKILL.md +152 -0
- package/skills/cloudflare-security-audit/AI-AND-LLM.md +83 -83
- package/skills/cloudflare-security-audit/ATTACK-CLASSES.md +130 -130
- package/skills/cloudflare-security-audit/CLIENT-SIDE.md +83 -83
- package/skills/cloudflare-security-audit/CLOUD-AND-DEPLOYMENT.md +86 -86
- package/skills/cloudflare-security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -84
- package/skills/cloudflare-security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -89
- package/skills/cloudflare-security-audit/HUNTING.md +251 -251
- package/skills/cloudflare-security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -101
- package/skills/cloudflare-security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -81
- package/skills/cloudflare-security-audit/RECONNAISSANCE.md +156 -156
- package/skills/cloudflare-security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -78
- package/skills/cloudflare-security-audit/SKILL.md +192 -192
- package/skills/cloudflare-security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -73
- package/skills/cloudflare-security-audit/VALIDATION-AND-REPORTING.md +186 -186
- package/skills/cloudflare-security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -105
- package/skills/cloudflare-security-audit/report-schema.json +461 -461
- package/skills/cloudflare-security-audit/validate-coverage-ledger.cjs +872 -872
- package/skills/cloudflare-security-audit/validate-coverage-ledger.test.cjs +740 -740
- package/skills/cloudflare-security-audit/validate-findings.cjs +773 -773
- package/skills/cloudflare-security-audit/validate-findings.test.cjs +652 -652
- package/skills/codebase-design/DEEPENING.md +37 -0
- package/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/skills/codebase-design/SKILL.md +114 -0
- package/skills/codex-collaborator/SKILL.md +24 -45
- package/skills/communication-doctrine/SKILL.md +89 -0
- package/skills/diagnosing-superpowers/SKILL.md +1 -1
- package/skills/diagnosing-superpowers/references/github-issues.md +3 -3
- package/skills/diagnosing-superpowers/templates/issue.md +23 -4
- package/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/skills/domain-modeling/GLOSSARY-FORMAT.md +60 -0
- package/skills/domain-modeling/SKILL.md +74 -0
- package/skills/executing-plans/SKILL.md +6 -56
- package/skills/executing-plans/scripts/task-done +52 -52
- package/skills/executing-plans/scripts/task-start +28 -28
- package/skills/gemini-collaborator/SKILL.md +24 -56
- package/skills/grill-me/SKILL.md +65 -0
- package/skills/handoff/SKILL.md +64 -0
- package/skills/herdr/SKILL.md +243 -0
- package/skills/image-to-code-skill/SKILL.md +1228 -1228
- package/skills/imagegen-frontend-mobile/SKILL.md +1465 -1465
- package/skills/imagegen-frontend-web/SKILL.md +987 -987
- package/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/skills/karpathy-guidelines/SKILL.md +67 -67
- package/skills/mcp-engineering/SKILL.md +74 -0
- package/skills/minimalist-skill/SKILL.md +87 -85
- package/skills/output-skill/SKILL.md +49 -49
- package/skills/owasp-security/reference/config-and-supply-chain.md +346 -344
- package/skills/owasp-security/reference/languages.md +378 -372
- package/skills/owasp-security/reference/owasp-report.md +1144 -1140
- package/skills/owasp-security/reference/review-checklist.md +134 -132
- package/skills/ponytail/SKILL.md +36 -52
- package/skills/postgres-best-practices/SKILL.md +30 -52
- package/skills/postgres-best-practices/references/backup-restore.md +372 -0
- package/skills/postgres-best-practices/references/bulk-loading.md +315 -0
- package/skills/postgres-best-practices/references/connection-pooling.md +310 -0
- package/skills/postgres-best-practices/references/hot-standby.md +221 -0
- package/skills/postgres-best-practices/references/indexing.md +318 -0
- package/skills/postgres-best-practices/references/logical-replication.md +610 -0
- package/skills/postgres-best-practices/references/major-version-upgrades.md +334 -0
- package/skills/postgres-best-practices/references/performance-diagnostics.md +553 -0
- package/skills/postgres-best-practices/references/query-optimization.md +294 -0
- package/skills/postgres-best-practices/references/query-patterns.md +566 -0
- package/skills/postgres-best-practices/references/schema-design.md +362 -0
- package/skills/postgres-best-practices/references/security-roles.md +489 -0
- package/skills/postgres-best-practices/references/transaction-isolation.md +344 -0
- package/skills/progressive-disclosure/SKILL.md +68 -0
- package/skills/pstack-discipline/SKILL.md +40 -0
- package/skills/receiving-code-review/SKILL.md +2 -23
- package/skills/requesting-code-review/SKILL.md +7 -36
- package/skills/soft-skill/SKILL.md +99 -98
- package/skills/stitch-skill/DESIGN.md +121 -121
- package/skills/stitch-skill/SKILL.md +185 -184
- package/skills/strix-security/SKILL.md +54 -53
- package/skills/subagent-driven-development/SKILL.md +35 -264
- package/skills/subagent-driven-development/references/batching.md +11 -0
- package/skills/subagent-driven-development/references/cannot-verify.md +10 -0
- package/skills/subagent-driven-development/references/final-review.md +47 -0
- package/skills/subagent-driven-development/references/fix-loop.md +77 -0
- package/skills/subagent-driven-development/references/handling-reports.md +15 -0
- package/skills/subagent-driven-development/references/preflight.md +26 -0
- package/skills/subagent-driven-development/references/resuming.md +12 -0
- package/skills/subagent-driven-development/scripts/review-package +53 -53
- package/skills/subagent-driven-development/scripts/sdd-workspace +87 -82
- package/skills/subagent-driven-development/scripts/task-brief +43 -43
- package/skills/systematic-debugging/SKILL.md +283 -306
- package/skills/taste-skill/SKILL.md +542 -1206
- package/skills/taste-skill/references/app-screens.md +1199 -0
- package/skills/taste-skill/references/colour.md +141 -0
- package/skills/taste-skill/references/copy.md +177 -0
- package/skills/taste-skill/references/critique.md +182 -0
- package/skills/taste-skill/references/imagery.md +791 -0
- package/skills/taste-skill/references/layout.md +292 -0
- package/skills/taste-skill/references/motion.md +980 -0
- package/skills/taste-skill/references/research.md +356 -0
- package/skills/taste-skill/references/scenes.md +174 -0
- package/skills/taste-skill/references/tells.md +115 -0
- package/skills/taste-skill/references/type.md +170 -0
- package/skills/test-driven-development/SKILL.md +330 -337
- package/skills/thermo/SKILL.md +67 -0
- package/skills/threat-modeling/SKILL.md +55 -0
- package/skills/to-spec/SKILL.md +75 -0
- package/skills/to-tickets/SKILL.md +105 -0
- package/skills/trailofbits-audit-context/SKILL.md +72 -72
- package/skills/trailofbits-insecure-defaults/commands/audit.md +35 -0
- package/skills/trailofbits-insecure-defaults/references/debug-features.json +13 -13
- package/skills/trailofbits-insecure-defaults/references/debug-features.md +75 -75
- package/skills/trailofbits-insecure-defaults/references/default-credentials.json +12 -12
- package/skills/trailofbits-insecure-defaults/references/default-credentials.md +76 -76
- package/skills/trailofbits-insecure-defaults/references/fail-open-security.json +11 -11
- package/skills/trailofbits-insecure-defaults/references/fail-open-security.md +70 -70
- package/skills/trailofbits-insecure-defaults/references/fallback-secrets.json +11 -11
- package/skills/trailofbits-insecure-defaults/references/fallback-secrets.md +70 -70
- package/skills/trailofbits-insecure-defaults/references/permissive-access.json +13 -13
- package/skills/trailofbits-insecure-defaults/references/permissive-access.md +62 -62
- package/skills/trailofbits-insecure-defaults/references/weak-crypto.json +13 -13
- package/skills/trailofbits-insecure-defaults/references/weak-crypto.md +71 -71
- package/skills/trailofbits-triage-brocards/SKILL.md +208 -208
- package/skills/verification-before-completion/SKILL.md +0 -14
- package/skills/wayfinder/SKILL.md +128 -0
- package/skills/writing-plans/SKILL.md +11 -15
- package/skills/writing-skills/SKILL.md +21 -303
- package/skills/writing-skills/references/CLAUDE_MD_TESTING.md +189 -0
- package/skills/writing-skills/references/anthropic-best-practices.md +1150 -0
- package/skills/writing-skills/references/bulletproofing.md +80 -0
- package/skills/writing-skills/references/discovery.md +201 -0
- package/skills/writing-skills/references/flowcharts.md +37 -0
- package/skills/writing-skills/references/graphviz-conventions.dot +172 -0
- package/skills/writing-skills/references/persuasion-principles.md +187 -0
- package/skills/writing-skills/references/testing-skills-with-subagents.md +384 -0
- package/tools/{claude-bridge.ps1 → archive/claude-bridge.ps1} +10 -7
- package/tools/{codex-bridge.ps1 → archive/codex-bridge.ps1} +1 -1
- package/tools/{gemini-bridge.ps1 → archive/gemini-bridge.ps1} +12 -19
- package/skills/gpt-tasteskill/SKILL.md +0 -74
- package/skills/taste-skill-v1/SKILL.md +0 -226
- /package/tools/{claude-bridge.cmd → archive/claude-bridge.cmd} +0 -0
- /package/tools/{claude-bridge.sh → archive/claude-bridge.sh} +0 -0
- /package/tools/{codex-bridge.cmd → archive/codex-bridge.cmd} +0 -0
- /package/tools/{codex-bridge.sh → archive/codex-bridge.sh} +0 -0
- /package/tools/{codexcli-bridge.cmd → archive/codexcli-bridge.cmd} +0 -0
- /package/tools/{codexcli-bridge.ps1 → archive/codexcli-bridge.ps1} +0 -0
- /package/tools/{gemini-bridge.cmd → archive/gemini-bridge.cmd} +0 -0
- /package/tools/{gemini-bridge.sh → archive/gemini-bridge.sh} +0 -0
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
# Debug and Introspection Defaults
|
|
2
|
-
|
|
3
|
-
**Report when:** Internal detail reaches a response, a listening port, or a log a lower-privileged party can read, whether it is gated by a flag that defaults to on, or simply unconditional (a stack trace or driver message written straight into an error response, with no flag at all).
|
|
4
|
-
|
|
5
|
-
**Skip when:** Log-verbosity-only flags with no user-facing output. Debug servers bound to loopback and off by default.
|
|
6
|
-
|
|
7
|
-
The finding needs both halves: enabled-by-default *and* an exposure path. A verbose logger that writes to a root-only file is neither.
|
|
8
|
-
|
|
9
|
-
## VULNERABLE - Report These
|
|
10
|
-
|
|
11
|
-
**Stack traces in API responses**
|
|
12
|
-
```python
|
|
13
|
-
# File: app.py
|
|
14
|
-
@app.errorhandler(Exception)
|
|
15
|
-
def handle_error(error):
|
|
16
|
-
return jsonify({
|
|
17
|
-
'error': str(error),
|
|
18
|
-
'traceback': traceback.format_exc() # Leaks internal paths, library versions
|
|
19
|
-
}), 500
|
|
20
|
-
```
|
|
21
|
-
**Why vulnerable:** Exposes internal implementation details to attackers.
|
|
22
|
-
|
|
23
|
-
**GraphQL introspection enabled**
|
|
24
|
-
```javascript
|
|
25
|
-
// File: server.js
|
|
26
|
-
const server = new ApolloServer({
|
|
27
|
-
typeDefs,
|
|
28
|
-
resolvers,
|
|
29
|
-
introspection: true, // Enabled in production
|
|
30
|
-
playground: true
|
|
31
|
-
});
|
|
32
|
-
```
|
|
33
|
-
**Why vulnerable:** Attackers can discover entire API schema, including admin-only fields.
|
|
34
|
-
|
|
35
|
-
**Verbose error messages**
|
|
36
|
-
```java
|
|
37
|
-
// File: UserController.java
|
|
38
|
-
catch (SQLException e) {
|
|
39
|
-
return ResponseEntity.status(500).body(
|
|
40
|
-
"Database error: " + e.getMessage() // Leaks table names, constraints
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
```
|
|
44
|
-
**Why vulnerable:** SQL error messages reveal database structure.
|
|
45
|
-
|
|
46
|
-
## SECURE - Skip These
|
|
47
|
-
|
|
48
|
-
**Debug features in logging only**
|
|
49
|
-
```python
|
|
50
|
-
# File: app.py
|
|
51
|
-
@app.errorhandler(Exception)
|
|
52
|
-
def handle_error(error):
|
|
53
|
-
logger.exception('Request failed', exc_info=error) # Logs full trace
|
|
54
|
-
return jsonify({'error': 'Internal server error'}), 500 # Generic to user
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
**Environment-aware debug settings**
|
|
58
|
-
```javascript
|
|
59
|
-
// File: server.js
|
|
60
|
-
const server = new ApolloServer({
|
|
61
|
-
typeDefs,
|
|
62
|
-
resolvers,
|
|
63
|
-
introspection: process.env.NODE_ENV !== 'production',
|
|
64
|
-
playground: process.env.NODE_ENV !== 'production'
|
|
65
|
-
});
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
**Generic user-facing errors**
|
|
69
|
-
```java
|
|
70
|
-
// File: UserController.java
|
|
71
|
-
catch (SQLException e) {
|
|
72
|
-
logger.error("Database error", e); // Full details to logs
|
|
73
|
-
return ResponseEntity.status(500).body("Unable to process request"); // Generic
|
|
74
|
-
}
|
|
75
|
-
```
|
|
1
|
+
# Debug and Introspection Defaults
|
|
2
|
+
|
|
3
|
+
**Report when:** Internal detail reaches a response, a listening port, or a log a lower-privileged party can read, whether it is gated by a flag that defaults to on, or simply unconditional (a stack trace or driver message written straight into an error response, with no flag at all).
|
|
4
|
+
|
|
5
|
+
**Skip when:** Log-verbosity-only flags with no user-facing output. Debug servers bound to loopback and off by default.
|
|
6
|
+
|
|
7
|
+
The finding needs both halves: enabled-by-default *and* an exposure path. A verbose logger that writes to a root-only file is neither.
|
|
8
|
+
|
|
9
|
+
## VULNERABLE - Report These
|
|
10
|
+
|
|
11
|
+
**Stack traces in API responses**
|
|
12
|
+
```python
|
|
13
|
+
# File: app.py
|
|
14
|
+
@app.errorhandler(Exception)
|
|
15
|
+
def handle_error(error):
|
|
16
|
+
return jsonify({
|
|
17
|
+
'error': str(error),
|
|
18
|
+
'traceback': traceback.format_exc() # Leaks internal paths, library versions
|
|
19
|
+
}), 500
|
|
20
|
+
```
|
|
21
|
+
**Why vulnerable:** Exposes internal implementation details to attackers.
|
|
22
|
+
|
|
23
|
+
**GraphQL introspection enabled**
|
|
24
|
+
```javascript
|
|
25
|
+
// File: server.js
|
|
26
|
+
const server = new ApolloServer({
|
|
27
|
+
typeDefs,
|
|
28
|
+
resolvers,
|
|
29
|
+
introspection: true, // Enabled in production
|
|
30
|
+
playground: true
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
**Why vulnerable:** Attackers can discover entire API schema, including admin-only fields.
|
|
34
|
+
|
|
35
|
+
**Verbose error messages**
|
|
36
|
+
```java
|
|
37
|
+
// File: UserController.java
|
|
38
|
+
catch (SQLException e) {
|
|
39
|
+
return ResponseEntity.status(500).body(
|
|
40
|
+
"Database error: " + e.getMessage() // Leaks table names, constraints
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
**Why vulnerable:** SQL error messages reveal database structure.
|
|
45
|
+
|
|
46
|
+
## SECURE - Skip These
|
|
47
|
+
|
|
48
|
+
**Debug features in logging only**
|
|
49
|
+
```python
|
|
50
|
+
# File: app.py
|
|
51
|
+
@app.errorhandler(Exception)
|
|
52
|
+
def handle_error(error):
|
|
53
|
+
logger.exception('Request failed', exc_info=error) # Logs full trace
|
|
54
|
+
return jsonify({'error': 'Internal server error'}), 500 # Generic to user
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Environment-aware debug settings**
|
|
58
|
+
```javascript
|
|
59
|
+
// File: server.js
|
|
60
|
+
const server = new ApolloServer({
|
|
61
|
+
typeDefs,
|
|
62
|
+
resolvers,
|
|
63
|
+
introspection: process.env.NODE_ENV !== 'production',
|
|
64
|
+
playground: process.env.NODE_ENV !== 'production'
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Generic user-facing errors**
|
|
69
|
+
```java
|
|
70
|
+
// File: UserController.java
|
|
71
|
+
catch (SQLException e) {
|
|
72
|
+
logger.error("Database error", e); // Full details to logs
|
|
73
|
+
return ResponseEntity.status(500).body("Unable to process request"); // Generic
|
|
74
|
+
}
|
|
75
|
+
```
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "default-credentials",
|
|
3
|
-
"title": "Default credentials",
|
|
4
|
-
"seeds": [
|
|
5
|
-
"(password|passwd|pwd|secret|token)[[:space:]]*[:=][[:space:]]*['\"][^'\"]{4,}['\"]",
|
|
6
|
-
"(api[_-]?key|access[_-]?key|client[_-]?secret)[[:space:]]*[:=][[:space:]]*['\"][^'\"]+['\"]",
|
|
7
|
-
"(admin|root|guest|test)[[:space:]]*[:=][[:space:]]*['\"](admin|root|password|changeme|guest|test|123)",
|
|
8
|
-
"(username|user|login|uid|account)[[:space:]]*[:=][[:space:]]*['\"](admin|administrator|root|sa|guest|test|demo)['\"]",
|
|
9
|
-
"(hash_password|make_password|set_password|hashpw|generate_password_hash)\\([^)]*['\"][^'\"]{3,}['\"]",
|
|
10
|
-
"(postgres(ql)?|mysql|mariadb|mongodb|redis|amqp|mssql)(\\+[a-z]+)?://[^:@[:space:]]+:[^@[:space:]]+@"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "default-credentials",
|
|
3
|
+
"title": "Default credentials",
|
|
4
|
+
"seeds": [
|
|
5
|
+
"(password|passwd|pwd|secret|token)[[:space:]]*[:=][[:space:]]*['\"][^'\"]{4,}['\"]",
|
|
6
|
+
"(api[_-]?key|access[_-]?key|client[_-]?secret)[[:space:]]*[:=][[:space:]]*['\"][^'\"]+['\"]",
|
|
7
|
+
"(admin|root|guest|test)[[:space:]]*[:=][[:space:]]*['\"](admin|root|password|changeme|guest|test|123)",
|
|
8
|
+
"(username|user|login|uid|account)[[:space:]]*[:=][[:space:]]*['\"](admin|administrator|root|sa|guest|test|demo)['\"]",
|
|
9
|
+
"(hash_password|make_password|set_password|hashpw|generate_password_hash)\\([^)]*['\"][^'\"]{3,}['\"]",
|
|
10
|
+
"(postgres(ql)?|mysql|mariadb|mongodb|redis|amqp|mssql)(\\+[a-z]+)?://[^:@[:space:]]+:[^@[:space:]]+@"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -1,76 +1,76 @@
|
|
|
1
|
-
# Default Credentials
|
|
2
|
-
|
|
3
|
-
**Report when:** A credential literal that a running deployment can actually authenticate with, including seeded accounts created on first boot.
|
|
4
|
-
|
|
5
|
-
**Skip when:** Accounts created disabled or with a forced-reset flag. Credentials in docs, READMEs, and fixture files.
|
|
6
|
-
|
|
7
|
-
A credential in prose is a credential nobody can use. A credential in `bootstrap_admin()` is a login.
|
|
8
|
-
|
|
9
|
-
## VULNERABLE - Report These
|
|
10
|
-
|
|
11
|
-
**Hardcoded admin account**
|
|
12
|
-
```python
|
|
13
|
-
# File: src/models/user.py
|
|
14
|
-
def bootstrap_admin():
|
|
15
|
-
"""Create default admin account if none exists"""
|
|
16
|
-
if not User.query.filter_by(role='admin').first():
|
|
17
|
-
admin = User(
|
|
18
|
-
username='admin',
|
|
19
|
-
password=hash_password('admin123'),
|
|
20
|
-
role='admin'
|
|
21
|
-
)
|
|
22
|
-
db.session.add(admin)
|
|
23
|
-
db.session.commit()
|
|
24
|
-
```
|
|
25
|
-
**Why vulnerable:** Default admin account created on first run with known credentials.
|
|
26
|
-
|
|
27
|
-
**API key in code**
|
|
28
|
-
```javascript
|
|
29
|
-
// File: src/integrations/payment.js
|
|
30
|
-
const STRIPE_API_KEY = process.env.STRIPE_KEY || 'sk_tes...';
|
|
31
|
-
|
|
32
|
-
const stripe = require('stripe')(STRIPE_API_KEY);
|
|
33
|
-
```
|
|
34
|
-
**Why vulnerable:** Uses test API key if env var missing. Might reach production.
|
|
35
|
-
|
|
36
|
-
**Database connection string**
|
|
37
|
-
```java
|
|
38
|
-
// File: DatabaseConfig.java
|
|
39
|
-
private static final String DB_URL = System.getenv().getOrDefault(
|
|
40
|
-
"DATABASE_URL",
|
|
41
|
-
"postgresql://admin:password@localhost:5432/prod"
|
|
42
|
-
);
|
|
43
|
-
```
|
|
44
|
-
**Why vulnerable:** Hardcoded database credentials as fallback.
|
|
45
|
-
|
|
46
|
-
## SECURE - Skip These
|
|
47
|
-
|
|
48
|
-
**Disabled default account**
|
|
49
|
-
```python
|
|
50
|
-
# File: src/models/user.py
|
|
51
|
-
def bootstrap_admin():
|
|
52
|
-
"""Admin account MUST be configured via environment"""
|
|
53
|
-
username = os.environ['ADMIN_USERNAME']
|
|
54
|
-
password = os.environ['ADMIN_PASSWORD']
|
|
55
|
-
|
|
56
|
-
if not User.query.filter_by(username=username).first():
|
|
57
|
-
admin = User(username=username, password=hash_password(password), role='admin')
|
|
58
|
-
db.session.add(admin)
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
**Example/documentation credentials**: a credential appearing inside prose in `README.md`:
|
|
62
|
-
```markdown
|
|
63
|
-
## Setup
|
|
64
|
-
|
|
65
|
-
Configure your API key:
|
|
66
|
-
|
|
67
|
-
export STRIPE_KEY='sk_tes...' # Example only
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
**Test fixture credentials**
|
|
71
|
-
```python
|
|
72
|
-
# File: tests/conftest.py
|
|
73
|
-
@pytest.fixture
|
|
74
|
-
def test_user():
|
|
75
|
-
return User(username='test_user', password='test_pass') # OK - test scope
|
|
76
|
-
```
|
|
1
|
+
# Default Credentials
|
|
2
|
+
|
|
3
|
+
**Report when:** A credential literal that a running deployment can actually authenticate with, including seeded accounts created on first boot.
|
|
4
|
+
|
|
5
|
+
**Skip when:** Accounts created disabled or with a forced-reset flag. Credentials in docs, READMEs, and fixture files.
|
|
6
|
+
|
|
7
|
+
A credential in prose is a credential nobody can use. A credential in `bootstrap_admin()` is a login.
|
|
8
|
+
|
|
9
|
+
## VULNERABLE - Report These
|
|
10
|
+
|
|
11
|
+
**Hardcoded admin account**
|
|
12
|
+
```python
|
|
13
|
+
# File: src/models/user.py
|
|
14
|
+
def bootstrap_admin():
|
|
15
|
+
"""Create default admin account if none exists"""
|
|
16
|
+
if not User.query.filter_by(role='admin').first():
|
|
17
|
+
admin = User(
|
|
18
|
+
username='admin',
|
|
19
|
+
password=hash_password('admin123'),
|
|
20
|
+
role='admin'
|
|
21
|
+
)
|
|
22
|
+
db.session.add(admin)
|
|
23
|
+
db.session.commit()
|
|
24
|
+
```
|
|
25
|
+
**Why vulnerable:** Default admin account created on first run with known credentials.
|
|
26
|
+
|
|
27
|
+
**API key in code**
|
|
28
|
+
```javascript
|
|
29
|
+
// File: src/integrations/payment.js
|
|
30
|
+
const STRIPE_API_KEY = process.env.STRIPE_KEY || 'sk_tes...';
|
|
31
|
+
|
|
32
|
+
const stripe = require('stripe')(STRIPE_API_KEY);
|
|
33
|
+
```
|
|
34
|
+
**Why vulnerable:** Uses test API key if env var missing. Might reach production.
|
|
35
|
+
|
|
36
|
+
**Database connection string**
|
|
37
|
+
```java
|
|
38
|
+
// File: DatabaseConfig.java
|
|
39
|
+
private static final String DB_URL = System.getenv().getOrDefault(
|
|
40
|
+
"DATABASE_URL",
|
|
41
|
+
"postgresql://admin:password@localhost:5432/prod"
|
|
42
|
+
);
|
|
43
|
+
```
|
|
44
|
+
**Why vulnerable:** Hardcoded database credentials as fallback.
|
|
45
|
+
|
|
46
|
+
## SECURE - Skip These
|
|
47
|
+
|
|
48
|
+
**Disabled default account**
|
|
49
|
+
```python
|
|
50
|
+
# File: src/models/user.py
|
|
51
|
+
def bootstrap_admin():
|
|
52
|
+
"""Admin account MUST be configured via environment"""
|
|
53
|
+
username = os.environ['ADMIN_USERNAME']
|
|
54
|
+
password = os.environ['ADMIN_PASSWORD']
|
|
55
|
+
|
|
56
|
+
if not User.query.filter_by(username=username).first():
|
|
57
|
+
admin = User(username=username, password=hash_password(password), role='admin')
|
|
58
|
+
db.session.add(admin)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Example/documentation credentials**: a credential appearing inside prose in `README.md`:
|
|
62
|
+
```markdown
|
|
63
|
+
## Setup
|
|
64
|
+
|
|
65
|
+
Configure your API key:
|
|
66
|
+
|
|
67
|
+
export STRIPE_KEY='sk_tes...' # Example only
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
**Test fixture credentials**
|
|
71
|
+
```python
|
|
72
|
+
# File: tests/conftest.py
|
|
73
|
+
@pytest.fixture
|
|
74
|
+
def test_user():
|
|
75
|
+
return User(username='test_user', password='test_pass') # OK - test scope
|
|
76
|
+
```
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "fail-open-security",
|
|
3
|
-
"title": "Fail-open security switches",
|
|
4
|
-
"seeds": [
|
|
5
|
-
"(AUTH|AUTHENTICATION|AUTHZ|REQUIRE_AUTH|LOGIN_REQUIRED|VERIFY|TLS_VERIFY|SSL_VERIFY|CSRF|SIGNATURE_CHECK)[A-Z_]*[[:space:]]*[:=][[:space:]]*(False|false|0|['\"](false|0|no|off)['\"])",
|
|
6
|
-
"(verify|check_hostname|validate)[[:space:]]*=[[:space:]]*(False|false)",
|
|
7
|
-
"(getenv|environ\\.get|process\\.env)[^)]*\\)[[:space:]]*(or|\\|\\|)[[:space:]]*(False|false|['\"](false|0|off|no)['\"])",
|
|
8
|
-
"(getenv|environ\\.get|getOrDefault|get_config|get_setting)\\([^)]*,[[:space:]]*['\"]?(false|0|no|off|none|disabled)['\"]?[[:space:]]*\\)",
|
|
9
|
-
"InsecureSkipVerify[[:space:]]*:[[:space:]]*true"
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "fail-open-security",
|
|
3
|
+
"title": "Fail-open security switches",
|
|
4
|
+
"seeds": [
|
|
5
|
+
"(AUTH|AUTHENTICATION|AUTHZ|REQUIRE_AUTH|LOGIN_REQUIRED|VERIFY|TLS_VERIFY|SSL_VERIFY|CSRF|SIGNATURE_CHECK)[A-Z_]*[[:space:]]*[:=][[:space:]]*(False|false|0|['\"](false|0|no|off)['\"])",
|
|
6
|
+
"(verify|check_hostname|validate)[[:space:]]*=[[:space:]]*(False|false)",
|
|
7
|
+
"(getenv|environ\\.get|process\\.env)[^)]*\\)[[:space:]]*(or|\\|\\|)[[:space:]]*(False|false|['\"](false|0|off|no)['\"])",
|
|
8
|
+
"(getenv|environ\\.get|getOrDefault|get_config|get_setting)\\([^)]*,[[:space:]]*['\"]?(false|0|no|off|none|disabled)['\"]?[[:space:]]*\\)",
|
|
9
|
+
"InsecureSkipVerify[[:space:]]*:[[:space:]]*true"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# Fail-Open Security Switches
|
|
2
|
-
|
|
3
|
-
**Report when:** The value taken when configuration is absent disables a security control. The insecure state is the unconfigured state.
|
|
4
|
-
|
|
5
|
-
**Skip when:** Switches whose unconfigured value is the secure one. Flags read but never consulted at the enforcement point.
|
|
6
|
-
|
|
7
|
-
Read the default, not the flag name. `REQUIRE_AUTH` defaulting to `'false'` requires nothing.
|
|
8
|
-
|
|
9
|
-
## VULNERABLE - Report These
|
|
10
|
-
|
|
11
|
-
**Authentication disabled by default**
|
|
12
|
-
```python
|
|
13
|
-
# File: config/security.py
|
|
14
|
-
REQUIRE_AUTH = os.getenv('REQUIRE_AUTH', 'false').lower() == 'true'
|
|
15
|
-
|
|
16
|
-
@app.before_request
|
|
17
|
-
def check_auth():
|
|
18
|
-
if not REQUIRE_AUTH:
|
|
19
|
-
return # Skip auth check
|
|
20
|
-
# ... auth logic
|
|
21
|
-
```
|
|
22
|
-
**Why vulnerable:** Default is no authentication. App runs insecurely if env var missing.
|
|
23
|
-
|
|
24
|
-
**CORS allows all origins**
|
|
25
|
-
```javascript
|
|
26
|
-
// File: server.js
|
|
27
|
-
const allowedOrigins = process.env.ALLOWED_ORIGINS || '*';
|
|
28
|
-
|
|
29
|
-
app.use(cors({ origin: allowedOrigins }));
|
|
30
|
-
```
|
|
31
|
-
**Why vulnerable:** Default allows requests from any origin. XSS/CSRF risk.
|
|
32
|
-
|
|
33
|
-
**Debug mode enabled by default**
|
|
34
|
-
```python
|
|
35
|
-
# File: config.py
|
|
36
|
-
DEBUG = os.getenv('DEBUG', 'true').lower() != 'false' # Default: true
|
|
37
|
-
|
|
38
|
-
if DEBUG:
|
|
39
|
-
app.config['DEBUG'] = True
|
|
40
|
-
app.config['PROPAGATE_EXCEPTIONS'] = True
|
|
41
|
-
```
|
|
42
|
-
**Why vulnerable:** Debug mode default. Stack traces leak sensitive info in production.
|
|
43
|
-
|
|
44
|
-
## SECURE - Skip These
|
|
45
|
-
|
|
46
|
-
**Authentication required by default**
|
|
47
|
-
```python
|
|
48
|
-
# File: config/security.py
|
|
49
|
-
REQUIRE_AUTH = os.getenv('REQUIRE_AUTH', 'true').lower() == 'true' # Default: true
|
|
50
|
-
|
|
51
|
-
# Or better - crash if not explicitly configured
|
|
52
|
-
REQUIRE_AUTH = os.environ['REQUIRE_AUTH'].lower() == 'true'
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
**CORS requires explicit configuration**
|
|
56
|
-
```javascript
|
|
57
|
-
// File: server.js
|
|
58
|
-
if (!process.env.ALLOWED_ORIGINS) {
|
|
59
|
-
throw new Error('ALLOWED_ORIGINS must be configured');
|
|
60
|
-
}
|
|
61
|
-
const allowedOrigins = process.env.ALLOWED_ORIGINS.split(',');
|
|
62
|
-
|
|
63
|
-
app.use(cors({ origin: allowedOrigins }));
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Debug mode disabled by default**
|
|
67
|
-
```python
|
|
68
|
-
# File: config.py
|
|
69
|
-
DEBUG = os.getenv('DEBUG', 'false').lower() == 'true' # Default: false
|
|
70
|
-
```
|
|
1
|
+
# Fail-Open Security Switches
|
|
2
|
+
|
|
3
|
+
**Report when:** The value taken when configuration is absent disables a security control. The insecure state is the unconfigured state.
|
|
4
|
+
|
|
5
|
+
**Skip when:** Switches whose unconfigured value is the secure one. Flags read but never consulted at the enforcement point.
|
|
6
|
+
|
|
7
|
+
Read the default, not the flag name. `REQUIRE_AUTH` defaulting to `'false'` requires nothing.
|
|
8
|
+
|
|
9
|
+
## VULNERABLE - Report These
|
|
10
|
+
|
|
11
|
+
**Authentication disabled by default**
|
|
12
|
+
```python
|
|
13
|
+
# File: config/security.py
|
|
14
|
+
REQUIRE_AUTH = os.getenv('REQUIRE_AUTH', 'false').lower() == 'true'
|
|
15
|
+
|
|
16
|
+
@app.before_request
|
|
17
|
+
def check_auth():
|
|
18
|
+
if not REQUIRE_AUTH:
|
|
19
|
+
return # Skip auth check
|
|
20
|
+
# ... auth logic
|
|
21
|
+
```
|
|
22
|
+
**Why vulnerable:** Default is no authentication. App runs insecurely if env var missing.
|
|
23
|
+
|
|
24
|
+
**CORS allows all origins**
|
|
25
|
+
```javascript
|
|
26
|
+
// File: server.js
|
|
27
|
+
const allowedOrigins = process.env.ALLOWED_ORIGINS || '*';
|
|
28
|
+
|
|
29
|
+
app.use(cors({ origin: allowedOrigins }));
|
|
30
|
+
```
|
|
31
|
+
**Why vulnerable:** Default allows requests from any origin. XSS/CSRF risk.
|
|
32
|
+
|
|
33
|
+
**Debug mode enabled by default**
|
|
34
|
+
```python
|
|
35
|
+
# File: config.py
|
|
36
|
+
DEBUG = os.getenv('DEBUG', 'true').lower() != 'false' # Default: true
|
|
37
|
+
|
|
38
|
+
if DEBUG:
|
|
39
|
+
app.config['DEBUG'] = True
|
|
40
|
+
app.config['PROPAGATE_EXCEPTIONS'] = True
|
|
41
|
+
```
|
|
42
|
+
**Why vulnerable:** Debug mode default. Stack traces leak sensitive info in production.
|
|
43
|
+
|
|
44
|
+
## SECURE - Skip These
|
|
45
|
+
|
|
46
|
+
**Authentication required by default**
|
|
47
|
+
```python
|
|
48
|
+
# File: config/security.py
|
|
49
|
+
REQUIRE_AUTH = os.getenv('REQUIRE_AUTH', 'true').lower() == 'true' # Default: true
|
|
50
|
+
|
|
51
|
+
# Or better - crash if not explicitly configured
|
|
52
|
+
REQUIRE_AUTH = os.environ['REQUIRE_AUTH'].lower() == 'true'
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**CORS requires explicit configuration**
|
|
56
|
+
```javascript
|
|
57
|
+
// File: server.js
|
|
58
|
+
if (!process.env.ALLOWED_ORIGINS) {
|
|
59
|
+
throw new Error('ALLOWED_ORIGINS must be configured');
|
|
60
|
+
}
|
|
61
|
+
const allowedOrigins = process.env.ALLOWED_ORIGINS.split(',');
|
|
62
|
+
|
|
63
|
+
app.use(cors({ origin: allowedOrigins }));
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Debug mode disabled by default**
|
|
67
|
+
```python
|
|
68
|
+
# File: config.py
|
|
69
|
+
DEBUG = os.getenv('DEBUG', 'false').lower() == 'true' # Default: false
|
|
70
|
+
```
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "fallback-secrets",
|
|
3
|
-
"title": "Fallback secrets",
|
|
4
|
-
"seeds": [
|
|
5
|
-
"(getenv|environ\\.get|get_config|get_setting|getOrDefault|GetString|LookupEnv)\\([^)]*,[[:space:]]*['\"]",
|
|
6
|
-
"(getenv|environ\\.get|os\\.environ\\.get)\\([^)]*\\)[[:space:]]*(or|\\|\\|)[[:space:]]*['\"]",
|
|
7
|
-
"process\\.env\\.[A-Za-z_][A-Za-z0-9_]*[[:space:]]*(\\|\\||\\?\\?)[[:space:]]*['\"]",
|
|
8
|
-
"ENV\\.fetch\\([^)]*,[[:space:]]*['\"]",
|
|
9
|
-
"(SECRET|SECRET_KEY|JWT_SECRET|SESSION_KEY|SIGNING_KEY|TOKEN|SALT|PEPPER)[[:space:]]*[:=]"
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"id": "fallback-secrets",
|
|
3
|
+
"title": "Fallback secrets",
|
|
4
|
+
"seeds": [
|
|
5
|
+
"(getenv|environ\\.get|get_config|get_setting|getOrDefault|GetString|LookupEnv)\\([^)]*,[[:space:]]*['\"]",
|
|
6
|
+
"(getenv|environ\\.get|os\\.environ\\.get)\\([^)]*\\)[[:space:]]*(or|\\|\\|)[[:space:]]*['\"]",
|
|
7
|
+
"process\\.env\\.[A-Za-z_][A-Za-z0-9_]*[[:space:]]*(\\|\\||\\?\\?)[[:space:]]*['\"]",
|
|
8
|
+
"ENV\\.fetch\\([^)]*,[[:space:]]*['\"]",
|
|
9
|
+
"(SECRET|SECRET_KEY|JWT_SECRET|SESSION_KEY|SIGNING_KEY|TOKEN|SALT|PEPPER)[[:space:]]*[:=]"
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
# Fallback Secrets
|
|
2
|
-
|
|
3
|
-
**Report when:** A default value supplied when the env var is absent, where that value feeds signing, encryption, session, or token machinery.
|
|
4
|
-
|
|
5
|
-
**Skip when:** Defaults generated per-boot at random. Values only used as cache keys or correlation ids.
|
|
6
|
-
|
|
7
|
-
The decisive question is not whether a literal exists. It is whether the app **runs** with it. `env.get(X, Y)` runs; `env[X]` crashes. That difference is the whole finding.
|
|
8
|
-
|
|
9
|
-
## VULNERABLE - Report These
|
|
10
|
-
|
|
11
|
-
**Python: Environment variable with fallback**
|
|
12
|
-
```python
|
|
13
|
-
# File: src/auth/jwt.py
|
|
14
|
-
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-123')
|
|
15
|
-
|
|
16
|
-
# Used in security context
|
|
17
|
-
def create_token(user_id):
|
|
18
|
-
return jwt.encode({'user_id': user_id}, SECRET_KEY, algorithm='HS256')
|
|
19
|
-
```
|
|
20
|
-
**Why vulnerable:** App runs with known secret if `SECRET_KEY` is missing. Attacker can forge tokens.
|
|
21
|
-
|
|
22
|
-
**JavaScript: Logical OR fallback**
|
|
23
|
-
```javascript
|
|
24
|
-
// File: config/database.js
|
|
25
|
-
const DB_PASSWORD = process.env.DB_PASSWORD || 'admin123';
|
|
26
|
-
|
|
27
|
-
const pool = new Pool({
|
|
28
|
-
user: 'admin',
|
|
29
|
-
password: DB_PASSWORD,
|
|
30
|
-
database: 'production'
|
|
31
|
-
});
|
|
32
|
-
```
|
|
33
|
-
**Why vulnerable:** Database accepts hardcoded password in production if env var missing.
|
|
34
|
-
|
|
35
|
-
**Ruby: fetch with default**
|
|
36
|
-
```ruby
|
|
37
|
-
# File: config/secrets.rb
|
|
38
|
-
Rails.application.credentials.secret_key_base =
|
|
39
|
-
ENV.fetch('SECRET_KEY_BASE', 'fallback-secret-base')
|
|
40
|
-
```
|
|
41
|
-
**Why vulnerable:** Rails session encryption uses weak known key as fallback.
|
|
42
|
-
|
|
43
|
-
## SECURE - Skip These
|
|
44
|
-
|
|
45
|
-
**Fail-secure: Crashes without config**
|
|
46
|
-
```python
|
|
47
|
-
# File: src/auth/jwt.py
|
|
48
|
-
SECRET_KEY = os.environ['SECRET_KEY'] # Raises KeyError if missing
|
|
49
|
-
|
|
50
|
-
# App won't start without SECRET_KEY - fail-secure
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
**Explicit validation**
|
|
54
|
-
```javascript
|
|
55
|
-
// File: config/database.js
|
|
56
|
-
if (!process.env.DB_PASSWORD) {
|
|
57
|
-
throw new Error('DB_PASSWORD environment variable required');
|
|
58
|
-
}
|
|
59
|
-
const DB_PASSWORD = process.env.DB_PASSWORD;
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**Test fixtures (clearly scoped)**
|
|
63
|
-
```python
|
|
64
|
-
# File: tests/fixtures/auth.py
|
|
65
|
-
TEST_SECRET = 'test-secret-key-123' # OK - test-only
|
|
66
|
-
|
|
67
|
-
# Usage in test
|
|
68
|
-
def test_token_creation():
|
|
69
|
-
token = create_token('user1', secret=TEST_SECRET)
|
|
70
|
-
```
|
|
1
|
+
# Fallback Secrets
|
|
2
|
+
|
|
3
|
+
**Report when:** A default value supplied when the env var is absent, where that value feeds signing, encryption, session, or token machinery.
|
|
4
|
+
|
|
5
|
+
**Skip when:** Defaults generated per-boot at random. Values only used as cache keys or correlation ids.
|
|
6
|
+
|
|
7
|
+
The decisive question is not whether a literal exists. It is whether the app **runs** with it. `env.get(X, Y)` runs; `env[X]` crashes. That difference is the whole finding.
|
|
8
|
+
|
|
9
|
+
## VULNERABLE - Report These
|
|
10
|
+
|
|
11
|
+
**Python: Environment variable with fallback**
|
|
12
|
+
```python
|
|
13
|
+
# File: src/auth/jwt.py
|
|
14
|
+
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-123')
|
|
15
|
+
|
|
16
|
+
# Used in security context
|
|
17
|
+
def create_token(user_id):
|
|
18
|
+
return jwt.encode({'user_id': user_id}, SECRET_KEY, algorithm='HS256')
|
|
19
|
+
```
|
|
20
|
+
**Why vulnerable:** App runs with known secret if `SECRET_KEY` is missing. Attacker can forge tokens.
|
|
21
|
+
|
|
22
|
+
**JavaScript: Logical OR fallback**
|
|
23
|
+
```javascript
|
|
24
|
+
// File: config/database.js
|
|
25
|
+
const DB_PASSWORD = process.env.DB_PASSWORD || 'admin123';
|
|
26
|
+
|
|
27
|
+
const pool = new Pool({
|
|
28
|
+
user: 'admin',
|
|
29
|
+
password: DB_PASSWORD,
|
|
30
|
+
database: 'production'
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
**Why vulnerable:** Database accepts hardcoded password in production if env var missing.
|
|
34
|
+
|
|
35
|
+
**Ruby: fetch with default**
|
|
36
|
+
```ruby
|
|
37
|
+
# File: config/secrets.rb
|
|
38
|
+
Rails.application.credentials.secret_key_base =
|
|
39
|
+
ENV.fetch('SECRET_KEY_BASE', 'fallback-secret-base')
|
|
40
|
+
```
|
|
41
|
+
**Why vulnerable:** Rails session encryption uses weak known key as fallback.
|
|
42
|
+
|
|
43
|
+
## SECURE - Skip These
|
|
44
|
+
|
|
45
|
+
**Fail-secure: Crashes without config**
|
|
46
|
+
```python
|
|
47
|
+
# File: src/auth/jwt.py
|
|
48
|
+
SECRET_KEY = os.environ['SECRET_KEY'] # Raises KeyError if missing
|
|
49
|
+
|
|
50
|
+
# App won't start without SECRET_KEY - fail-secure
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Explicit validation**
|
|
54
|
+
```javascript
|
|
55
|
+
// File: config/database.js
|
|
56
|
+
if (!process.env.DB_PASSWORD) {
|
|
57
|
+
throw new Error('DB_PASSWORD environment variable required');
|
|
58
|
+
}
|
|
59
|
+
const DB_PASSWORD = process.env.DB_PASSWORD;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Test fixtures (clearly scoped)**
|
|
63
|
+
```python
|
|
64
|
+
# File: tests/fixtures/auth.py
|
|
65
|
+
TEST_SECRET = 'test-secret-key-123' # OK - test-only
|
|
66
|
+
|
|
67
|
+
# Usage in test
|
|
68
|
+
def test_token_creation():
|
|
69
|
+
token = create_token('user1', secret=TEST_SECRET)
|
|
70
|
+
```
|