@vigolium/piolium 0.0.1
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/LICENSE +21 -0
- package/README.md +117 -0
- package/agents/access-auditor.md +300 -0
- package/agents/assumption-breaker.md +154 -0
- package/agents/attack-designer.md +116 -0
- package/agents/code-scanner.md +139 -0
- package/agents/concurrency-auditor.md +238 -0
- package/agents/confirm-writer.md +257 -0
- package/agents/context-reviewer.md +274 -0
- package/agents/cross-verifier.md +165 -0
- package/agents/cve-scout.md +381 -0
- package/agents/env-builder.md +282 -0
- package/agents/env-profiler.md +205 -0
- package/agents/evidence-collector.md +140 -0
- package/agents/finding-grader.md +142 -0
- package/agents/finding-writer.md +148 -0
- package/agents/flow-tracer.md +106 -0
- package/agents/goal-backtracer.md +146 -0
- package/agents/history-miner.md +467 -0
- package/agents/independent-verifier.md +118 -0
- package/agents/intent-mapper.md +183 -0
- package/agents/longshot-collector.md +128 -0
- package/agents/longshot-prober.md +126 -0
- package/agents/patch-auditor.md +73 -0
- package/agents/poc-author.md +124 -0
- package/agents/poc-runner.md +194 -0
- package/agents/probe-lead.md +269 -0
- package/agents/red-challenger.md +101 -0
- package/agents/report-composer.md +208 -0
- package/agents/review-adjudicator.md +216 -0
- package/agents/spec-auditor.md +155 -0
- package/agents/taint-tracer.md +265 -0
- package/agents/test-locator.md +209 -0
- package/agents/threat-modeler.md +132 -0
- package/agents/variant-scanner.md +108 -0
- package/agents/variant-spotter.md +110 -0
- package/bin/piolium.mjs +376 -0
- package/extensions/piolium/_vendor/yaml.bundle.d.mts +6 -0
- package/extensions/piolium/_vendor/yaml.bundle.mjs +139 -0
- package/extensions/piolium/agent-runner.ts +322 -0
- package/extensions/piolium/agents.ts +266 -0
- package/extensions/piolium/audit-state.ts +522 -0
- package/extensions/piolium/bundled-resources.ts +97 -0
- package/extensions/piolium/candidate-scan.ts +966 -0
- package/extensions/piolium/command-target.ts +177 -0
- package/extensions/piolium/console-stream.ts +57 -0
- package/extensions/piolium/export-results.ts +380 -0
- package/extensions/piolium/findings.ts +448 -0
- package/extensions/piolium/heartbeat.ts +182 -0
- package/extensions/piolium/help.ts +234 -0
- package/extensions/piolium/index.ts +1865 -0
- package/extensions/piolium/longshot.ts +530 -0
- package/extensions/piolium/matcher-suggestions.ts +196 -0
- package/extensions/piolium/matcher-utils.ts +83 -0
- package/extensions/piolium/modes/balanced.ts +750 -0
- package/extensions/piolium/modes/confirm-bootstrap.ts +186 -0
- package/extensions/piolium/modes/confirm.ts +697 -0
- package/extensions/piolium/modes/deep.ts +917 -0
- package/extensions/piolium/modes/diff.ts +177 -0
- package/extensions/piolium/modes/lite.ts +540 -0
- package/extensions/piolium/modes/longshot.ts +595 -0
- package/extensions/piolium/modes/merge.ts +204 -0
- package/extensions/piolium/modes/phase-runner.ts +267 -0
- package/extensions/piolium/modes/reinvest.ts +546 -0
- package/extensions/piolium/modes/revisit.ts +279 -0
- package/extensions/piolium/modes.ts +48 -0
- package/extensions/piolium/phase-labels.ts +123 -0
- package/extensions/piolium/phase-status-strip.ts +92 -0
- package/extensions/piolium/prompt-prefix-editor.ts +39 -0
- package/extensions/piolium/providers/anthropic-vertex.ts +836 -0
- package/extensions/piolium/recon.ts +409 -0
- package/extensions/piolium/result-stats.ts +105 -0
- package/extensions/piolium/retry.ts +120 -0
- package/extensions/piolium/scheduler.ts +212 -0
- package/extensions/piolium/secrets.ts +368 -0
- package/extensions/piolium/tools/web-tools.ts +148 -0
- package/package.json +77 -0
- package/skills/agentic-actions-auditor/SKILL.md +327 -0
- package/skills/agentic-actions-auditor/references/action-profiles.md +186 -0
- package/skills/agentic-actions-auditor/references/cross-file-resolution.md +209 -0
- package/skills/agentic-actions-auditor/references/foundations.md +94 -0
- package/skills/agentic-actions-auditor/references/vector-a-env-var-intermediary.md +77 -0
- package/skills/agentic-actions-auditor/references/vector-b-direct-expression-injection.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-c-cli-data-fetch.md +83 -0
- package/skills/agentic-actions-auditor/references/vector-d-pr-target-checkout.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-e-error-log-injection.md +88 -0
- package/skills/agentic-actions-auditor/references/vector-f-subshell-expansion.md +82 -0
- package/skills/agentic-actions-auditor/references/vector-g-eval-of-ai-output.md +91 -0
- package/skills/agentic-actions-auditor/references/vector-h-dangerous-sandbox-configs.md +102 -0
- package/skills/agentic-actions-auditor/references/vector-i-wildcard-allowlists.md +88 -0
- package/skills/audit/SKILL.md +562 -0
- package/skills/audit/assets/icon.svg +7 -0
- package/skills/audit/hooks/scripts/validate_phase_output.py +550 -0
- package/skills/audit/references/adversarial-review.md +148 -0
- package/skills/audit/references/architecture-aware-sast.md +306 -0
- package/skills/audit/references/audit-workflow.md +737 -0
- package/skills/audit/references/chamber-protocol.md +384 -0
- package/skills/audit/references/creative-attack-modes.md +221 -0
- package/skills/audit/references/deep-analysis.md +273 -0
- package/skills/audit/references/domain-attack-playbooks.md +1129 -0
- package/skills/audit/references/knowledge-base-template.md +513 -0
- package/skills/audit/references/real-env-validation.md +191 -0
- package/skills/audit/references/report-templates.md +417 -0
- package/skills/audit/references/triage-and-prereqs.md +134 -0
- package/skills/audit/scripts/consolidate_drafts.py +554 -0
- package/skills/audit/scripts/partition_findings.py +152 -0
- package/skills/audit/scripts/rg-hotspots.sh +121 -0
- package/skills/audit/scripts/stamp_file_state.py +349 -0
- package/skills/code-reviewer/SKILL.md +65 -0
- package/skills/codeql/SKILL.md +281 -0
- package/skills/codeql/references/build-fixes.md +90 -0
- package/skills/codeql/references/diagnostic-query-templates.md +339 -0
- package/skills/codeql/references/extension-yaml-format.md +209 -0
- package/skills/codeql/references/important-only-suite.md +153 -0
- package/skills/codeql/references/language-details.md +207 -0
- package/skills/codeql/references/macos-arm64e-workaround.md +179 -0
- package/skills/codeql/references/performance-tuning.md +111 -0
- package/skills/codeql/references/quality-assessment.md +172 -0
- package/skills/codeql/references/ruleset-catalog.md +63 -0
- package/skills/codeql/references/run-all-suite.md +92 -0
- package/skills/codeql/references/sarif-processing.md +79 -0
- package/skills/codeql/references/threat-models.md +51 -0
- package/skills/codeql/workflows/build-database.md +280 -0
- package/skills/codeql/workflows/create-data-extensions.md +261 -0
- package/skills/codeql/workflows/run-analysis.md +301 -0
- package/skills/differential-review/SKILL.md +220 -0
- package/skills/differential-review/adversarial.md +203 -0
- package/skills/differential-review/methodology.md +234 -0
- package/skills/differential-review/patterns.md +300 -0
- package/skills/differential-review/reporting.md +369 -0
- package/skills/fp-check/SKILL.md +125 -0
- package/skills/fp-check/references/bug-class-verification.md +114 -0
- package/skills/fp-check/references/deep-verification.md +143 -0
- package/skills/fp-check/references/evidence-templates.md +91 -0
- package/skills/fp-check/references/false-positive-patterns.md +115 -0
- package/skills/fp-check/references/gate-reviews.md +27 -0
- package/skills/fp-check/references/standard-verification.md +78 -0
- package/skills/insecure-defaults/SKILL.md +117 -0
- package/skills/insecure-defaults/references/examples.md +409 -0
- package/skills/last30days/SKILL.md +444 -0
- package/skills/sarif-parsing/SKILL.md +483 -0
- package/skills/sarif-parsing/resources/jq-queries.md +162 -0
- package/skills/sarif-parsing/resources/sarif_helpers.py +331 -0
- package/skills/security-threat-model/LICENSE.txt +201 -0
- package/skills/security-threat-model/SKILL.md +81 -0
- package/skills/security-threat-model/agents/openai.yaml +4 -0
- package/skills/security-threat-model/references/prompt-template.md +255 -0
- package/skills/security-threat-model/references/security-controls-and-assets.md +32 -0
- package/skills/semgrep/SKILL.md +212 -0
- package/skills/semgrep/references/rulesets.md +162 -0
- package/skills/semgrep/references/scan-modes.md +110 -0
- package/skills/semgrep/references/scanner-task-prompt.md +140 -0
- package/skills/semgrep/scripts/merge_sarif.py +203 -0
- package/skills/semgrep/workflows/scan-workflow.md +311 -0
- package/skills/semgrep-rule-creator/SKILL.md +168 -0
- package/skills/semgrep-rule-creator/references/quick-reference.md +202 -0
- package/skills/semgrep-rule-creator/references/workflow.md +240 -0
- package/skills/semgrep-rule-variant-creator/SKILL.md +205 -0
- package/skills/semgrep-rule-variant-creator/references/applicability-analysis.md +250 -0
- package/skills/semgrep-rule-variant-creator/references/language-syntax-guide.md +324 -0
- package/skills/semgrep-rule-variant-creator/references/workflow.md +518 -0
- package/skills/sharp-edges/SKILL.md +292 -0
- package/skills/sharp-edges/references/auth-patterns.md +252 -0
- package/skills/sharp-edges/references/case-studies.md +274 -0
- package/skills/sharp-edges/references/config-patterns.md +333 -0
- package/skills/sharp-edges/references/crypto-apis.md +190 -0
- package/skills/sharp-edges/references/lang-c.md +205 -0
- package/skills/sharp-edges/references/lang-csharp.md +285 -0
- package/skills/sharp-edges/references/lang-go.md +270 -0
- package/skills/sharp-edges/references/lang-java.md +263 -0
- package/skills/sharp-edges/references/lang-javascript.md +269 -0
- package/skills/sharp-edges/references/lang-kotlin.md +265 -0
- package/skills/sharp-edges/references/lang-php.md +245 -0
- package/skills/sharp-edges/references/lang-python.md +274 -0
- package/skills/sharp-edges/references/lang-ruby.md +273 -0
- package/skills/sharp-edges/references/lang-rust.md +272 -0
- package/skills/sharp-edges/references/lang-swift.md +287 -0
- package/skills/sharp-edges/references/language-specific.md +588 -0
- package/skills/spec-to-code-compliance/SKILL.md +357 -0
- package/skills/spec-to-code-compliance/resources/COMPLETENESS_CHECKLIST.md +69 -0
- package/skills/spec-to-code-compliance/resources/IR_EXAMPLES.md +417 -0
- package/skills/spec-to-code-compliance/resources/OUTPUT_REQUIREMENTS.md +105 -0
- package/skills/supply-chain-risk-auditor/SKILL.md +67 -0
- package/skills/supply-chain-risk-auditor/resources/results-template.md +41 -0
- package/skills/variant-analysis/METHODOLOGY.md +327 -0
- package/skills/variant-analysis/SKILL.md +142 -0
- package/skills/variant-analysis/resources/codeql/cpp.ql +119 -0
- package/skills/variant-analysis/resources/codeql/go.ql +69 -0
- package/skills/variant-analysis/resources/codeql/java.ql +71 -0
- package/skills/variant-analysis/resources/codeql/javascript.ql +63 -0
- package/skills/variant-analysis/resources/codeql/python.ql +80 -0
- package/skills/variant-analysis/resources/semgrep/cpp.yaml +98 -0
- package/skills/variant-analysis/resources/semgrep/go.yaml +63 -0
- package/skills/variant-analysis/resources/semgrep/java.yaml +61 -0
- package/skills/variant-analysis/resources/semgrep/javascript.yaml +60 -0
- package/skills/variant-analysis/resources/semgrep/python.yaml +72 -0
- package/skills/variant-analysis/resources/variant-report-template.md +75 -0
- package/skills/vuln-report/SKILL.md +137 -0
- package/skills/vuln-report/agents/openai.yaml +4 -0
- package/skills/vuln-report/references/report-template.md +135 -0
- package/skills/wooyun-legacy/SKILL.md +367 -0
- package/skills/wooyun-legacy/references/bank-penetration.md +222 -0
- package/skills/wooyun-legacy/references/checklists/command-execution-checklist.md +119 -0
- package/skills/wooyun-legacy/references/checklists/csrf-checklist.md +74 -0
- package/skills/wooyun-legacy/references/checklists/file-upload-checklist.md +108 -0
- package/skills/wooyun-legacy/references/checklists/info-disclosure-checklist.md +114 -0
- package/skills/wooyun-legacy/references/checklists/logic-flaws-checklist.md +95 -0
- package/skills/wooyun-legacy/references/checklists/misconfig-checklist.md +124 -0
- package/skills/wooyun-legacy/references/checklists/path-traversal-checklist.md +87 -0
- package/skills/wooyun-legacy/references/checklists/rce-checklist.md +93 -0
- package/skills/wooyun-legacy/references/checklists/sql-injection-checklist.md +97 -0
- package/skills/wooyun-legacy/references/checklists/ssrf-checklist.md +99 -0
- package/skills/wooyun-legacy/references/checklists/unauthorized-access-checklist.md +89 -0
- package/skills/wooyun-legacy/references/checklists/weak-password-checklist.md +115 -0
- package/skills/wooyun-legacy/references/checklists/xss-checklist.md +103 -0
- package/skills/wooyun-legacy/references/checklists/xxe-checklist.md +130 -0
- package/skills/wooyun-legacy/references/info-disclosure.md +975 -0
- package/skills/wooyun-legacy/references/logic-flaws.md +721 -0
- package/skills/wooyun-legacy/references/path-traversal.md +1191 -0
- package/skills/wooyun-legacy/references/telecom-penetration.md +156 -0
- package/skills/wooyun-legacy/references/unauthorized-access.md +980 -0
- package/skills/wooyun-legacy/references/xss.md +746 -0
- package/skills/zeroize-audit/SKILL.md +371 -0
- package/skills/zeroize-audit/configs/c.yaml +21 -0
- package/skills/zeroize-audit/configs/default.yaml +128 -0
- package/skills/zeroize-audit/configs/rust.yaml +83 -0
- package/skills/zeroize-audit/prompts/report_template.md +238 -0
- package/skills/zeroize-audit/prompts/system.md +163 -0
- package/skills/zeroize-audit/prompts/task.md +97 -0
- package/skills/zeroize-audit/references/compile-commands.md +231 -0
- package/skills/zeroize-audit/references/detection-strategy.md +191 -0
- package/skills/zeroize-audit/references/ir-analysis.md +252 -0
- package/skills/zeroize-audit/references/mcp-analysis.md +221 -0
- package/skills/zeroize-audit/references/poc-generation.md +470 -0
- package/skills/zeroize-audit/references/rust-zeroization-patterns.md +867 -0
- package/skills/zeroize-audit/schemas/input.json +83 -0
- package/skills/zeroize-audit/schemas/output.json +140 -0
- package/skills/zeroize-audit/tools/analyze_asm.sh +202 -0
- package/skills/zeroize-audit/tools/analyze_cfg.py +381 -0
- package/skills/zeroize-audit/tools/analyze_heap.sh +211 -0
- package/skills/zeroize-audit/tools/analyze_ir_semantic.py +429 -0
- package/skills/zeroize-audit/tools/diff_ir.sh +135 -0
- package/skills/zeroize-audit/tools/diff_rust_mir.sh +189 -0
- package/skills/zeroize-audit/tools/emit_asm.sh +67 -0
- package/skills/zeroize-audit/tools/emit_ir.sh +77 -0
- package/skills/zeroize-audit/tools/emit_rust_asm.sh +178 -0
- package/skills/zeroize-audit/tools/emit_rust_ir.sh +150 -0
- package/skills/zeroize-audit/tools/emit_rust_mir.sh +158 -0
- package/skills/zeroize-audit/tools/extract_compile_flags.py +284 -0
- package/skills/zeroize-audit/tools/generate_poc.py +1329 -0
- package/skills/zeroize-audit/tools/mcp/apply_confidence_gates.py +113 -0
- package/skills/zeroize-audit/tools/mcp/check_mcp.sh +68 -0
- package/skills/zeroize-audit/tools/mcp/normalize_mcp_evidence.py +125 -0
- package/skills/zeroize-audit/tools/scripts/check_llvm_patterns.py +481 -0
- package/skills/zeroize-audit/tools/scripts/check_mir_patterns.py +554 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm.py +424 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_aarch64.py +300 -0
- package/skills/zeroize-audit/tools/scripts/check_rust_asm_x86.py +283 -0
- package/skills/zeroize-audit/tools/scripts/find_dangerous_apis.py +375 -0
- package/skills/zeroize-audit/tools/scripts/semantic_audit.py +923 -0
- package/skills/zeroize-audit/tools/track_dataflow.sh +196 -0
- package/skills/zeroize-audit/tools/validate_rust_toolchain.sh +298 -0
- package/skills/zeroize-audit/workflows/phase-0-preflight.md +150 -0
- package/skills/zeroize-audit/workflows/phase-1-source-analysis.md +144 -0
- package/skills/zeroize-audit/workflows/phase-2-compiler-analysis.md +139 -0
- package/skills/zeroize-audit/workflows/phase-3-interim-report.md +46 -0
- package/skills/zeroize-audit/workflows/phase-4-poc-generation.md +46 -0
- package/skills/zeroize-audit/workflows/phase-5-poc-validation.md +136 -0
- package/skills/zeroize-audit/workflows/phase-6-final-report.md +44 -0
- package/skills/zeroize-audit/workflows/phase-7-test-generation.md +42 -0
- package/themes/piolium-srcery.json +94 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Standard Verification
|
|
2
|
+
|
|
3
|
+
Linear single-pass checklist for straightforward bugs. No task creation — work through each step sequentially and document findings inline.
|
|
4
|
+
|
|
5
|
+
## Escalation Checkpoints
|
|
6
|
+
|
|
7
|
+
Two points in this checklist may trigger escalation to [deep-verification.md]({baseDir}/references/deep-verification.md):
|
|
8
|
+
|
|
9
|
+
1. **After Step 1 (Data Flow)**: Escalate if 3+ trust boundaries, callbacks/async control flow, or ambiguous validation chain
|
|
10
|
+
2. **After Step 5 (Devil's Advocate)**: Escalate if any question produces genuine uncertainty you cannot resolve
|
|
11
|
+
|
|
12
|
+
When escalating, hand off all evidence gathered so far — deep verification will continue from where you left off.
|
|
13
|
+
|
|
14
|
+
## Checklist
|
|
15
|
+
|
|
16
|
+
### Step 1: Data Flow
|
|
17
|
+
|
|
18
|
+
Trace data from source to the alleged vulnerability sink.
|
|
19
|
+
|
|
20
|
+
- Map trust boundaries crossed (internal/trusted vs external/untrusted)
|
|
21
|
+
- Identify all validation and sanitization between source and sink
|
|
22
|
+
- Check API contracts — many APIs have built-in bounds protection that prevents the alleged issue
|
|
23
|
+
- Check for environmental protections (compiler, runtime, OS, framework) that prevent exploitation entirely (not just raise the bar)
|
|
24
|
+
- Apply class-specific checks from [bug-class-verification.md]({baseDir}/references/bug-class-verification.md)
|
|
25
|
+
|
|
26
|
+
**Key pitfall**: Analyzing the vulnerable code in isolation. Conditional logic upstream may make the vulnerability mathematically unreachable. Trace the full validation chain.
|
|
27
|
+
|
|
28
|
+
**Escalation check**: If you found 3+ trust boundaries, callbacks or async control flow in the path, or an ambiguous validation chain — escalate to deep verification.
|
|
29
|
+
|
|
30
|
+
### Step 2: Exploitability
|
|
31
|
+
|
|
32
|
+
Prove the attacker can trigger the vulnerability.
|
|
33
|
+
|
|
34
|
+
- **Attacker control**: Prove the attacker controls data reaching the vulnerable operation. Internal storage set by trusted components is not attacker-controlled.
|
|
35
|
+
- **Bounds proof**: For integer/bounds issues, create an explicit algebraic proof using the template in [evidence-templates.md]({baseDir}/references/evidence-templates.md). Verify: IF validation_check_passes THEN bounds_guarantee_holds.
|
|
36
|
+
- **Race feasibility**: For race conditions, prove concurrent access is actually possible. Single-threaded initialization and synchronized contexts cannot have races.
|
|
37
|
+
|
|
38
|
+
### Step 3: Impact
|
|
39
|
+
|
|
40
|
+
Determine whether exploitation has real security consequences.
|
|
41
|
+
|
|
42
|
+
- Distinguish real security impact (RCE, privesc, info disclosure) from operational robustness issues (crash recovery, cleanup failure)
|
|
43
|
+
- Distinguish primary security controls from defense-in-depth. Failure of a defense-in-depth measure is not a vulnerability if primary protections remain intact.
|
|
44
|
+
|
|
45
|
+
### Step 4: PoC Sketch
|
|
46
|
+
|
|
47
|
+
Create a pseudocode PoC showing the attack path. Executable and unit test PoCs are optional for standard verification.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Data Flow: [Source] → [Validation?] → [Transform?] → [Vulnerable Op] → [Impact]
|
|
51
|
+
Attacker controls: [what input, how]
|
|
52
|
+
Trigger: [pseudocode showing the exploit path]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
See [evidence-templates.md]({baseDir}/references/evidence-templates.md) for the full PoC template.
|
|
56
|
+
|
|
57
|
+
### Step 5: Devil's Advocate Spot-Check
|
|
58
|
+
|
|
59
|
+
Answer these 7 questions. If any produces genuine uncertainty, escalate to deep verification.
|
|
60
|
+
|
|
61
|
+
**Against the vulnerability:**
|
|
62
|
+
|
|
63
|
+
1. Am I seeing a vulnerability because the pattern "looks dangerous" rather than because it actually is? (pattern-matching bias)
|
|
64
|
+
2. Am I incorrectly assuming attacker control over trusted data? (trust boundary confusion)
|
|
65
|
+
3. Have I rigorously proven the mathematical condition for vulnerability can occur? (proof rigor)
|
|
66
|
+
4. Am I confusing defense-in-depth failure with a primary security vulnerability? (defense-in-depth confusion)
|
|
67
|
+
5. Am I hallucinating this vulnerability? LLMs are biased toward seeing bugs everywhere — is this actually real or am I pattern-matching on scary-looking code? (LLM self-check)
|
|
68
|
+
|
|
69
|
+
**For the vulnerability (always ask — false-negative protection):**
|
|
70
|
+
|
|
71
|
+
6. Am I dismissing a real vulnerability because the exploit seems complex or unlikely?
|
|
72
|
+
7. Am I inventing mitigations or validation logic that I haven't verified in the actual source code? Re-read the code after reaching a conclusion.
|
|
73
|
+
|
|
74
|
+
**Escalation check**: If any question above produces genuine uncertainty you cannot resolve with the evidence at hand — escalate to deep verification.
|
|
75
|
+
|
|
76
|
+
### Step 6: Gate Review
|
|
77
|
+
|
|
78
|
+
Apply all six gates from [gate-reviews.md]({baseDir}/references/gate-reviews.md) and all 13 items from [false-positive-patterns.md]({baseDir}/references/false-positive-patterns.md) to reach a verdict.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: insecure-defaults
|
|
3
|
+
description: "Detects fail-open insecure defaults (hardcoded secrets, weak auth, permissive security) that allow apps to run insecurely in production. Use when auditing security, reviewing config management, or analyzing environment variable handling."
|
|
4
|
+
allowed-tools:
|
|
5
|
+
- Read
|
|
6
|
+
- Grep
|
|
7
|
+
- Glob
|
|
8
|
+
- Bash
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Insecure Defaults Detection
|
|
12
|
+
|
|
13
|
+
Finds **fail-open** vulnerabilities where apps run insecurely with missing configuration. Distinguishes exploitable defaults from fail-secure patterns that crash safely.
|
|
14
|
+
|
|
15
|
+
- **Fail-open (CRITICAL):** `SECRET = env.get('KEY') or 'default'` → App runs with weak secret
|
|
16
|
+
- **Fail-secure (SAFE):** `SECRET = env['KEY']` → App crashes if missing
|
|
17
|
+
|
|
18
|
+
## When to Use
|
|
19
|
+
|
|
20
|
+
- **Security audits** of production applications (auth, crypto, API security)
|
|
21
|
+
- **Configuration review** of deployment files, IaC templates, Docker configs
|
|
22
|
+
- **Code review** of environment variable handling and secrets management
|
|
23
|
+
- **Pre-deployment checks** for hardcoded credentials or weak defaults
|
|
24
|
+
|
|
25
|
+
## When NOT to Use
|
|
26
|
+
|
|
27
|
+
Do not use this skill for:
|
|
28
|
+
- **Test fixtures** explicitly scoped to test environments (files in `test/`, `spec/`, `__tests__/`)
|
|
29
|
+
- **Example/template files** (`.example`, `.template`, `.sample` suffixes)
|
|
30
|
+
- **Development-only tools** (local Docker Compose for dev, debug scripts)
|
|
31
|
+
- **Documentation examples** in README.md or docs/ directories
|
|
32
|
+
- **Build-time configuration** that gets replaced during deployment
|
|
33
|
+
- **Crash-on-missing behavior** where app won't start without proper config (fail-secure)
|
|
34
|
+
|
|
35
|
+
When in doubt: trace the code path to determine if the app runs with the default or crashes.
|
|
36
|
+
|
|
37
|
+
## Rationalizations to Reject
|
|
38
|
+
|
|
39
|
+
- **"It's just a development default"** → If it reaches production code, it's a finding
|
|
40
|
+
- **"The production config overrides it"** → Verify prod config exists; code-level vulnerability remains if not
|
|
41
|
+
- **"This would never run without proper config"** → Prove it with code trace; many apps fail silently
|
|
42
|
+
- **"It's behind authentication"** → Defense in depth; compromised session still exploits weak defaults
|
|
43
|
+
- **"We'll fix it before release"** → Document now; "later" rarely comes
|
|
44
|
+
|
|
45
|
+
## Workflow
|
|
46
|
+
|
|
47
|
+
Follow this workflow for every potential finding:
|
|
48
|
+
|
|
49
|
+
### 1. SEARCH: Perform Project Discovery and Find Insecure Defaults
|
|
50
|
+
|
|
51
|
+
Determine language, framework, and project conventions. Use this information to further discover things like secret storage locations, secret usage patterns, credentialed third-party integrations, cryptography, and any other relevant configuration. Further use information to analyze insecure default configurations.
|
|
52
|
+
|
|
53
|
+
**Example**
|
|
54
|
+
Search for patterns in `**/config/`, `**/auth/`, `**/database/`, and env files:
|
|
55
|
+
- **Fallback secrets:** `getenv.*\) or ['"]`, `process\.env\.[A-Z_]+ \|\| ['"]`, `ENV\.fetch.*default:`
|
|
56
|
+
- **Hardcoded credentials:** `password.*=.*['"][^'"]{8,}['"]`, `api[_-]?key.*=.*['"][^'"]+['"]`
|
|
57
|
+
- **Weak defaults:** `DEBUG.*=.*true`, `AUTH.*=.*false`, `CORS.*=.*\*`
|
|
58
|
+
- **Crypto algorithms:** `MD5|SHA1|DES|RC4|ECB` in security contexts
|
|
59
|
+
|
|
60
|
+
Tailor search approach based on discovery results.
|
|
61
|
+
|
|
62
|
+
Focus on production-reachable code, not test fixtures or example files.
|
|
63
|
+
|
|
64
|
+
### 2. VERIFY: Actual Behavior
|
|
65
|
+
For each match, trace the code path to understand runtime behavior.
|
|
66
|
+
|
|
67
|
+
**Questions to answer:**
|
|
68
|
+
- When is this code executed? (Startup vs. runtime)
|
|
69
|
+
- What happens if a configuration variable is missing?
|
|
70
|
+
- Is there validation that enforces secure configuration?
|
|
71
|
+
|
|
72
|
+
### 3. CONFIRM: Production Impact
|
|
73
|
+
Determine if this issue reaches production:
|
|
74
|
+
|
|
75
|
+
If production config provides the variable → Lower severity (but still a code-level vulnerability)
|
|
76
|
+
If production config missing or uses default → CRITICAL
|
|
77
|
+
|
|
78
|
+
### 4. REPORT: with Evidence
|
|
79
|
+
|
|
80
|
+
**Example report:**
|
|
81
|
+
```
|
|
82
|
+
Finding: Hardcoded JWT Secret Fallback
|
|
83
|
+
Location: src/auth/jwt.ts:15
|
|
84
|
+
Pattern: const secret = process.env.JWT_SECRET || 'default';
|
|
85
|
+
|
|
86
|
+
Verification: App starts without JWT_SECRET; secret used in jwt.sign() at line 42
|
|
87
|
+
Production Impact: Dockerfile missing JWT_SECRET
|
|
88
|
+
Exploitation: Attacker forges JWTs using 'default', gains unauthorized access
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Quick Verification Checklist
|
|
92
|
+
|
|
93
|
+
**Fallback Secrets:** `SECRET = env.get(X) or Y`
|
|
94
|
+
→ Verify: App starts without env var? Secret used in crypto/auth?
|
|
95
|
+
→ Skip: Test fixtures, example files
|
|
96
|
+
|
|
97
|
+
**Default Credentials:** Hardcoded `username`/`password` pairs
|
|
98
|
+
→ Verify: Active in deployed config? No runtime override?
|
|
99
|
+
→ Skip: Disabled accounts, documentation examples
|
|
100
|
+
|
|
101
|
+
**Fail-Open Security:** `AUTH_REQUIRED = env.get(X, 'false')`
|
|
102
|
+
→ Verify: Default is insecure (false/disabled/permissive)?
|
|
103
|
+
→ Safe: App crashes or default is secure (true/enabled/restricted)
|
|
104
|
+
|
|
105
|
+
**Weak Crypto:** MD5/SHA1/DES/RC4/ECB in security contexts
|
|
106
|
+
→ Verify: Used for passwords, encryption, or tokens?
|
|
107
|
+
→ Skip: Checksums, non-security hashing
|
|
108
|
+
|
|
109
|
+
**Permissive Access:** CORS `*`, permissions `0777`, public-by-default
|
|
110
|
+
→ Verify: Default allows unauthorized access?
|
|
111
|
+
→ Skip: Explicitly configured permissiveness with justification
|
|
112
|
+
|
|
113
|
+
**Debug Features:** Stack traces, introspection, verbose errors
|
|
114
|
+
→ Verify: Enabled by default? Exposed in responses?
|
|
115
|
+
→ Skip: Logging-only, not user-facing
|
|
116
|
+
|
|
117
|
+
For detailed examples and counter-examples, see [examples.md](references/examples.md).
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
# Insecure Defaults: Examples and Counter-Examples
|
|
2
|
+
|
|
3
|
+
This document provides detailed examples for each category in the Quick Verification Checklist, showing both vulnerable patterns (report these) and secure patterns (skip these).
|
|
4
|
+
|
|
5
|
+
## Fallback Secrets
|
|
6
|
+
|
|
7
|
+
### ❌ VULNERABLE - Report These
|
|
8
|
+
|
|
9
|
+
**Python: Environment variable with fallback**
|
|
10
|
+
```python
|
|
11
|
+
# File: src/auth/jwt.py
|
|
12
|
+
SECRET_KEY = os.environ.get('SECRET_KEY', 'dev-secret-key-123')
|
|
13
|
+
|
|
14
|
+
# Used in security context
|
|
15
|
+
def create_token(user_id):
|
|
16
|
+
return jwt.encode({'user_id': user_id}, SECRET_KEY, algorithm='HS256')
|
|
17
|
+
```
|
|
18
|
+
**Why vulnerable:** App runs with known secret if `SECRET_KEY` is missing. Attacker can forge tokens.
|
|
19
|
+
|
|
20
|
+
**JavaScript: Logical OR fallback**
|
|
21
|
+
```javascript
|
|
22
|
+
// File: config/database.js
|
|
23
|
+
const DB_PASSWORD = process.env.DB_PASSWORD || 'admin123';
|
|
24
|
+
|
|
25
|
+
const pool = new Pool({
|
|
26
|
+
user: 'admin',
|
|
27
|
+
password: DB_PASSWORD,
|
|
28
|
+
database: 'production'
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
**Why vulnerable:** Database accepts hardcoded password in production if env var missing.
|
|
32
|
+
|
|
33
|
+
**Ruby: fetch with default**
|
|
34
|
+
```ruby
|
|
35
|
+
# File: config/secrets.rb
|
|
36
|
+
Rails.application.credentials.secret_key_base =
|
|
37
|
+
ENV.fetch('SECRET_KEY_BASE', 'fallback-secret-base')
|
|
38
|
+
```
|
|
39
|
+
**Why vulnerable:** Rails session encryption uses weak known key as fallback.
|
|
40
|
+
|
|
41
|
+
### ✅ SECURE - Skip These
|
|
42
|
+
|
|
43
|
+
**Fail-secure: Crashes without config**
|
|
44
|
+
```python
|
|
45
|
+
# File: src/auth/jwt.py
|
|
46
|
+
SECRET_KEY = os.environ['SECRET_KEY'] # Raises KeyError if missing
|
|
47
|
+
|
|
48
|
+
# App won't start without SECRET_KEY - fail-secure
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Explicit validation**
|
|
52
|
+
```javascript
|
|
53
|
+
// File: config/database.js
|
|
54
|
+
if (!process.env.DB_PASSWORD) {
|
|
55
|
+
throw new Error('DB_PASSWORD environment variable required');
|
|
56
|
+
}
|
|
57
|
+
const DB_PASSWORD = process.env.DB_PASSWORD;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**Test fixtures (clearly scoped)**
|
|
61
|
+
```python
|
|
62
|
+
# File: tests/fixtures/auth.py
|
|
63
|
+
TEST_SECRET = 'test-secret-key-123' # OK - test-only
|
|
64
|
+
|
|
65
|
+
# Usage in test
|
|
66
|
+
def test_token_creation():
|
|
67
|
+
token = create_token('user1', secret=TEST_SECRET)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Default Credentials
|
|
73
|
+
|
|
74
|
+
### ❌ VULNERABLE - Report These
|
|
75
|
+
|
|
76
|
+
**Hardcoded admin account**
|
|
77
|
+
```python
|
|
78
|
+
# File: src/models/user.py
|
|
79
|
+
def bootstrap_admin():
|
|
80
|
+
"""Create default admin account if none exists"""
|
|
81
|
+
if not User.query.filter_by(role='admin').first():
|
|
82
|
+
admin = User(
|
|
83
|
+
username='admin',
|
|
84
|
+
password=hash_password('admin123'),
|
|
85
|
+
role='admin'
|
|
86
|
+
)
|
|
87
|
+
db.session.add(admin)
|
|
88
|
+
db.session.commit()
|
|
89
|
+
```
|
|
90
|
+
**Why vulnerable:** Default admin account created on first run with known credentials.
|
|
91
|
+
|
|
92
|
+
**API key in code**
|
|
93
|
+
```javascript
|
|
94
|
+
// File: src/integrations/payment.js
|
|
95
|
+
const STRIPE_API_KEY = process.env.STRIPE_KEY || 'sk_tes...';
|
|
96
|
+
|
|
97
|
+
const stripe = require('stripe')(STRIPE_API_KEY);
|
|
98
|
+
```
|
|
99
|
+
**Why vulnerable:** Uses test API key if env var missing. Might reach production.
|
|
100
|
+
|
|
101
|
+
**Database connection string**
|
|
102
|
+
```java
|
|
103
|
+
// File: DatabaseConfig.java
|
|
104
|
+
private static final String DB_URL = System.getenv().getOrDefault(
|
|
105
|
+
"DATABASE_URL",
|
|
106
|
+
"postgresql://admin:password@localhost:5432/prod"
|
|
107
|
+
);
|
|
108
|
+
```
|
|
109
|
+
**Why vulnerable:** Hardcoded database credentials as fallback.
|
|
110
|
+
|
|
111
|
+
### ✅ SECURE - Skip These
|
|
112
|
+
|
|
113
|
+
**Disabled default account**
|
|
114
|
+
```python
|
|
115
|
+
# File: src/models/user.py
|
|
116
|
+
def bootstrap_admin():
|
|
117
|
+
"""Admin account MUST be configured via environment"""
|
|
118
|
+
username = os.environ['ADMIN_USERNAME']
|
|
119
|
+
password = os.environ['ADMIN_PASSWORD']
|
|
120
|
+
|
|
121
|
+
if not User.query.filter_by(username=username).first():
|
|
122
|
+
admin = User(username=username, password=hash_password(password), role='admin')
|
|
123
|
+
db.session.add(admin)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Example/documentation credentials**
|
|
127
|
+
```bash
|
|
128
|
+
# File: README.md
|
|
129
|
+
## Setup
|
|
130
|
+
|
|
131
|
+
Configure your API key:
|
|
132
|
+
```bash
|
|
133
|
+
export STRIPE_KEY='sk_tes...' # Example only
|
|
134
|
+
```
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Test fixture credentials**
|
|
138
|
+
```python
|
|
139
|
+
# File: tests/conftest.py
|
|
140
|
+
@pytest.fixture
|
|
141
|
+
def test_user():
|
|
142
|
+
return User(username='test_user', password='test_pass') # OK - test scope
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Fail-Open Security
|
|
148
|
+
|
|
149
|
+
### ❌ VULNERABLE - Report These
|
|
150
|
+
|
|
151
|
+
**Authentication disabled by default**
|
|
152
|
+
```python
|
|
153
|
+
# File: config/security.py
|
|
154
|
+
REQUIRE_AUTH = os.getenv('REQUIRE_AUTH', 'false').lower() == 'true'
|
|
155
|
+
|
|
156
|
+
@app.before_request
|
|
157
|
+
def check_auth():
|
|
158
|
+
if not REQUIRE_AUTH:
|
|
159
|
+
return # Skip auth check
|
|
160
|
+
# ... auth logic
|
|
161
|
+
```
|
|
162
|
+
**Why vulnerable:** Default is no authentication. App runs insecurely if env var missing.
|
|
163
|
+
|
|
164
|
+
**CORS allows all origins**
|
|
165
|
+
```javascript
|
|
166
|
+
// File: server.js
|
|
167
|
+
const allowedOrigins = process.env.ALLOWED_ORIGINS || '*';
|
|
168
|
+
|
|
169
|
+
app.use(cors({ origin: allowedOrigins }));
|
|
170
|
+
```
|
|
171
|
+
**Why vulnerable:** Default allows requests from any origin. XSS/CSRF risk.
|
|
172
|
+
|
|
173
|
+
**Debug mode enabled by default**
|
|
174
|
+
```python
|
|
175
|
+
# File: config.py
|
|
176
|
+
DEBUG = os.getenv('DEBUG', 'true').lower() != 'false' # Default: true
|
|
177
|
+
|
|
178
|
+
if DEBUG:
|
|
179
|
+
app.config['DEBUG'] = True
|
|
180
|
+
app.config['PROPAGATE_EXCEPTIONS'] = True
|
|
181
|
+
```
|
|
182
|
+
**Why vulnerable:** Debug mode default. Stack traces leak sensitive info in production.
|
|
183
|
+
|
|
184
|
+
### ✅ SECURE - Skip These
|
|
185
|
+
|
|
186
|
+
**Authentication required by default**
|
|
187
|
+
```python
|
|
188
|
+
# File: config/security.py
|
|
189
|
+
REQUIRE_AUTH = os.getenv('REQUIRE_AUTH', 'true').lower() == 'true' # Default: true
|
|
190
|
+
|
|
191
|
+
# Or better - crash if not explicitly configured
|
|
192
|
+
REQUIRE_AUTH = os.environ['REQUIRE_AUTH'].lower() == 'true'
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**CORS requires explicit configuration**
|
|
196
|
+
```javascript
|
|
197
|
+
// File: server.js
|
|
198
|
+
if (!process.env.ALLOWED_ORIGINS) {
|
|
199
|
+
throw new Error('ALLOWED_ORIGINS must be configured');
|
|
200
|
+
}
|
|
201
|
+
const allowedOrigins = process.env.ALLOWED_ORIGINS.split(',');
|
|
202
|
+
|
|
203
|
+
app.use(cors({ origin: allowedOrigins }));
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Debug mode disabled by default**
|
|
207
|
+
```python
|
|
208
|
+
# File: config.py
|
|
209
|
+
DEBUG = os.getenv('DEBUG', 'false').lower() == 'true' # Default: false
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
---
|
|
213
|
+
|
|
214
|
+
## Weak Crypto
|
|
215
|
+
|
|
216
|
+
### ❌ VULNERABLE - Report These
|
|
217
|
+
|
|
218
|
+
**MD5 for password hashing**
|
|
219
|
+
```python
|
|
220
|
+
# File: src/auth/passwords.py
|
|
221
|
+
import hashlib
|
|
222
|
+
|
|
223
|
+
def hash_password(password):
|
|
224
|
+
"""Hash user password"""
|
|
225
|
+
return hashlib.md5(password.encode()).hexdigest()
|
|
226
|
+
```
|
|
227
|
+
**Why vulnerable:** MD5 is cryptographically broken. Rainbow tables exist. Use bcrypt/Argon2.
|
|
228
|
+
|
|
229
|
+
**DES encryption for sensitive data**
|
|
230
|
+
```java
|
|
231
|
+
// File: Encryption.java
|
|
232
|
+
public static byte[] encrypt(String data, byte[] key) {
|
|
233
|
+
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
|
|
234
|
+
SecretKeySpec secretKey = new SecretKeySpec(key, "DES");
|
|
235
|
+
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
|
236
|
+
return cipher.doFinal(data.getBytes());
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
**Why vulnerable:** DES has 56-bit keys (brute-forceable). ECB mode leaks patterns.
|
|
240
|
+
|
|
241
|
+
**SHA1 for signature verification**
|
|
242
|
+
```javascript
|
|
243
|
+
// File: webhooks.js
|
|
244
|
+
function verifySignature(payload, signature) {
|
|
245
|
+
const hmac = crypto.createHmac('sha1', WEBHOOK_SECRET);
|
|
246
|
+
const computed = hmac.update(payload).digest('hex');
|
|
247
|
+
return computed === signature;
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
**Why vulnerable:** SHA1 collisions exist. Use SHA256 or better.
|
|
251
|
+
|
|
252
|
+
### ✅ SECURE - Skip These
|
|
253
|
+
|
|
254
|
+
**Weak crypto for non-security checksums**
|
|
255
|
+
```python
|
|
256
|
+
# File: src/utils/cache.py
|
|
257
|
+
import hashlib
|
|
258
|
+
|
|
259
|
+
def cache_key(data):
|
|
260
|
+
"""Generate cache key - not security-sensitive"""
|
|
261
|
+
return hashlib.md5(data.encode()).hexdigest() # OK - just for cache lookup
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
**Modern crypto for passwords**
|
|
265
|
+
```python
|
|
266
|
+
# File: src/auth/passwords.py
|
|
267
|
+
import bcrypt
|
|
268
|
+
|
|
269
|
+
def hash_password(password):
|
|
270
|
+
return bcrypt.hashpw(password.encode(), bcrypt.gensalt())
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**Strong encryption**
|
|
274
|
+
```java
|
|
275
|
+
// File: Encryption.java
|
|
276
|
+
Cipher cipher = Cipher.getInstance("AES/GCM/NoPadding");
|
|
277
|
+
// 256-bit key, authenticated encryption
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Permissive Access
|
|
283
|
+
|
|
284
|
+
### ❌ VULNERABLE - Report These
|
|
285
|
+
|
|
286
|
+
**File permissions world-writable**
|
|
287
|
+
```python
|
|
288
|
+
# File: src/storage/files.py
|
|
289
|
+
def create_secure_file(path):
|
|
290
|
+
fd = os.open(path, os.O_CREAT | os.O_WRONLY, 0o666) # rw-rw-rw-
|
|
291
|
+
return fd
|
|
292
|
+
```
|
|
293
|
+
**Why vulnerable:** Any user can write to file. Should be 0o600 or 0o644.
|
|
294
|
+
|
|
295
|
+
**S3 bucket public by default**
|
|
296
|
+
```python
|
|
297
|
+
# File: infrastructure/storage.py
|
|
298
|
+
def create_storage_bucket(name):
|
|
299
|
+
bucket = s3.create_bucket(
|
|
300
|
+
Bucket=name,
|
|
301
|
+
ACL='public-read' # Publicly readable by default
|
|
302
|
+
)
|
|
303
|
+
```
|
|
304
|
+
**Why vulnerable:** Sensitive data exposed publicly. Should require explicit configuration.
|
|
305
|
+
|
|
306
|
+
**API allows any origin**
|
|
307
|
+
```python
|
|
308
|
+
# File: app.py
|
|
309
|
+
@app.after_request
|
|
310
|
+
def after_request(response):
|
|
311
|
+
response.headers['Access-Control-Allow-Origin'] = '*'
|
|
312
|
+
response.headers['Access-Control-Allow-Credentials'] = 'true'
|
|
313
|
+
return response
|
|
314
|
+
```
|
|
315
|
+
**Why vulnerable:** CORS misconfiguration. Allows credential theft from any site.
|
|
316
|
+
|
|
317
|
+
### ✅ SECURE - Skip These
|
|
318
|
+
|
|
319
|
+
**Explicitly configured permissiveness with justification**
|
|
320
|
+
```python
|
|
321
|
+
# File: src/storage/public_assets.py
|
|
322
|
+
def create_public_asset(path):
|
|
323
|
+
"""Create world-readable asset for CDN distribution"""
|
|
324
|
+
# Intentionally public - static assets only
|
|
325
|
+
fd = os.open(path, os.O_CREAT | os.O_WRONLY, 0o644)
|
|
326
|
+
return fd
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
**Restrictive by default**
|
|
330
|
+
```python
|
|
331
|
+
# File: infrastructure/storage.py
|
|
332
|
+
def create_storage_bucket(name, public=False):
|
|
333
|
+
acl = 'public-read' if public else 'private'
|
|
334
|
+
if public:
|
|
335
|
+
logger.warning(f'Creating PUBLIC bucket: {name}')
|
|
336
|
+
bucket = s3.create_bucket(Bucket=name, ACL=acl)
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
## Debug Features
|
|
342
|
+
|
|
343
|
+
### ❌ VULNERABLE - Report These
|
|
344
|
+
|
|
345
|
+
**Stack traces in API responses**
|
|
346
|
+
```python
|
|
347
|
+
# File: app.py
|
|
348
|
+
@app.errorhandler(Exception)
|
|
349
|
+
def handle_error(error):
|
|
350
|
+
return jsonify({
|
|
351
|
+
'error': str(error),
|
|
352
|
+
'traceback': traceback.format_exc() # Leaks internal paths, library versions
|
|
353
|
+
}), 500
|
|
354
|
+
```
|
|
355
|
+
**Why vulnerable:** Exposes internal implementation details to attackers.
|
|
356
|
+
|
|
357
|
+
**GraphQL introspection enabled**
|
|
358
|
+
```javascript
|
|
359
|
+
// File: server.js
|
|
360
|
+
const server = new ApolloServer({
|
|
361
|
+
typeDefs,
|
|
362
|
+
resolvers,
|
|
363
|
+
introspection: true, // Enabled in production
|
|
364
|
+
playground: true
|
|
365
|
+
});
|
|
366
|
+
```
|
|
367
|
+
**Why vulnerable:** Attackers can discover entire API schema, including admin-only fields.
|
|
368
|
+
|
|
369
|
+
**Verbose error messages**
|
|
370
|
+
```java
|
|
371
|
+
// File: UserController.java
|
|
372
|
+
catch (SQLException e) {
|
|
373
|
+
return ResponseEntity.status(500).body(
|
|
374
|
+
"Database error: " + e.getMessage() // Leaks table names, constraints
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
```
|
|
378
|
+
**Why vulnerable:** SQL error messages reveal database structure.
|
|
379
|
+
|
|
380
|
+
### ✅ SECURE - Skip These
|
|
381
|
+
|
|
382
|
+
**Debug features in logging only**
|
|
383
|
+
```python
|
|
384
|
+
# File: app.py
|
|
385
|
+
@app.errorhandler(Exception)
|
|
386
|
+
def handle_error(error):
|
|
387
|
+
logger.exception('Request failed', exc_info=error) # Logs full trace
|
|
388
|
+
return jsonify({'error': 'Internal server error'}), 500 # Generic to user
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
**Environment-aware debug settings**
|
|
392
|
+
```javascript
|
|
393
|
+
// File: server.js
|
|
394
|
+
const server = new ApolloServer({
|
|
395
|
+
typeDefs,
|
|
396
|
+
resolvers,
|
|
397
|
+
introspection: process.env.NODE_ENV !== 'production',
|
|
398
|
+
playground: process.env.NODE_ENV !== 'production'
|
|
399
|
+
});
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
**Generic user-facing errors**
|
|
403
|
+
```java
|
|
404
|
+
// File: UserController.java
|
|
405
|
+
catch (SQLException e) {
|
|
406
|
+
logger.error("Database error", e); // Full details to logs
|
|
407
|
+
return ResponseEntity.status(500).body("Unable to process request"); // Generic
|
|
408
|
+
}
|
|
409
|
+
```
|