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.
Files changed (250) hide show
  1. package/README.md +57 -26
  2. package/README.pt-BR.md +443 -0
  3. package/agents/cloud-engineer.md +77 -0
  4. package/agents/code-sentinel.md +71 -34
  5. package/agents/database-architect.md +31 -25
  6. package/agents/frontend-designer.md +30 -28
  7. package/agents/mobile-designer.md +25 -24
  8. package/agents/modernizer.md +68 -0
  9. package/agents/orchestrator.md +107 -93
  10. package/agents/reviewer.md +102 -71
  11. package/agents/security-auditor.md +27 -27
  12. package/agents/tester.md +97 -90
  13. package/commands/grill-me.md +20 -4
  14. package/commands/orchestrate.md +16 -0
  15. package/commands/orchestrator.md +16 -0
  16. package/commands/plan.md +17 -1
  17. package/config/agents.json +31 -3
  18. package/config/mcp.json +72 -0
  19. package/config/models.json +26 -16
  20. package/config/profiles.json +2 -4
  21. package/config/skills.json +762 -573
  22. package/docs/SKILLS.md +393 -275
  23. package/docs/designs/old/2026-10-31 plan-lifecycle-backlog-and-clean-code-skill.md +87 -0
  24. package/docs/designs/old/2026-11-02 skill-upstream-audit-and-update.md +105 -0
  25. package/docs/designs/old/2026-11-05 communication-doctrine-bluf-ste.md +94 -0
  26. package/docs/designs/old/2026-11-06-cloud-engineer-and-resilience-synthesis.md +67 -0
  27. package/docs/designs/old/2026-11-06-herdr-native-agent-orchestration.md +45 -0
  28. package/docs/runs/skill-audit/2026-11-12-compare-report.json +1028 -0
  29. package/docs/runs/skill-audit/2026-11-12-upstream-audit.json +275 -0
  30. package/docs/runs/skill-audit/add_progressive_disclosure.cjs +30 -0
  31. package/docs/runs/skill-audit/check_heimdall_skills.ps1 +9 -0
  32. package/docs/runs/skill-audit/compare_classics.ps1 +26 -0
  33. package/docs/runs/skill-audit/compare_taste.ps1 +12 -0
  34. package/docs/runs/skill-audit/customization-report.json +380 -0
  35. package/docs/runs/skill-audit/diff_pending_skills.cjs +94 -0
  36. package/docs/runs/skill-audit/fetch_and_apply_skill.cjs +58 -0
  37. package/docs/runs/skill-audit/fetch_and_apply_taste_v2.cjs +65 -0
  38. package/docs/runs/skill-audit/inspect_pending_skills.cjs +71 -0
  39. package/docs/runs/skill-audit/inventory.json +308 -0
  40. package/docs/runs/skill-audit/list_local_taste.ps1 +1 -0
  41. package/docs/runs/skill-audit/phase5-update-plan.json +595 -0
  42. package/docs/runs/skill-audit/phase5-update-plan.md +138 -0
  43. package/docs/runs/skill-audit/probe.ps1 +16 -0
  44. package/docs/runs/skill-audit/probe_classics_branches.ps1 +3 -0
  45. package/docs/runs/skill-audit/probe_commits.ps1 +15 -0
  46. package/docs/runs/skill-audit/probe_repos.ps1 +17 -0
  47. package/docs/runs/skill-audit/probe_sentry_sec.ps1 +3 -0
  48. package/docs/runs/skill-audit/probe_sentry_sweep.ps1 +5 -0
  49. package/docs/runs/skill-audit/probe_snyk.ps1 +3 -0
  50. package/docs/runs/skill-audit/probe_snyk_recipes.ps1 +5 -0
  51. package/docs/runs/skill-audit/probe_taste_branches.ps1 +8 -0
  52. package/docs/runs/skill-audit/probe_taste_v19.ps1 +3 -0
  53. package/docs/runs/skill-audit/probe_user_repos.ps1 +19 -0
  54. package/docs/runs/skill-audit/prune_taste_skills.cjs +22 -0
  55. package/docs/runs/skill-audit/run_phase1_2.cjs +142 -0
  56. package/docs/runs/skill-audit/run_phase6_verification.cjs +107 -0
  57. package/docs/runs/skill-audit/show_16_details.ps1 +25 -0
  58. package/docs/runs/skill-audit/show_20_skills.ps1 +28 -0
  59. package/docs/runs/skill-audit/show_classics_diff.cjs +37 -0
  60. package/docs/runs/skill-audit/sync_agent_markdowns.cjs +30 -0
  61. package/docs/runs/skill-audit/taste-skill-upstream.md +542 -0
  62. package/docs/runs/skill-audit/update-manifest.md +88 -0
  63. package/docs/runs/skill-audit/update_config_skills.cjs +52 -0
  64. package/docs/runs/skill-audit/update_registry_phase7.cjs +83 -0
  65. package/docs/runs/skill-audit/upstream-status.json +563 -0
  66. package/docs/runs/skill-audit/verification-results.json +252 -0
  67. package/doctrine/AGENTS.md +42 -77
  68. package/hooks/git/pre-commit +11 -0
  69. package/hooks/heimdall-hook.cjs +81 -2
  70. package/hooks/herdr-agent-state.ps1 +55 -0
  71. package/hooks/hooks.json +0 -11
  72. package/lib/catalog-sync.cjs +167 -0
  73. package/lib/hermes-context.cjs +57 -0
  74. package/lib/model-context.cjs +123 -0
  75. package/lib/path-discovery.cjs +94 -0
  76. package/package.json +7 -3
  77. package/playbooks/01-interactive-grilling-gate.md +23 -6
  78. package/playbooks/02-fast-code-deep-verification.md +3 -2
  79. package/playbooks/03-adversarial-code-review.md +15 -7
  80. package/playbooks/05-canonical-plan-template.md +35 -19
  81. package/playbooks/06-model-registry-matrix.md +24 -13
  82. package/playbooks/07-legacy-code-modernization.md +74 -0
  83. package/playbooks/08-backlog-and-change-request-flow.md +122 -0
  84. package/setup.mjs +592 -172
  85. package/skills/antislop/SKILL.md +76 -56
  86. package/skills/antislop/VERSION +1 -0
  87. package/skills/antislop-copywriting/SKILL.md +407 -372
  88. package/skills/antislop-human/LICENSE-web-quality-skills +21 -0
  89. package/skills/antislop-human/SKILL.md +204 -147
  90. package/skills/antislop-human/contrast-check.py +168 -165
  91. package/skills/antislop-human/contrast-mcp.py +6 -3
  92. package/skills/antislop-human/references/A11Y-PATTERNS.md +249 -0
  93. package/skills/antislop-human/references/WCAG.md +127 -0
  94. package/skills/antislop-ui/LICENSE-web-quality-skills +21 -0
  95. package/skills/antislop-ui/SKILL.md +344 -304
  96. package/skills/antislop-ui/references/CORE-WEB-VITALS.md +181 -0
  97. package/skills/antislop-ui/references/WEB-BASELINE.md +28 -0
  98. package/skills/brainstorming/SKILL.md +296 -265
  99. package/skills/brainstorming/builder-check-prompt.md +23 -0
  100. package/skills/brainstorming/scripts/frame-template.html +213 -213
  101. package/skills/brainstorming/scripts/server.cjs +723 -723
  102. package/skills/brandkit/SKILL.md +798 -798
  103. package/skills/brutalist-skill/SKILL.md +93 -92
  104. package/skills/caveman/README.md +68 -0
  105. package/skills/caveman/SKILL.md +73 -38
  106. package/skills/claude-collaborator/SKILL.md +24 -44
  107. package/skills/clean-code/SKILL.md +152 -0
  108. package/skills/cloudflare-security-audit/AI-AND-LLM.md +83 -83
  109. package/skills/cloudflare-security-audit/ATTACK-CLASSES.md +130 -130
  110. package/skills/cloudflare-security-audit/CLIENT-SIDE.md +83 -83
  111. package/skills/cloudflare-security-audit/CLOUD-AND-DEPLOYMENT.md +86 -86
  112. package/skills/cloudflare-security-audit/DATA-ISOLATION-AND-LIFECYCLE.md +84 -84
  113. package/skills/cloudflare-security-audit/DESKTOP-MOBILE-AND-LOCAL-IPC.md +89 -89
  114. package/skills/cloudflare-security-audit/HUNTING.md +251 -251
  115. package/skills/cloudflare-security-audit/MEMORY-SAFETY-AND-BINARY.md +101 -101
  116. package/skills/cloudflare-security-audit/PROTOCOLS-RPC-AND-MESSAGING.md +81 -81
  117. package/skills/cloudflare-security-audit/RECONNAISSANCE.md +156 -156
  118. package/skills/cloudflare-security-audit/RESOURCE-EXHAUSTION-AND-AVAILABILITY.md +78 -78
  119. package/skills/cloudflare-security-audit/SKILL.md +192 -192
  120. package/skills/cloudflare-security-audit/SUPPLY-CHAIN-AND-RELEASE.md +73 -73
  121. package/skills/cloudflare-security-audit/VALIDATION-AND-REPORTING.md +186 -186
  122. package/skills/cloudflare-security-audit/WEB-PROTOCOL-AND-AUTH.md +105 -105
  123. package/skills/cloudflare-security-audit/report-schema.json +461 -461
  124. package/skills/cloudflare-security-audit/validate-coverage-ledger.cjs +872 -872
  125. package/skills/cloudflare-security-audit/validate-coverage-ledger.test.cjs +740 -740
  126. package/skills/cloudflare-security-audit/validate-findings.cjs +773 -773
  127. package/skills/cloudflare-security-audit/validate-findings.test.cjs +652 -652
  128. package/skills/codebase-design/DEEPENING.md +37 -0
  129. package/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  130. package/skills/codebase-design/SKILL.md +114 -0
  131. package/skills/codex-collaborator/SKILL.md +24 -45
  132. package/skills/communication-doctrine/SKILL.md +89 -0
  133. package/skills/diagnosing-superpowers/SKILL.md +1 -1
  134. package/skills/diagnosing-superpowers/references/github-issues.md +3 -3
  135. package/skills/diagnosing-superpowers/templates/issue.md +23 -4
  136. package/skills/domain-modeling/ADR-FORMAT.md +47 -0
  137. package/skills/domain-modeling/GLOSSARY-FORMAT.md +60 -0
  138. package/skills/domain-modeling/SKILL.md +74 -0
  139. package/skills/executing-plans/SKILL.md +6 -56
  140. package/skills/executing-plans/scripts/task-done +52 -52
  141. package/skills/executing-plans/scripts/task-start +28 -28
  142. package/skills/gemini-collaborator/SKILL.md +24 -56
  143. package/skills/grill-me/SKILL.md +65 -0
  144. package/skills/handoff/SKILL.md +64 -0
  145. package/skills/herdr/SKILL.md +243 -0
  146. package/skills/image-to-code-skill/SKILL.md +1228 -1228
  147. package/skills/imagegen-frontend-mobile/SKILL.md +1465 -1465
  148. package/skills/imagegen-frontend-web/SKILL.md +987 -987
  149. package/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  150. package/skills/improve-codebase-architecture/SKILL.md +71 -0
  151. package/skills/karpathy-guidelines/SKILL.md +67 -67
  152. package/skills/mcp-engineering/SKILL.md +74 -0
  153. package/skills/minimalist-skill/SKILL.md +87 -85
  154. package/skills/output-skill/SKILL.md +49 -49
  155. package/skills/owasp-security/reference/config-and-supply-chain.md +346 -344
  156. package/skills/owasp-security/reference/languages.md +378 -372
  157. package/skills/owasp-security/reference/owasp-report.md +1144 -1140
  158. package/skills/owasp-security/reference/review-checklist.md +134 -132
  159. package/skills/ponytail/SKILL.md +36 -52
  160. package/skills/postgres-best-practices/SKILL.md +30 -52
  161. package/skills/postgres-best-practices/references/backup-restore.md +372 -0
  162. package/skills/postgres-best-practices/references/bulk-loading.md +315 -0
  163. package/skills/postgres-best-practices/references/connection-pooling.md +310 -0
  164. package/skills/postgres-best-practices/references/hot-standby.md +221 -0
  165. package/skills/postgres-best-practices/references/indexing.md +318 -0
  166. package/skills/postgres-best-practices/references/logical-replication.md +610 -0
  167. package/skills/postgres-best-practices/references/major-version-upgrades.md +334 -0
  168. package/skills/postgres-best-practices/references/performance-diagnostics.md +553 -0
  169. package/skills/postgres-best-practices/references/query-optimization.md +294 -0
  170. package/skills/postgres-best-practices/references/query-patterns.md +566 -0
  171. package/skills/postgres-best-practices/references/schema-design.md +362 -0
  172. package/skills/postgres-best-practices/references/security-roles.md +489 -0
  173. package/skills/postgres-best-practices/references/transaction-isolation.md +344 -0
  174. package/skills/progressive-disclosure/SKILL.md +68 -0
  175. package/skills/pstack-discipline/SKILL.md +40 -0
  176. package/skills/receiving-code-review/SKILL.md +2 -23
  177. package/skills/requesting-code-review/SKILL.md +7 -36
  178. package/skills/soft-skill/SKILL.md +99 -98
  179. package/skills/stitch-skill/DESIGN.md +121 -121
  180. package/skills/stitch-skill/SKILL.md +185 -184
  181. package/skills/strix-security/SKILL.md +54 -53
  182. package/skills/subagent-driven-development/SKILL.md +35 -264
  183. package/skills/subagent-driven-development/references/batching.md +11 -0
  184. package/skills/subagent-driven-development/references/cannot-verify.md +10 -0
  185. package/skills/subagent-driven-development/references/final-review.md +47 -0
  186. package/skills/subagent-driven-development/references/fix-loop.md +77 -0
  187. package/skills/subagent-driven-development/references/handling-reports.md +15 -0
  188. package/skills/subagent-driven-development/references/preflight.md +26 -0
  189. package/skills/subagent-driven-development/references/resuming.md +12 -0
  190. package/skills/subagent-driven-development/scripts/review-package +53 -53
  191. package/skills/subagent-driven-development/scripts/sdd-workspace +87 -82
  192. package/skills/subagent-driven-development/scripts/task-brief +43 -43
  193. package/skills/systematic-debugging/SKILL.md +283 -306
  194. package/skills/taste-skill/SKILL.md +542 -1206
  195. package/skills/taste-skill/references/app-screens.md +1199 -0
  196. package/skills/taste-skill/references/colour.md +141 -0
  197. package/skills/taste-skill/references/copy.md +177 -0
  198. package/skills/taste-skill/references/critique.md +182 -0
  199. package/skills/taste-skill/references/imagery.md +791 -0
  200. package/skills/taste-skill/references/layout.md +292 -0
  201. package/skills/taste-skill/references/motion.md +980 -0
  202. package/skills/taste-skill/references/research.md +356 -0
  203. package/skills/taste-skill/references/scenes.md +174 -0
  204. package/skills/taste-skill/references/tells.md +115 -0
  205. package/skills/taste-skill/references/type.md +170 -0
  206. package/skills/test-driven-development/SKILL.md +330 -337
  207. package/skills/thermo/SKILL.md +67 -0
  208. package/skills/threat-modeling/SKILL.md +55 -0
  209. package/skills/to-spec/SKILL.md +75 -0
  210. package/skills/to-tickets/SKILL.md +105 -0
  211. package/skills/trailofbits-audit-context/SKILL.md +72 -72
  212. package/skills/trailofbits-insecure-defaults/commands/audit.md +35 -0
  213. package/skills/trailofbits-insecure-defaults/references/debug-features.json +13 -13
  214. package/skills/trailofbits-insecure-defaults/references/debug-features.md +75 -75
  215. package/skills/trailofbits-insecure-defaults/references/default-credentials.json +12 -12
  216. package/skills/trailofbits-insecure-defaults/references/default-credentials.md +76 -76
  217. package/skills/trailofbits-insecure-defaults/references/fail-open-security.json +11 -11
  218. package/skills/trailofbits-insecure-defaults/references/fail-open-security.md +70 -70
  219. package/skills/trailofbits-insecure-defaults/references/fallback-secrets.json +11 -11
  220. package/skills/trailofbits-insecure-defaults/references/fallback-secrets.md +70 -70
  221. package/skills/trailofbits-insecure-defaults/references/permissive-access.json +13 -13
  222. package/skills/trailofbits-insecure-defaults/references/permissive-access.md +62 -62
  223. package/skills/trailofbits-insecure-defaults/references/weak-crypto.json +13 -13
  224. package/skills/trailofbits-insecure-defaults/references/weak-crypto.md +71 -71
  225. package/skills/trailofbits-triage-brocards/SKILL.md +208 -208
  226. package/skills/verification-before-completion/SKILL.md +0 -14
  227. package/skills/wayfinder/SKILL.md +128 -0
  228. package/skills/writing-plans/SKILL.md +11 -15
  229. package/skills/writing-skills/SKILL.md +21 -303
  230. package/skills/writing-skills/references/CLAUDE_MD_TESTING.md +189 -0
  231. package/skills/writing-skills/references/anthropic-best-practices.md +1150 -0
  232. package/skills/writing-skills/references/bulletproofing.md +80 -0
  233. package/skills/writing-skills/references/discovery.md +201 -0
  234. package/skills/writing-skills/references/flowcharts.md +37 -0
  235. package/skills/writing-skills/references/graphviz-conventions.dot +172 -0
  236. package/skills/writing-skills/references/persuasion-principles.md +187 -0
  237. package/skills/writing-skills/references/testing-skills-with-subagents.md +384 -0
  238. package/tools/{claude-bridge.ps1 → archive/claude-bridge.ps1} +10 -7
  239. package/tools/{codex-bridge.ps1 → archive/codex-bridge.ps1} +1 -1
  240. package/tools/{gemini-bridge.ps1 → archive/gemini-bridge.ps1} +12 -19
  241. package/skills/gpt-tasteskill/SKILL.md +0 -74
  242. package/skills/taste-skill-v1/SKILL.md +0 -226
  243. /package/tools/{claude-bridge.cmd → archive/claude-bridge.cmd} +0 -0
  244. /package/tools/{claude-bridge.sh → archive/claude-bridge.sh} +0 -0
  245. /package/tools/{codex-bridge.cmd → archive/codex-bridge.cmd} +0 -0
  246. /package/tools/{codex-bridge.sh → archive/codex-bridge.sh} +0 -0
  247. /package/tools/{codexcli-bridge.cmd → archive/codexcli-bridge.cmd} +0 -0
  248. /package/tools/{codexcli-bridge.ps1 → archive/codexcli-bridge.ps1} +0 -0
  249. /package/tools/{gemini-bridge.cmd → archive/gemini-bridge.cmd} +0 -0
  250. /package/tools/{gemini-bridge.sh → archive/gemini-bridge.sh} +0 -0
@@ -1,344 +1,346 @@
1
- # A02 Security Misconfiguration & A03 Software Supply Chain Failures
2
-
3
- The #2 and #3 categories of the OWASP Top 10:2025 are rarely found in application code. They
4
- live in Dockerfiles, Kubernetes manifests, Terraform, framework settings, lockfiles, and CI
5
- workflow definitions. This file covers those surfaces concretely.
6
-
7
- > **Same reporting bar applies.** A hardening gap in a file that never reaches production, or a
8
- > permissive setting already constrained by a layer above it (a security group behind a private
9
- > subnet, a `latest` tag pinned by digest at deploy), is defense-in-depth - report it as such.
10
- > See "Before Reporting a Finding" in [`../SKILL.md`](../SKILL.md).
11
-
12
- ## Contents
13
- - [Where to Look First](#where-to-look-first)
14
- - [A02 - Containers](#a02-containers)
15
- - [A02 - Kubernetes](#a02-kubernetes)
16
- - [A02 - Cloud & Terraform](#a02-cloud--terraform)
17
- - [A02 - Application & Web Server Config](#a02-application--web-server-config)
18
- - [A02 - Security Headers](#a02-security-headers)
19
- - [A03 - Dependency Manifests and Lockfiles](#a03-dependency-manifests-and-lockfiles)
20
- - [A03 - Dependency Confusion and Typosquatting](#a03-dependency-confusion-and-typosquatting)
21
- - [A03 - Install Scripts](#a03-install-scripts)
22
- - [A03 - CI/CD Pipelines](#a03-cicd-pipelines)
23
- - [A03 - Provenance, Signing, and SBOM](#a03-provenance-signing-and-sbom)
24
-
25
- ---
26
-
27
- ## Where to Look First
28
-
29
- Before reading any application code, list these files if they exist. They are small, high-signal,
30
- and frequently unreviewed:
31
-
32
- | Surface | Files |
33
- |---|---|
34
- | Containers | `Dockerfile*`, `docker-compose*.yml`, `.dockerignore` |
35
- | Orchestration | `k8s/**/*.yaml`, `helm/**/values.yaml`, `*.deployment.yaml` |
36
- | Infrastructure | `*.tf`, `*.tfvars`, `cdk/**`, `template.yaml` (SAM), `serverless.yml` |
37
- | App config | `settings.py`, `application*.yml`, `appsettings*.json`, `next.config.js`, `.env*` |
38
- | Web server | `nginx.conf`, `httpd.conf`, ingress annotations |
39
- | Dependencies | `package.json` + lockfile, `requirements.txt`, `pyproject.toml`, `go.mod`, `pom.xml`, `Gemfile`, `Cargo.toml` |
40
- | Registry config | `.npmrc`, `pip.conf`, `settings.xml`, `.yarnrc.yml` |
41
- | Pipelines | `.github/workflows/*.yml`, `.gitlab-ci.yml`, `Jenkinsfile`, `azure-pipelines.yml` |
42
-
43
- Two questions cut through most of it: **what runs as root or with wildcard permissions**, and
44
- **what executes code that someone outside the repo controls**.
45
-
46
- ---
47
-
48
- ## A02: Containers
49
-
50
- ```dockerfile
51
- # UNSAFE
52
- FROM node:latest # unpinned - the image changes under you
53
- COPY . . # no .dockerignore: .env, .git, keys land in the layer
54
- RUN npm install
55
- ARG NPM_TOKEN # build args are visible in image history
56
- ENV API_KEY="sk-live-..." # baked into the image, readable by anyone who pulls it
57
- USER root # default; the process runs as uid 0
58
- CMD ["npm", "start"]
59
- ```
60
-
61
- ```dockerfile
62
- # SAFE
63
- FROM node:22.11.0-alpine@sha256:... # pinned by digest
64
- WORKDIR /app
65
- COPY package*.json ./
66
- RUN npm ci --omit=dev # ci, not install: honors the lockfile exactly
67
- COPY --chown=node:node . . # with a .dockerignore covering .git, .env, secrets
68
- USER node # non-root
69
- CMD ["node", "server.js"]
70
- ```
71
-
72
- **Check for:**
73
- - Running as root - `USER` absent entirely is the common case, not an explicit `USER root`
74
- - Secrets in `ENV`, `ARG`, or any `RUN` command - every layer is readable via `docker history`;
75
- deleting a file in a later layer does not remove it from the earlier one. Use build secrets
76
- (`RUN --mount=type=secret`) or inject at runtime.
77
- - Missing `.dockerignore` while the Dockerfile does `COPY . .` - this is how `.git` and `.env`
78
- reach production images
79
- - `npm install` / `pip install -r` without a lockfile step (see A03 below)
80
- - `latest` or floating tags; unpinned base image digests
81
- - `curl ... | sh` in a build step - unverified remote code at build time
82
- - `--privileged`, `network_mode: host`, or docker socket mounts (`/var/run/docker.sock`) in
83
- compose files - a socket mount is host root, effectively
84
-
85
- ---
86
-
87
- ## A02: Kubernetes
88
-
89
- ```yaml
90
- # UNSAFE
91
- spec:
92
- containers:
93
- - name: api
94
- image: myapp:latest
95
- securityContext:
96
- privileged: true # full host access
97
- runAsUser: 0
98
- env:
99
- - name: DB_PASSWORD
100
- value: "hunter2" # plaintext in the manifest, and in git
101
- volumeMounts:
102
- - mountPath: /host
103
- name: hostvol
104
- volumes:
105
- - name: hostvol
106
- hostPath: { path: / } # the entire node filesystem
107
- ```
108
-
109
- ```yaml
110
- # SAFE
111
- spec:
112
- automountServiceAccountToken: false # unless the pod actually calls the API server
113
- securityContext:
114
- runAsNonRoot: true
115
- runAsUser: 10001
116
- seccompProfile: { type: RuntimeDefault }
117
- containers:
118
- - name: api
119
- image: myapp@sha256:...
120
- securityContext:
121
- allowPrivilegeEscalation: false
122
- readOnlyRootFilesystem: true
123
- capabilities: { drop: ["ALL"] }
124
- envFrom:
125
- - secretRef: { name: api-secrets } # from a secret store, not the manifest
126
- resources:
127
- limits: { cpu: "1", memory: "512Mi" } # absent limits = node-wide DoS
128
- ```
129
-
130
- **Check for:** `privileged: true`, `hostNetwork`/`hostPID`/`hostPath`, missing
131
- `allowPrivilegeEscalation: false`, capabilities not dropped, secrets as literal `value:` (and
132
- remember base64 in a `Secret` object is encoding, not encryption), `automountServiceAccountToken`
133
- left on by default, absent resource limits, no NetworkPolicy (default is all pods can reach all
134
- pods), and RBAC bindings granting `cluster-admin` or `*` verbs.
135
-
136
- ---
137
-
138
- ## A02: Cloud & Terraform
139
-
140
- ```hcl
141
- # UNSAFE
142
- resource "aws_s3_bucket_public_access_block" "b" {
143
- block_public_acls = false # public-ACL guard off
144
- }
145
-
146
- resource "aws_security_group_rule" "ssh" {
147
- type = "ingress"
148
- from_port = 22
149
- to_port = 22
150
- cidr_blocks = ["0.0.0.0/0"] # SSH open to the internet
151
- }
152
-
153
- resource "aws_db_instance" "db" {
154
- publicly_accessible = true
155
- storage_encrypted = false
156
- }
157
-
158
- data "aws_iam_policy_document" "p" {
159
- statement {
160
- actions = ["*"] # wildcard action on wildcard resource
161
- resources = ["*"]
162
- }
163
- }
164
- ```
165
-
166
- **Check for:**
167
- - Storage exposed publicly (S3 ACLs/policies, GCS `allUsers`, Azure blob public access)
168
- - `0.0.0.0/0` on anything that is not 80/443 - SSH, RDP, database ports, admin panels
169
- - Encryption at rest disabled; TLS not enforced in transit
170
- - IAM policies with `"*"` actions or resources; roles assumable by `"*"` principals
171
- - Managed databases and caches marked publicly accessible
172
- - Audit logging (CloudTrail, flow logs, GCP audit logs) disabled or not retained
173
- - Secrets in `.tfvars` or committed state files - Terraform state stores values in cleartext
174
- - IMDSv1 permitted on EC2 (`http_tokens = "optional"`) - this is the SSRF-to-credentials path
175
-
176
- ---
177
-
178
- ## A02: Application & Web Server Config
179
-
180
- ```python
181
- # UNSAFE (Django)
182
- DEBUG = True # tracebacks with settings and local variables
183
- ALLOWED_HOSTS = ["*"] # host header injection, cache poisoning
184
- SECRET_KEY = "dev-key-do-not-use" # committed and predictable → forgeable sessions
185
- CORS_ALLOW_ALL_ORIGINS = True # with credentials, any site reads authenticated responses
186
- SESSION_COOKIE_SECURE = False
187
- ```
188
-
189
- **Check for:**
190
- - Debug/verbose error modes reachable in production; stack-trace pages, `/debug` or profiler routes
191
- - Development secrets committed, or the same key across environments
192
- - CORS: `*` combined with credentials, origin reflected from the request, or a regex matching
193
- `evil-myapp.com` because the dot was not escaped
194
- - Directory listing enabled; `.git/`, `.env`, backups, or `/actuator`, `/metrics`, `/graphql`
195
- introspection served publicly
196
- - Default admin consoles left mounted (`/admin`, phpMyAdmin, Kibana, Grafana) without auth
197
- - TLS: versions below 1.2 enabled, weak ciphers, certificate verification disabled in clients
198
- (`verify=False`, `rejectUnauthorized: false`, `InsecureSkipVerify: true`)
199
-
200
- ---
201
-
202
- ## A02: Security Headers
203
-
204
- | Header | Value | Why |
205
- |---|---|---|
206
- | `Content-Security-Policy` | `default-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'` | Last line of defense for XSS. `unsafe-inline`/`unsafe-eval` mostly negates it; prefer nonces or hashes. |
207
- | `Strict-Transport-Security` | `max-age=31536000; includeSubDomains` | Prevents downgrade/stripping. |
208
- | `X-Content-Type-Options` | `nosniff` | Stops MIME sniffing turning an upload into script. |
209
- | `Referrer-Policy` | `strict-origin-when-cross-origin` | Keeps paths and tokens out of `Referer`. |
210
- | `Cache-Control` | `no-store` on authenticated responses | Prevents shared-cache leakage. |
211
- | Cookies | `HttpOnly; Secure; SameSite=Lax` | XSS theft and cross-site request defense. |
212
-
213
- `frame-ancestors` supersedes `X-Frame-Options`; setting both is harmless and helps old clients.
214
-
215
- ---
216
-
217
- ## A03: Dependency Manifests and Lockfiles
218
-
219
- The recurring finding is a lockfile that is missing, or one the build is allowed to rewrite,
220
- so what ships can differ from what was reviewed. Most JS package managers read the lockfile on a
221
- plain install; the question is whether a mismatch with the manifest fails the build or silently
222
- updates the lock.
223
-
224
- | Ecosystem | Does not enforce the lock (may rewrite it or skip checks) | Fails the build if the lock is missing or out of sync |
225
- |---|---|---|
226
- | npm | `npm install` (updates the lock when `package.json` disagrees) | `npm ci` |
227
- | Yarn 2+ | `yarn install` outside CI | `yarn install --immutable`, the default when Yarn detects CI (`enableImmutableInstalls`) |
228
- | Yarn 1 | `yarn install`; `--frozen-lockfile` still succeeds when `yarn.lock` is missing | `yarn install --frozen-lockfile` plus an explicit check that `yarn.lock` exists |
229
- | pnpm | `pnpm install` outside CI | `pnpm install --frozen-lockfile`, the default in CI when a lockfile exists |
230
- | pip | `pip install -r requirements.txt` without hashes | `pip install --require-hashes -r requirements.txt` (every entry pinned `==` with `--hash`) |
231
- | uv | `uv sync`, or `uv sync --frozen` (uses the lock without checking it is current) | `uv sync --locked` |
232
- | Poetry | `poetry install` | `poetry check --lock` before install |
233
- | Go | `-mod=mod` (updates `go.mod`) | the default `-mod=readonly` since Go 1.16, with `go.sum` committed. `go mod verify` is separate: it checks the module cache for local tampering against hashes recorded at download |
234
- | Rust | `cargo build` (may update `Cargo.lock`) | `cargo build --locked` |
235
- | Gradle | dynamic versions with no lock; any CI build run with `--write-locks` (overwrites lock state) or `--update-locks` (rewrites the named entries) | committed `gradle.lockfile` with `lockMode = LockMode.STRICT` (also fails when a locked configuration has no lock state) |
236
- | Maven | version ranges in `pom.xml` | no native lockfile: pin exact versions and forbid ranges |
237
-
238
- **Check for:** a lockfile missing or gitignored; a production build step that can rewrite it
239
- (`npm install` in CI, `uv sync --frozen` where `--locked` was meant, Gradle `--write-locks` in CI, or
240
- `enableImmutableInstalls: false` / `--no-frozen-lockfile` overriding the CI default); floating ranges (`^`, `~`, `*`, `latest`) with no enforced lockfile behind them; `requirements.txt` without `==`; a lockfile whose `resolved` URLs point at
241
- a registry other than the expected one; and vulnerable-but-unused dependencies (they still count
242
- if the code path is reachable - check before rating severity).
243
-
244
- ---
245
-
246
- ## A03: Dependency Confusion and Typosquatting
247
-
248
- Dependency confusion: an internal package name that is not registered publicly can be claimed by
249
- an attacker, whose higher version number wins resolution when a build falls back to the public
250
- registry.
251
-
252
- ```ini
253
- # UNSAFE .npmrc - private scope resolvable from the public registry
254
- registry=https://registry.npmjs.org/
255
-
256
- # SAFE - bind the scope to the internal registry explicitly
257
- @mycompany:registry=https://npm.internal.example.com/
258
- //npm.internal.example.com/:_authToken=${NPM_TOKEN}
259
- ```
260
-
261
- **Check for:**
262
- - Internal package names used unscoped, or scopes not pinned to an internal registry
263
- - A proxy/mirror configured to fall through to the public registry for internal names
264
- - `pip install --extra-index-url` - pip picks the highest version across **all** indexes; use
265
- `--index-url` with a single trusted mirror
266
- - Names one edit away from a popular package (`crossenv`, `python3-dateutil`, `reqeusts`),
267
- packages with very recent first-publish dates, or a maintainer change on a critical dependency
268
- - Git/URL dependencies pointing at a branch rather than a commit SHA
269
-
270
- ---
271
-
272
- ## A03: Install Scripts
273
-
274
- Package installation executes code. `npm install` runs `preinstall`/`postinstall` from every
275
- package in the tree, with the developer's or CI runner's privileges.
276
-
277
- ```json
278
- // Review any package that ships this - it is the standard malware entry point
279
- { "scripts": { "postinstall": "node ./scripts/collect.js" } }
280
- ```
281
-
282
- Mitigations: `npm ci --ignore-scripts` (then run the builds you actually need explicitly),
283
- `pip install --only-binary :all:` to avoid arbitrary `setup.py` execution, and running installs
284
- in a container without credentials or network access beyond the registry.
285
-
286
- ---
287
-
288
- ## A03: CI/CD Pipelines
289
-
290
- The pipeline has repository write access and production credentials. It is a higher-value target
291
- than the application.
292
-
293
- ```yaml
294
- # UNSAFE - GitHub Actions
295
- on: pull_request_target # runs with a writable token AND secrets...
296
- jobs:
297
- build:
298
- steps:
299
- - uses: actions/checkout@v4
300
- with:
301
- ref: ${{ github.event.pull_request.head.sha }} # ...on the fork's code. RCE.
302
- - uses: some-org/some-action@main # mutable ref
303
- - run: echo "Title: ${{ github.event.pull_request.title }}" # script injection
304
- ```
305
-
306
- ```yaml
307
- # SAFE
308
- on: pull_request # read-only token, no secrets for forks
309
- permissions:
310
- contents: read # least privilege, declared explicitly
311
- jobs:
312
- build:
313
- steps:
314
- - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pinned SHA
315
- - env:
316
- TITLE: ${{ github.event.pull_request.title }} # via env, not interpolated into the shell
317
- run: echo "Title: $TITLE"
318
- ```
319
-
320
- **Check for:**
321
- - `pull_request_target` or `workflow_run` that checks out untrusted code - the combination of
322
- fork code plus secrets is the critical one
323
- - `${{ }}` interpolation of attacker-controllable fields (PR title, branch name, issue body,
324
- commit message) directly into `run:` - the expression is substituted before the shell sees it
325
- - Third-party actions referenced by tag or branch instead of a commit SHA; tags are mutable
326
- - `permissions:` not restricted (default may be write-all)
327
- - Secrets echoed, passed to untrusted steps, or exposed to fork-triggered runs
328
- - Self-hosted runners on public repositories - fork PRs get code execution on your infrastructure
329
- - No required review or branch protection on the branch that deploys
330
-
331
- ---
332
-
333
- ## A03: Provenance, Signing, and SBOM
334
-
335
- - Generate an SBOM (CycloneDX or SPDX) as a build artifact, not as a one-off report
336
- - Verify signatures before deploy: `cosign verify`, `npm audit signatures`, sigstore attestations
337
- - Publish with provenance (`npm publish --provenance`, SLSA attestations) so consumers can verify
338
- which workflow and commit produced an artifact
339
- - Pin container images by digest, not tag - a tag can be repointed after your review
340
- - Keep a rollback path: an artifact whose signature fails verification should block the deploy,
341
- which only works if failing closed does not leave you unable to ship the previous version
342
-
343
- Continuous monitoring (Dependabot, Renovate, Snyk, `osv-scanner`, `pip-audit`, `cargo audit`)
344
- matters more than a point-in-time audit - the dependency was clean on the day you reviewed it.
1
+ # A02 Security Misconfiguration & A03 Software Supply Chain Failures
2
+
3
+ The #2 and #3 categories of the OWASP Top 10:2025 are rarely found in application code. They
4
+ live in Dockerfiles, Kubernetes manifests, Terraform, framework settings, lockfiles, and CI
5
+ workflow definitions. This file covers those surfaces concretely.
6
+
7
+ > **Same reporting bar applies.** A hardening gap in a file that never reaches production, or a
8
+ > permissive setting already constrained by a layer above it (a security group behind a private
9
+ > subnet, a `latest` tag pinned by digest at deploy), is defense-in-depth - report it as such.
10
+ > See "Before Reporting a Finding" in [`../SKILL.md`](../SKILL.md).
11
+
12
+ ## Contents
13
+ - [Where to Look First](#where-to-look-first)
14
+ - [A02 - Containers](#a02-containers)
15
+ - [A02 - Kubernetes](#a02-kubernetes)
16
+ - [A02 - Cloud & Terraform](#a02-cloud--terraform)
17
+ - [A02 - Application & Web Server Config](#a02-application--web-server-config)
18
+ - [A02 - Security Headers](#a02-security-headers)
19
+ - [A03 - Dependency Manifests and Lockfiles](#a03-dependency-manifests-and-lockfiles)
20
+ - [A03 - Dependency Confusion and Typosquatting](#a03-dependency-confusion-and-typosquatting)
21
+ - [A03 - Install Scripts](#a03-install-scripts)
22
+ - [A03 - CI/CD Pipelines](#a03-cicd-pipelines)
23
+ - [A03 - Provenance, Signing, and SBOM](#a03-provenance-signing-and-sbom)
24
+
25
+ ---
26
+
27
+ ## Where to Look First
28
+
29
+ Before reading any application code, list these files if they exist. They are small, high-signal,
30
+ and frequently unreviewed:
31
+
32
+ | Surface | Files |
33
+ |---|---|
34
+ | Containers | `Dockerfile*`, `docker-compose*.yml`, `.dockerignore` |
35
+ | Orchestration | `k8s/**/*.yaml`, `helm/**/values.yaml`, `*.deployment.yaml` |
36
+ | Infrastructure | `*.tf`, `*.tfvars`, `cdk/**`, `template.yaml` (SAM), `serverless.yml` |
37
+ | App config | `settings.py`, `application*.yml`, `appsettings*.json`, `next.config.js`, `.env*` |
38
+ | Web server | `nginx.conf`, `httpd.conf`, ingress annotations |
39
+ | Dependencies | `package.json` + lockfile, `requirements.txt`, `pyproject.toml`, `go.mod`, `pom.xml`, `Gemfile`, `Cargo.toml` |
40
+ | Registry config | `.npmrc`, `pip.conf`, `settings.xml`, `.yarnrc.yml` |
41
+ | Pipelines | `.github/workflows/*.yml`, `.gitlab-ci.yml`, `Jenkinsfile`, `azure-pipelines.yml` |
42
+
43
+ Two questions cut through most of it: **what runs as root or with wildcard permissions**, and
44
+ **what executes code that someone outside the repo controls**.
45
+
46
+ ---
47
+
48
+ ## A02: Containers
49
+
50
+ ```dockerfile
51
+ # UNSAFE
52
+ FROM node:latest # unpinned - the image changes under you
53
+ COPY . . # no .dockerignore: .env, .git, keys land in the layer
54
+ RUN npm install
55
+ ARG NPM_TOKEN # build args are visible in image history
56
+ ENV API_KEY="sk-live-..." # baked into the image, readable by anyone who pulls it
57
+ USER root # default; the process runs as uid 0
58
+ CMD ["npm", "start"]
59
+ ```
60
+
61
+ ```dockerfile
62
+ # SAFE
63
+ FROM node:22.11.0-alpine@sha256:... # pinned by digest
64
+ WORKDIR /app
65
+ COPY package*.json ./
66
+ RUN npm ci --omit=dev # ci, not install: honors the lockfile exactly
67
+ COPY --chown=node:node . . # with a .dockerignore covering .git, .env, secrets
68
+ USER node # non-root
69
+ CMD ["node", "server.js"]
70
+ ```
71
+
72
+ **Check for:**
73
+ - Running as root - `USER` absent entirely is the common case, not an explicit `USER root`
74
+ - Secrets in `ENV`, `ARG`, or any `RUN` command - the values are in the layer metadata, visible
75
+ with `docker history`. Use build secrets (`RUN --mount=type=secret`) or inject at runtime.
76
+ - Secret files copied in and deleted in a later layer - `docker history` does not show these,
77
+ but the earlier layer still contains the file; `docker save` or `dive` recovers it. Check both
78
+ vectors: history for values, layer contents for files.
79
+ - Missing `.dockerignore` while the Dockerfile does `COPY . .` - this is how `.git` and `.env`
80
+ reach production images
81
+ - `npm install` / `pip install -r` without a lockfile step (see A03 below)
82
+ - `latest` or floating tags; unpinned base image digests
83
+ - `curl ... | sh` in a build step - unverified remote code at build time
84
+ - `--privileged`, `network_mode: host`, or docker socket mounts (`/var/run/docker.sock`) in
85
+ compose files - a socket mount is host root, effectively
86
+
87
+ ---
88
+
89
+ ## A02: Kubernetes
90
+
91
+ ```yaml
92
+ # UNSAFE
93
+ spec:
94
+ containers:
95
+ - name: api
96
+ image: myapp:latest
97
+ securityContext:
98
+ privileged: true # full host access
99
+ runAsUser: 0
100
+ env:
101
+ - name: DB_PASSWORD
102
+ value: "hunter2" # plaintext in the manifest, and in git
103
+ volumeMounts:
104
+ - mountPath: /host
105
+ name: hostvol
106
+ volumes:
107
+ - name: hostvol
108
+ hostPath: { path: / } # the entire node filesystem
109
+ ```
110
+
111
+ ```yaml
112
+ # SAFE
113
+ spec:
114
+ automountServiceAccountToken: false # unless the pod actually calls the API server
115
+ securityContext:
116
+ runAsNonRoot: true
117
+ runAsUser: 10001
118
+ seccompProfile: { type: RuntimeDefault }
119
+ containers:
120
+ - name: api
121
+ image: myapp@sha256:...
122
+ securityContext:
123
+ allowPrivilegeEscalation: false
124
+ readOnlyRootFilesystem: true
125
+ capabilities: { drop: ["ALL"] }
126
+ envFrom:
127
+ - secretRef: { name: api-secrets } # from a secret store, not the manifest
128
+ resources:
129
+ limits: { cpu: "1", memory: "512Mi" } # absent limits = node-wide DoS
130
+ ```
131
+
132
+ **Check for:** `privileged: true`, `hostNetwork`/`hostPID`/`hostPath`, missing
133
+ `allowPrivilegeEscalation: false`, capabilities not dropped, secrets as literal `value:` (and
134
+ remember base64 in a `Secret` object is encoding, not encryption), `automountServiceAccountToken`
135
+ left on by default, absent resource limits, no NetworkPolicy (default is all pods can reach all
136
+ pods), and RBAC bindings granting `cluster-admin` or `*` verbs.
137
+
138
+ ---
139
+
140
+ ## A02: Cloud & Terraform
141
+
142
+ ```hcl
143
+ # UNSAFE
144
+ resource "aws_s3_bucket_public_access_block" "b" {
145
+ block_public_acls = false # public-ACL guard off
146
+ }
147
+
148
+ resource "aws_security_group_rule" "ssh" {
149
+ type = "ingress"
150
+ from_port = 22
151
+ to_port = 22
152
+ cidr_blocks = ["0.0.0.0/0"] # SSH open to the internet
153
+ }
154
+
155
+ resource "aws_db_instance" "db" {
156
+ publicly_accessible = true
157
+ storage_encrypted = false
158
+ }
159
+
160
+ data "aws_iam_policy_document" "p" {
161
+ statement {
162
+ actions = ["*"] # wildcard action on wildcard resource
163
+ resources = ["*"]
164
+ }
165
+ }
166
+ ```
167
+
168
+ **Check for:**
169
+ - Storage exposed publicly (S3 ACLs/policies, GCS `allUsers`, Azure blob public access)
170
+ - `0.0.0.0/0` on anything that is not 80/443 - SSH, RDP, database ports, admin panels
171
+ - Encryption at rest disabled; TLS not enforced in transit
172
+ - IAM policies with `"*"` actions or resources; roles assumable by `"*"` principals
173
+ - Managed databases and caches marked publicly accessible
174
+ - Audit logging (CloudTrail, flow logs, GCP audit logs) disabled or not retained
175
+ - Secrets in `.tfvars` or committed state files - Terraform state stores values in cleartext
176
+ - IMDSv1 permitted on EC2 (`http_tokens = "optional"`) - this is the SSRF-to-credentials path
177
+
178
+ ---
179
+
180
+ ## A02: Application & Web Server Config
181
+
182
+ ```python
183
+ # UNSAFE (Django)
184
+ DEBUG = True # tracebacks with settings and local variables
185
+ ALLOWED_HOSTS = ["*"] # host header injection, cache poisoning
186
+ SECRET_KEY = "dev-key-do-not-use" # committed and predictable → forgeable sessions
187
+ CORS_ALLOW_ALL_ORIGINS = True # with credentials, any site reads authenticated responses
188
+ SESSION_COOKIE_SECURE = False
189
+ ```
190
+
191
+ **Check for:**
192
+ - Debug/verbose error modes reachable in production; stack-trace pages, `/debug` or profiler routes
193
+ - Development secrets committed, or the same key across environments
194
+ - CORS: `*` combined with credentials, origin reflected from the request, or a regex matching
195
+ `evil-myapp.com` because the dot was not escaped
196
+ - Directory listing enabled; `.git/`, `.env`, backups, or `/actuator`, `/metrics`, `/graphql`
197
+ introspection served publicly
198
+ - Default admin consoles left mounted (`/admin`, phpMyAdmin, Kibana, Grafana) without auth
199
+ - TLS: versions below 1.2 enabled, weak ciphers, certificate verification disabled in clients
200
+ (`verify=False`, `rejectUnauthorized: false`, `InsecureSkipVerify: true`)
201
+
202
+ ---
203
+
204
+ ## A02: Security Headers
205
+
206
+ | Header | Value | Why |
207
+ |---|---|---|
208
+ | `Content-Security-Policy` | `default-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'` | Last line of defense for XSS. `unsafe-inline`/`unsafe-eval` mostly negates it; prefer nonces or hashes. |
209
+ | `Strict-Transport-Security` | `max-age=31536000; includeSubDomains` | Prevents downgrade/stripping. |
210
+ | `X-Content-Type-Options` | `nosniff` | Stops MIME sniffing turning an upload into script. |
211
+ | `Referrer-Policy` | `strict-origin-when-cross-origin` | Keeps paths and tokens out of `Referer`. |
212
+ | `Cache-Control` | `no-store` on authenticated responses | Prevents shared-cache leakage. |
213
+ | Cookies | `HttpOnly; Secure; SameSite=Lax` | XSS theft and cross-site request defense. |
214
+
215
+ `frame-ancestors` supersedes `X-Frame-Options`; setting both is harmless and helps old clients.
216
+
217
+ ---
218
+
219
+ ## A03: Dependency Manifests and Lockfiles
220
+
221
+ The recurring finding is a lockfile that is missing, or one the build is allowed to rewrite,
222
+ so what ships can differ from what was reviewed. Most JS package managers read the lockfile on a
223
+ plain install; the question is whether a mismatch with the manifest fails the build or silently
224
+ updates the lock.
225
+
226
+ | Ecosystem | Does not enforce the lock (may rewrite it or skip checks) | Fails the build if the lock is missing or out of sync |
227
+ |---|---|---|
228
+ | npm | `npm install` (updates the lock when `package.json` disagrees) | `npm ci` |
229
+ | Yarn 2+ | `yarn install` outside CI | `yarn install --immutable`, the default when Yarn detects CI (`enableImmutableInstalls`) |
230
+ | Yarn 1 | `yarn install`; `--frozen-lockfile` still succeeds when `yarn.lock` is missing | `yarn install --frozen-lockfile` plus an explicit check that `yarn.lock` exists |
231
+ | pnpm | `pnpm install` outside CI | `pnpm install --frozen-lockfile`, the default in CI when a lockfile exists |
232
+ | pip | `pip install -r requirements.txt` without hashes | `pip install --require-hashes -r requirements.txt` (every entry pinned `==` with `--hash`) |
233
+ | uv | `uv sync`, or `uv sync --frozen` (uses the lock without checking it is current) | `uv sync --locked` |
234
+ | Poetry | `poetry install` | `poetry check --lock` before install |
235
+ | Go | `-mod=mod` (updates `go.mod`) | the default `-mod=readonly` since Go 1.16, with `go.sum` committed. `go mod verify` is separate: it checks the module cache for local tampering against hashes recorded at download |
236
+ | Rust | `cargo build` (may update `Cargo.lock`) | `cargo build --locked` |
237
+ | Gradle | dynamic versions with no lock; any CI build run with `--write-locks` (overwrites lock state) or `--update-locks` (rewrites the named entries) | committed `gradle.lockfile` with `lockMode = LockMode.STRICT` (also fails when a locked configuration has no lock state) |
238
+ | Maven | version ranges in `pom.xml` | no native lockfile: pin exact versions and forbid ranges |
239
+
240
+ **Check for:** a lockfile missing or gitignored; a production build step that can rewrite it
241
+ (`npm install` in CI, `uv sync --frozen` where `--locked` was meant, Gradle `--write-locks` in CI, or
242
+ `enableImmutableInstalls: false` / `--no-frozen-lockfile` overriding the CI default); floating ranges (`^`, `~`, `*`, `latest`) with no enforced lockfile behind them; `requirements.txt` without `==`; a lockfile whose `resolved` URLs point at
243
+ a registry other than the expected one; and vulnerable-but-unused dependencies (they still count
244
+ if the code path is reachable - check before rating severity).
245
+
246
+ ---
247
+
248
+ ## A03: Dependency Confusion and Typosquatting
249
+
250
+ Dependency confusion: an internal package name that is not registered publicly can be claimed by
251
+ an attacker, whose higher version number wins resolution when a build falls back to the public
252
+ registry.
253
+
254
+ ```ini
255
+ # UNSAFE .npmrc - private scope resolvable from the public registry
256
+ registry=https://registry.npmjs.org/
257
+
258
+ # SAFE - bind the scope to the internal registry explicitly
259
+ @mycompany:registry=https://npm.internal.example.com/
260
+ //npm.internal.example.com/:_authToken=${NPM_TOKEN}
261
+ ```
262
+
263
+ **Check for:**
264
+ - Internal package names used unscoped, or scopes not pinned to an internal registry
265
+ - A proxy/mirror configured to fall through to the public registry for internal names
266
+ - `pip install --extra-index-url` - pip picks the highest version across **all** indexes; use
267
+ `--index-url` with a single trusted mirror
268
+ - Names one edit away from a popular package (`crossenv`, `python3-dateutil`, `reqeusts`),
269
+ packages with very recent first-publish dates, or a maintainer change on a critical dependency
270
+ - Git/URL dependencies pointing at a branch rather than a commit SHA
271
+
272
+ ---
273
+
274
+ ## A03: Install Scripts
275
+
276
+ Package installation executes code. `npm install` runs `preinstall`/`postinstall` from every
277
+ package in the tree, with the developer's or CI runner's privileges.
278
+
279
+ ```json
280
+ // Review any package that ships this - it is the standard malware entry point
281
+ { "scripts": { "postinstall": "node ./scripts/collect.js" } }
282
+ ```
283
+
284
+ Mitigations: `npm ci --ignore-scripts` (then run the builds you actually need explicitly),
285
+ `pip install --only-binary :all:` to avoid arbitrary `setup.py` execution, and running installs
286
+ in a container without credentials or network access beyond the registry.
287
+
288
+ ---
289
+
290
+ ## A03: CI/CD Pipelines
291
+
292
+ The pipeline has repository write access and production credentials. It is a higher-value target
293
+ than the application.
294
+
295
+ ```yaml
296
+ # UNSAFE - GitHub Actions
297
+ on: pull_request_target # runs with a writable token AND secrets...
298
+ jobs:
299
+ build:
300
+ steps:
301
+ - uses: actions/checkout@v4
302
+ with:
303
+ ref: ${{ github.event.pull_request.head.sha }} # ...on the fork's code. RCE.
304
+ - uses: some-org/some-action@main # mutable ref
305
+ - run: echo "Title: ${{ github.event.pull_request.title }}" # script injection
306
+ ```
307
+
308
+ ```yaml
309
+ # SAFE
310
+ on: pull_request # read-only token, no secrets for forks
311
+ permissions:
312
+ contents: read # least privilege, declared explicitly
313
+ jobs:
314
+ build:
315
+ steps:
316
+ - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # pinned SHA
317
+ - env:
318
+ TITLE: ${{ github.event.pull_request.title }} # via env, not interpolated into the shell
319
+ run: echo "Title: $TITLE"
320
+ ```
321
+
322
+ **Check for:**
323
+ - `pull_request_target` or `workflow_run` that checks out untrusted code - the combination of
324
+ fork code plus secrets is the critical one
325
+ - `${{ }}` interpolation of attacker-controllable fields (PR title, branch name, issue body,
326
+ commit message) directly into `run:` - the expression is substituted before the shell sees it
327
+ - Third-party actions referenced by tag or branch instead of a commit SHA; tags are mutable
328
+ - `permissions:` not restricted (default may be write-all)
329
+ - Secrets echoed, passed to untrusted steps, or exposed to fork-triggered runs
330
+ - Self-hosted runners on public repositories - fork PRs get code execution on your infrastructure
331
+ - No required review or branch protection on the branch that deploys
332
+
333
+ ---
334
+
335
+ ## A03: Provenance, Signing, and SBOM
336
+
337
+ - Generate an SBOM (CycloneDX or SPDX) as a build artifact, not as a one-off report
338
+ - Verify signatures before deploy: `cosign verify`, `npm audit signatures`, sigstore attestations
339
+ - Publish with provenance (`npm publish --provenance`, SLSA attestations) so consumers can verify
340
+ which workflow and commit produced an artifact
341
+ - Pin container images by digest, not tag - a tag can be repointed after your review
342
+ - Keep a rollback path: an artifact whose signature fails verification should block the deploy,
343
+ which only works if failing closed does not leave you unable to ship the previous version
344
+
345
+ Continuous monitoring (Dependabot, Renovate, Snyk, `osv-scanner`, `pip-audit`, `cargo audit`)
346
+ matters more than a point-in-time audit - the dependency was clean on the day you reviewed it.