@zivis/mcp 0.1.8 → 0.1.10

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 (330) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +19 -0
  3. package/dist/api-client.d.ts +2 -24
  4. package/dist/api-client.js +32 -52
  5. package/dist/auth/index.d.ts +1 -22
  6. package/dist/auth/index.js +17 -38
  7. package/dist/auth/jwt.d.ts +0 -16
  8. package/dist/auth/jwt.js +0 -13
  9. package/dist/auth/keychain.d.ts +6 -32
  10. package/dist/auth/keychain.js +83 -114
  11. package/dist/auth/oauth.d.ts +3 -32
  12. package/dist/auth/oauth.js +67 -61
  13. package/dist/auth/sessions.d.ts +5 -25
  14. package/dist/auth/sessions.js +20 -39
  15. package/dist/auth/token-refresh.d.ts +2 -22
  16. package/dist/auth/token-refresh.js +33 -36
  17. package/dist/cli.d.ts +1 -18
  18. package/dist/cli.js +30 -908
  19. package/dist/index.d.ts +0 -6
  20. package/dist/index.js +0 -7
  21. package/dist/lib/inspect-cache.d.ts +10 -0
  22. package/dist/lib/inspect-cache.js +75 -0
  23. package/dist/lib/next-steps.d.ts +27 -0
  24. package/dist/lib/next-steps.js +21 -0
  25. package/dist/matcher/ast-eval.d.ts +8 -0
  26. package/dist/matcher/ast-eval.js +95 -0
  27. package/dist/matcher/finding.d.ts +55 -0
  28. package/dist/matcher/finding.js +1 -0
  29. package/dist/matcher/index.d.ts +8 -0
  30. package/dist/matcher/index.js +202 -0
  31. package/dist/matcher/inference-candidates.d.ts +26 -0
  32. package/dist/matcher/inference-candidates.js +81 -0
  33. package/dist/matcher/walker.d.ts +7 -0
  34. package/dist/matcher/walker.js +71 -0
  35. package/dist/pattern-pack/index.d.ts +125 -0
  36. package/dist/pattern-pack/index.js +189 -0
  37. package/dist/pattern-packs/zivis-public-0.2.0/capsules/agents/privilege-separation.yaml +224 -0
  38. package/dist/pattern-packs/zivis-public-0.2.0/capsules/prompting/self-consistency-no-isolation.yaml +237 -0
  39. package/dist/pattern-packs/zivis-public-0.2.0/capsules/retrieval/context-injection-no-validator.yaml +348 -0
  40. package/dist/pattern-packs/zivis-public-0.2.0/capsules/security/late-org-filter.yaml +266 -0
  41. package/dist/pattern-packs/zivis-public-0.2.0/controls/external_validator_on_facts.yaml +37 -0
  42. package/dist/pattern-packs/zivis-public-0.2.0/controls/fact_validator_present.yaml +68 -0
  43. package/dist/pattern-packs/zivis-public-0.2.0/controls/human_approval_gate.yaml +44 -0
  44. package/dist/pattern-packs/zivis-public-0.2.0/controls/langgraph_state_machine_with_per_node_tools.yaml +35 -0
  45. package/dist/pattern-packs/zivis-public-0.2.0/controls/per_sample_retrieval_diversification.yaml +38 -0
  46. package/dist/pattern-packs/zivis-public-0.2.0/controls/prisma_extension_or_middleware_attaching_org_filter.yaml +31 -0
  47. package/dist/pattern-packs/zivis-public-0.2.0/controls/row_level_security_policy.yaml +37 -0
  48. package/dist/pattern-packs/zivis-public-0.2.0/controls/source_attribution_present.yaml +58 -0
  49. package/dist/pattern-packs/zivis-public-0.2.0/manifest.json +167 -0
  50. package/dist/pattern-packs/zivis-public-0.2.0/prompts/agents/privilege-separation/identify.md +54 -0
  51. package/dist/pattern-packs/zivis-public-0.2.0/prompts/prompting/self-consistency-no-isolation/identify.md +60 -0
  52. package/dist/pattern-packs/zivis-public-0.2.0/prompts/retrieval/context-injection-no-validator/identify.md +109 -0
  53. package/dist/pattern-packs/zivis-public-0.2.0/prompts/security/late-org-filter/identify.md +78 -0
  54. package/dist/project-binding.d.ts +2 -19
  55. package/dist/project-binding.js +38 -21
  56. package/dist/prompts/audit-dependencies.d.ts +2 -0
  57. package/dist/prompts/audit-dependencies.js +47 -0
  58. package/dist/prompts/getting-started.d.ts +2 -0
  59. package/dist/prompts/getting-started.js +37 -0
  60. package/dist/prompts/index.d.ts +2 -0
  61. package/dist/prompts/index.js +6 -0
  62. package/dist/resolve-application-id.d.ts +0 -4
  63. package/dist/resolve-application-id.js +0 -5
  64. package/dist/sanitize.d.ts +1 -21
  65. package/dist/sanitize.js +7 -41
  66. package/dist/server.d.ts +1 -13
  67. package/dist/server.js +142 -265
  68. package/dist/tools/artifacts.d.ts +76 -0
  69. package/dist/tools/artifacts.js +178 -0
  70. package/dist/tools/check-project.d.ts +5 -18
  71. package/dist/tools/check-project.js +122 -110
  72. package/dist/tools/check-repo-trust.d.ts +4 -19
  73. package/dist/tools/check-repo-trust.js +56 -47
  74. package/dist/tools/create-diagram.d.ts +0 -5
  75. package/dist/tools/create-diagram.js +0 -10
  76. package/dist/tools/create-document.d.ts +0 -5
  77. package/dist/tools/create-document.js +3 -9
  78. package/dist/tools/create-finding.d.ts +85 -0
  79. package/dist/tools/create-finding.js +136 -0
  80. package/dist/tools/delete-finding.d.ts +19 -0
  81. package/dist/tools/delete-finding.js +36 -0
  82. package/dist/tools/devx-run.d.ts +88 -0
  83. package/dist/tools/devx-run.js +175 -0
  84. package/dist/tools/discover-local-infra.d.ts +0 -10
  85. package/dist/tools/discover-local-infra.js +3 -73
  86. package/dist/tools/enterprise/get-org-zat.d.ts +0 -5
  87. package/dist/tools/enterprise/get-org-zat.js +0 -6
  88. package/dist/tools/explain-signal-for-diff.d.ts +34 -0
  89. package/dist/tools/explain-signal-for-diff.js +75 -0
  90. package/dist/tools/generate-diagram.d.ts +0 -6
  91. package/dist/tools/generate-diagram.js +21 -13
  92. package/dist/tools/get-application-overview.d.ts +0 -5
  93. package/dist/tools/get-application-overview.js +0 -6
  94. package/dist/tools/get-application.d.ts +0 -5
  95. package/dist/tools/get-application.js +0 -6
  96. package/dist/tools/get-diagram.d.ts +0 -5
  97. package/dist/tools/get-diagram.js +1 -11
  98. package/dist/tools/get-document.d.ts +0 -5
  99. package/dist/tools/get-document.js +0 -6
  100. package/dist/tools/get-oss-zat.d.ts +0 -5
  101. package/dist/tools/get-oss-zat.js +0 -7
  102. package/dist/tools/get-signal.d.ts +24 -0
  103. package/dist/tools/get-signal.js +75 -0
  104. package/dist/tools/get-started.d.ts +18 -0
  105. package/dist/tools/get-started.js +470 -0
  106. package/dist/tools/get-trust-keys.d.ts +0 -5
  107. package/dist/tools/get-trust-keys.js +0 -6
  108. package/dist/tools/import-openapi-endpoints.d.ts +0 -5
  109. package/dist/tools/import-openapi-endpoints.js +0 -6
  110. package/dist/tools/inspect-zat.d.ts +0 -5
  111. package/dist/tools/inspect-zat.js +0 -19
  112. package/dist/tools/inspect.d.ts +21 -0
  113. package/dist/tools/inspect.js +222 -0
  114. package/dist/tools/list-applications.d.ts +1 -6
  115. package/dist/tools/list-applications.js +0 -6
  116. package/dist/tools/list-diagrams.d.ts +0 -5
  117. package/dist/tools/list-diagrams.js +0 -6
  118. package/dist/tools/list-documents.d.ts +0 -5
  119. package/dist/tools/list-documents.js +0 -6
  120. package/dist/tools/list-endpoints.d.ts +1 -6
  121. package/dist/tools/list-endpoints.js +0 -6
  122. package/dist/tools/list-signals.d.ts +37 -0
  123. package/dist/tools/list-signals.js +83 -0
  124. package/dist/tools/manage-application.d.ts +64 -0
  125. package/dist/tools/manage-application.js +129 -0
  126. package/dist/tools/manage-diagram.d.ts +0 -5
  127. package/dist/tools/manage-diagram.js +0 -16
  128. package/dist/tools/manage-endpoint-lifecycle.d.ts +80 -0
  129. package/dist/tools/manage-endpoint-lifecycle.js +180 -0
  130. package/dist/tools/open-in-ide.d.ts +2 -14
  131. package/dist/tools/open-in-ide.js +0 -13
  132. package/dist/tools/review-change.d.ts +34 -0
  133. package/dist/tools/review-change.js +93 -0
  134. package/dist/tools/security-memory.d.ts +76 -0
  135. package/dist/tools/security-memory.js +202 -0
  136. package/dist/tools/security-review.d.ts +1 -21
  137. package/dist/tools/security-review.js +8 -108
  138. package/dist/tools/threat-get-capsule.d.ts +15 -0
  139. package/dist/tools/threat-get-capsule.js +53 -0
  140. package/dist/tools/threat-get-inference-prompt.d.ts +15 -0
  141. package/dist/tools/threat-get-inference-prompt.js +73 -0
  142. package/dist/tools/threat-list-relevant-capsules.d.ts +17 -0
  143. package/dist/tools/threat-list-relevant-capsules.js +158 -0
  144. package/dist/tools/threat-run-matcher.d.ts +17 -0
  145. package/dist/tools/threat-run-matcher.js +145 -0
  146. package/dist/tools/update-document.d.ts +0 -5
  147. package/dist/tools/update-document.js +3 -9
  148. package/dist/tools/update-endpoint.d.ts +1 -6
  149. package/dist/tools/update-endpoint.js +0 -7
  150. package/dist/tools/update-finding.d.ts +61 -0
  151. package/dist/tools/update-finding.js +80 -0
  152. package/dist/tools/update-mermaid-source.d.ts +0 -13
  153. package/dist/tools/update-mermaid-source.js +0 -14
  154. package/dist/tools/verify-trust-mark.d.ts +0 -5
  155. package/dist/tools/verify-trust-mark.js +0 -6
  156. package/dist/types.d.ts +14 -14
  157. package/dist/types.js +22 -28
  158. package/package.json +38 -15
  159. package/dist/api-client.js.map +0 -1
  160. package/dist/auth/index.js.map +0 -1
  161. package/dist/auth/jwt.js.map +0 -1
  162. package/dist/auth/keychain.js.map +0 -1
  163. package/dist/auth/oauth.js.map +0 -1
  164. package/dist/auth/sessions.js.map +0 -1
  165. package/dist/auth/token-refresh.js.map +0 -1
  166. package/dist/cli.js.map +0 -1
  167. package/dist/index.js.map +0 -1
  168. package/dist/project-binding.js.map +0 -1
  169. package/dist/resolve-application-id.js.map +0 -1
  170. package/dist/sanitize.js.map +0 -1
  171. package/dist/server.js.map +0 -1
  172. package/dist/tools/check-project.js.map +0 -1
  173. package/dist/tools/check-repo-trust.js.map +0 -1
  174. package/dist/tools/create-diagram.js.map +0 -1
  175. package/dist/tools/create-document.js.map +0 -1
  176. package/dist/tools/discover-local-infra.js.map +0 -1
  177. package/dist/tools/enterprise/capture-evidence.d.ts +0 -54
  178. package/dist/tools/enterprise/capture-evidence.js +0 -72
  179. package/dist/tools/enterprise/capture-evidence.js.map +0 -1
  180. package/dist/tools/enterprise/create-report-ticket.d.ts +0 -34
  181. package/dist/tools/enterprise/create-report-ticket.js +0 -44
  182. package/dist/tools/enterprise/create-report-ticket.js.map +0 -1
  183. package/dist/tools/enterprise/end-pentest-session.d.ts +0 -33
  184. package/dist/tools/enterprise/end-pentest-session.js +0 -42
  185. package/dist/tools/enterprise/end-pentest-session.js.map +0 -1
  186. package/dist/tools/enterprise/generate-report.d.ts +0 -55
  187. package/dist/tools/enterprise/generate-report.js +0 -111
  188. package/dist/tools/enterprise/generate-report.js.map +0 -1
  189. package/dist/tools/enterprise/get-org-zat.js.map +0 -1
  190. package/dist/tools/enterprise/get-report-status.d.ts +0 -27
  191. package/dist/tools/enterprise/get-report-status.js +0 -38
  192. package/dist/tools/enterprise/get-report-status.js.map +0 -1
  193. package/dist/tools/enterprise/get-threat-model.d.ts +0 -29
  194. package/dist/tools/enterprise/get-threat-model.js +0 -83
  195. package/dist/tools/enterprise/get-threat-model.js.map +0 -1
  196. package/dist/tools/enterprise/list-agents.d.ts +0 -42
  197. package/dist/tools/enterprise/list-agents.js +0 -95
  198. package/dist/tools/enterprise/list-agents.js.map +0 -1
  199. package/dist/tools/enterprise/list-report-issues.d.ts +0 -36
  200. package/dist/tools/enterprise/list-report-issues.js +0 -50
  201. package/dist/tools/enterprise/list-report-issues.js.map +0 -1
  202. package/dist/tools/enterprise/list-threat-models.d.ts +0 -36
  203. package/dist/tools/enterprise/list-threat-models.js +0 -82
  204. package/dist/tools/enterprise/list-threat-models.js.map +0 -1
  205. package/dist/tools/enterprise/manage-actor.d.ts +0 -58
  206. package/dist/tools/enterprise/manage-actor.js +0 -99
  207. package/dist/tools/enterprise/manage-actor.js.map +0 -1
  208. package/dist/tools/enterprise/manage-attack-scenario.d.ts +0 -70
  209. package/dist/tools/enterprise/manage-attack-scenario.js +0 -89
  210. package/dist/tools/enterprise/manage-attack-scenario.js.map +0 -1
  211. package/dist/tools/enterprise/manage-component.d.ts +0 -58
  212. package/dist/tools/enterprise/manage-component.js +0 -90
  213. package/dist/tools/enterprise/manage-component.js.map +0 -1
  214. package/dist/tools/enterprise/manage-data-asset.d.ts +0 -53
  215. package/dist/tools/enterprise/manage-data-asset.js +0 -90
  216. package/dist/tools/enterprise/manage-data-asset.js.map +0 -1
  217. package/dist/tools/enterprise/manage-data-flow.d.ts +0 -57
  218. package/dist/tools/enterprise/manage-data-flow.js +0 -98
  219. package/dist/tools/enterprise/manage-data-flow.js.map +0 -1
  220. package/dist/tools/enterprise/manage-finding.d.ts +0 -69
  221. package/dist/tools/enterprise/manage-finding.js +0 -106
  222. package/dist/tools/enterprise/manage-finding.js.map +0 -1
  223. package/dist/tools/enterprise/manage-security-control.d.ts +0 -59
  224. package/dist/tools/enterprise/manage-security-control.js +0 -96
  225. package/dist/tools/enterprise/manage-security-control.js.map +0 -1
  226. package/dist/tools/enterprise/manage-test-case.d.ts +0 -88
  227. package/dist/tools/enterprise/manage-test-case.js +0 -119
  228. package/dist/tools/enterprise/manage-test-case.js.map +0 -1
  229. package/dist/tools/enterprise/promote-finding-to-issue.d.ts +0 -36
  230. package/dist/tools/enterprise/promote-finding-to-issue.js +0 -65
  231. package/dist/tools/enterprise/promote-finding-to-issue.js.map +0 -1
  232. package/dist/tools/enterprise/publish-report-version.d.ts +0 -34
  233. package/dist/tools/enterprise/publish-report-version.js +0 -75
  234. package/dist/tools/enterprise/publish-report-version.js.map +0 -1
  235. package/dist/tools/enterprise/publish-test-to-library.d.ts +0 -31
  236. package/dist/tools/enterprise/publish-test-to-library.js +0 -40
  237. package/dist/tools/enterprise/publish-test-to-library.js.map +0 -1
  238. package/dist/tools/enterprise/record-test-result.d.ts +0 -67
  239. package/dist/tools/enterprise/record-test-result.js +0 -75
  240. package/dist/tools/enterprise/record-test-result.js.map +0 -1
  241. package/dist/tools/enterprise/start-pentest-session.d.ts +0 -35
  242. package/dist/tools/enterprise/start-pentest-session.js +0 -50
  243. package/dist/tools/enterprise/start-pentest-session.js.map +0 -1
  244. package/dist/tools/enterprise/sync-report-section.d.ts +0 -41
  245. package/dist/tools/enterprise/sync-report-section.js +0 -79
  246. package/dist/tools/enterprise/sync-report-section.js.map +0 -1
  247. package/dist/tools/enterprise/update-report-issue.d.ts +0 -55
  248. package/dist/tools/enterprise/update-report-issue.js +0 -69
  249. package/dist/tools/enterprise/update-report-issue.js.map +0 -1
  250. package/dist/tools/generate-diagram.js.map +0 -1
  251. package/dist/tools/get-agent-test-results.d.ts +0 -41
  252. package/dist/tools/get-agent-test-results.js +0 -86
  253. package/dist/tools/get-agent-test-results.js.map +0 -1
  254. package/dist/tools/get-application-overview.js.map +0 -1
  255. package/dist/tools/get-application.js.map +0 -1
  256. package/dist/tools/get-artifact-content.d.ts +0 -29
  257. package/dist/tools/get-artifact-content.js +0 -86
  258. package/dist/tools/get-artifact-content.js.map +0 -1
  259. package/dist/tools/get-diagram.js.map +0 -1
  260. package/dist/tools/get-document.js.map +0 -1
  261. package/dist/tools/get-finding-details.d.ts +0 -28
  262. package/dist/tools/get-finding-details.js +0 -43
  263. package/dist/tools/get-finding-details.js.map +0 -1
  264. package/dist/tools/get-findings.d.ts +0 -57
  265. package/dist/tools/get-findings.js +0 -103
  266. package/dist/tools/get-findings.js.map +0 -1
  267. package/dist/tools/get-oss-zat.js.map +0 -1
  268. package/dist/tools/get-recon-scan.d.ts +0 -27
  269. package/dist/tools/get-recon-scan.js +0 -46
  270. package/dist/tools/get-recon-scan.js.map +0 -1
  271. package/dist/tools/get-scan-output.d.ts +0 -27
  272. package/dist/tools/get-scan-output.js +0 -64
  273. package/dist/tools/get-scan-output.js.map +0 -1
  274. package/dist/tools/get-scenario-details.d.ts +0 -27
  275. package/dist/tools/get-scenario-details.js +0 -46
  276. package/dist/tools/get-scenario-details.js.map +0 -1
  277. package/dist/tools/get-test-case-results.d.ts +0 -37
  278. package/dist/tools/get-test-case-results.js +0 -66
  279. package/dist/tools/get-test-case-results.js.map +0 -1
  280. package/dist/tools/get-test-details.d.ts +0 -29
  281. package/dist/tools/get-test-details.js +0 -49
  282. package/dist/tools/get-test-details.js.map +0 -1
  283. package/dist/tools/get-trust-keys.js.map +0 -1
  284. package/dist/tools/import-openapi-endpoints.js.map +0 -1
  285. package/dist/tools/inspect-zat.js.map +0 -1
  286. package/dist/tools/list-agent-test-cases.d.ts +0 -41
  287. package/dist/tools/list-agent-test-cases.js +0 -73
  288. package/dist/tools/list-agent-test-cases.js.map +0 -1
  289. package/dist/tools/list-applications.js.map +0 -1
  290. package/dist/tools/list-diagrams.js.map +0 -1
  291. package/dist/tools/list-documents.js.map +0 -1
  292. package/dist/tools/list-endpoints.js.map +0 -1
  293. package/dist/tools/list-recon-scans.d.ts +0 -36
  294. package/dist/tools/list-recon-scans.js +0 -74
  295. package/dist/tools/list-recon-scans.js.map +0 -1
  296. package/dist/tools/list-scan-artifacts.d.ts +0 -41
  297. package/dist/tools/list-scan-artifacts.js +0 -63
  298. package/dist/tools/list-scan-artifacts.js.map +0 -1
  299. package/dist/tools/list-scans.d.ts +0 -44
  300. package/dist/tools/list-scans.js +0 -91
  301. package/dist/tools/list-scans.js.map +0 -1
  302. package/dist/tools/list-test-library.d.ts +0 -44
  303. package/dist/tools/list-test-library.js +0 -83
  304. package/dist/tools/list-test-library.js.map +0 -1
  305. package/dist/tools/list-test-scenarios.d.ts +0 -31
  306. package/dist/tools/list-test-scenarios.js +0 -66
  307. package/dist/tools/list-test-scenarios.js.map +0 -1
  308. package/dist/tools/local-scan.d.ts +0 -40
  309. package/dist/tools/local-scan.js +0 -261
  310. package/dist/tools/local-scan.js.map +0 -1
  311. package/dist/tools/manage-diagram.js.map +0 -1
  312. package/dist/tools/open-in-ide.js.map +0 -1
  313. package/dist/tools/run-test-scenario.d.ts +0 -37
  314. package/dist/tools/run-test-scenario.js +0 -70
  315. package/dist/tools/run-test-scenario.js.map +0 -1
  316. package/dist/tools/scan-pr.d.ts +0 -27
  317. package/dist/tools/scan-pr.js +0 -51
  318. package/dist/tools/scan-pr.js.map +0 -1
  319. package/dist/tools/security-review.js.map +0 -1
  320. package/dist/tools/setup-red-team-target.d.ts +0 -79
  321. package/dist/tools/setup-red-team-target.js +0 -430
  322. package/dist/tools/setup-red-team-target.js.map +0 -1
  323. package/dist/tools/triage-finding.d.ts +0 -47
  324. package/dist/tools/triage-finding.js +0 -116
  325. package/dist/tools/triage-finding.js.map +0 -1
  326. package/dist/tools/update-document.js.map +0 -1
  327. package/dist/tools/update-endpoint.js.map +0 -1
  328. package/dist/tools/update-mermaid-source.js.map +0 -1
  329. package/dist/tools/verify-trust-mark.js.map +0 -1
  330. package/dist/types.js.map +0 -1
@@ -0,0 +1,237 @@
1
+ # Capsule: Self-consistency without context isolation
2
+ # Spec: docs/specs/PATTERN-MATCHING-LIBRARY-V1.md
3
+ # Plan: docs/plans/LOCAL-REPO-GRAPH-IMPLEMENTATION.md
4
+ # Schema: schemas/pattern-detection-card.schema.json
5
+
6
+ id: prompting.self-consistency-no-isolation
7
+ slug: self-consistency-no-isolation
8
+ version: 0.1.0
9
+ category: prompting
10
+ title: Self-Consistency Without Context Isolation
11
+ headline: Vote Without Independence
12
+ description: >
13
+ Detects code that aggregates multiple LLM samples (vote, consensus, ranking)
14
+ while every sample shares the same untrusted context. Majority voting only
15
+ filters random noise — when context is shared, correlated errors override
16
+ correctness and the vote count is mis-read as calibrated confidence.
17
+
18
+ detection_tier: public
19
+ scoring_tier: proprietary
20
+
21
+ applicable_languages:
22
+ - typescript
23
+ - javascript
24
+ - python
25
+
26
+ relevance_filter:
27
+ any_of:
28
+ - dependency: openai
29
+ direct_only: true
30
+ - dependency: "@anthropic-ai/sdk"
31
+ direct_only: true
32
+ - dependency: anthropic
33
+ direct_only: true
34
+ - dependency: "ai"
35
+ direct_only: true
36
+ - dependency: langchain
37
+ direct_only: true
38
+ - dependency: llama-index
39
+ direct_only: true
40
+
41
+ strategies:
42
+ - code: AST
43
+ language: python
44
+ expression: |
45
+ rule:
46
+ kind: for_statement
47
+ has:
48
+ kind: call
49
+ any:
50
+ - pattern: $CLIENT.chat.completions.create($$$)
51
+ - pattern: $CLIENT.messages.create($$$)
52
+ - pattern: openai.ChatCompletion.create($$$)
53
+ evidence_fields: [file_path, line_span, symbol]
54
+ confidence_weight: 0.30
55
+
56
+ - code: AST
57
+ language: typescript
58
+ expression: |
59
+ rule:
60
+ any:
61
+ - pattern: $_.chat.completions.create($$$)
62
+ - pattern: generateText($$$)
63
+ - pattern: streamText($$$)
64
+ inside:
65
+ stopBy: end
66
+ any:
67
+ - pattern: Promise.all($$$)
68
+ - pattern: $X.map($$$)
69
+ - kind: for_statement
70
+ - kind: while_statement
71
+ evidence_fields: [file_path, line_span, symbol]
72
+ confidence_weight: 0.30
73
+
74
+ - code: GRAPH
75
+ expression: |
76
+ same_messages_argument_passed_to_n_completion_calls(n >= 2)
77
+ AND aggregator_observed(any_of: Counter, max(set(.), key=.count), majority_vote, np.argmax, statistics.mode)
78
+ evidence_fields: [graph_path, file_spans, node_ids]
79
+ confidence_weight: 0.30
80
+
81
+ - code: META
82
+ expression:
83
+ none_of_controls:
84
+ - per_sample_retrieval_diversification
85
+ - external_validator_on_facts
86
+ - human_approval_gate
87
+ evidence_fields: [missing_controls]
88
+ confidence_weight: 0.25
89
+
90
+ - code: INFER
91
+ expression: prompt_id:prompting.self-consistency-no-isolation.identify
92
+ evidence_fields: [llm_rationale]
93
+ confidence_weight: 0.15
94
+ trusted: false
95
+
96
+ required_evidence_count: 2
97
+
98
+ control_negations:
99
+ - "presence_of(per_sample_retrieval_diversification)"
100
+ - "presence_of(external_validator_on_facts)"
101
+ - "presence_of(human_approval_gate)"
102
+
103
+ threats:
104
+ - title: Vote count mistaken for calibrated confidence
105
+ stride: [tampering, repudiation]
106
+ description: >
107
+ The application treats agreement across samples as independent confirmation,
108
+ when in fact every sample saw the same poisoned retrieval context or the
109
+ same prompt-injection payload. Downstream actions (auto-approve, send,
110
+ execute) fire under false high-confidence signal.
111
+ remediation: >
112
+ Diversify per-sample retrieval queries, temperatures, or seeds.
113
+ Add an external fact-validator. For high-impact outputs, require a human
114
+ approval gate. Never expose vote count as a confidence number to users
115
+ without disclosing the independence assumption.
116
+ - title: Correlated injection amplification
117
+ stride: [tampering]
118
+ description: >
119
+ A single prompt-injection payload in shared retrieved context biases all N
120
+ samples identically; majority vote then ratifies the attack rather than
121
+ filtering it.
122
+ remediation: >
123
+ Per-sample context isolation. Run independent retrieval (different queries
124
+ or different stores) per sample so an injection only contaminates a subset.
125
+
126
+ fixtures:
127
+ positive:
128
+ - "fixtures/positive/self-consistency-no-isolation/openai_loop_vote_python"
129
+ - "fixtures/positive/self-consistency-no-isolation/anthropic_promise_all_typescript"
130
+ negative:
131
+ - "fixtures/negative/self-consistency-no-isolation/per_sample_diverse_retrieval"
132
+ - "fixtures/negative/self-consistency-no-isolation/single_completion_no_aggregation"
133
+
134
+ lifecycle: draft
135
+ owner: platform-threat-modeling
136
+ tags:
137
+ - prompting
138
+ - self-consistency
139
+ - context-isolation
140
+ - prompt-injection-amplification
141
+
142
+ sensitivity_level: customer_safe
143
+ allowed_execution_modes:
144
+ - local_only
145
+ - local_model
146
+ - hybrid_cloud_eval
147
+
148
+ safe_summary: >
149
+ Multiple LLM completions are aggregated by voting or consensus, but every
150
+ sample sees the same retrieved context or the same user message. Independence
151
+ is assumed and not enforced. A single prompt-injection or a single
152
+ hallucinated retrieval contaminates the vote uniformly; majority count is
153
+ mistaken for calibrated confidence and downstream actions fire under
154
+ false certainty.
155
+
156
+ detect_when: >
157
+ Two or more LLM completions for the same user task are merged by voting,
158
+ consensus, or similarity scoring without independent context isolation —
159
+ no per-sample retrieval diversification, no external validator, no human gate.
160
+
161
+ risk_hints:
162
+ - Shared retrieval/injection in the user message affects every sample the same way
163
+ - Majority vote amplifies systematic bias rather than filtering noise
164
+ - Vote count surfaced as a confidence number is a UX lie when context is shared
165
+ - Async Promise.all with the same messages array is the most common JS shape
166
+
167
+ architectural_signals:
168
+ - Same `messages` argument passed to N completion calls inside a loop or Promise.all
169
+ - majority_vote, Counter, np.argmax, statistics.mode applied to the result array
170
+ - Single retrieval call upstream feeding all samples
171
+
172
+ model_task_prompt_ref: prompts/prompting/self-consistency-no-isolation/identify.md
173
+
174
+ expected_output_schema:
175
+ type: object
176
+ required: [independence_assessment, confidence_claim_risk, evidence_spans]
177
+ properties:
178
+ independence_assessment:
179
+ type: string
180
+ enum: [shared_context, isolated_context, unclear]
181
+ confidence_claim_risk:
182
+ type: string
183
+ enum: [high, medium, low]
184
+ description: How dangerous is the confidence claim users see, given the (lack of) independence
185
+ rationale:
186
+ type: string
187
+ recommended_controls:
188
+ type: array
189
+ items:
190
+ type: string
191
+ enum: [per_sample_retrieval_diversification, external_validator, human_approval, temperature_variation, seed_variation]
192
+ evidence_spans:
193
+ type: array
194
+ items:
195
+ type: object
196
+ required: [file]
197
+ properties:
198
+ file: { type: string }
199
+ start_line: { type: integer }
200
+ end_line: { type: integer }
201
+ note: { type: string }
202
+
203
+ minimum_context_required:
204
+ lines: 80
205
+ symbols:
206
+ - chat.completions.create
207
+ - messages.create
208
+ - generateText
209
+ - Counter
210
+ - majority
211
+ - np.argmax
212
+
213
+ related_patterns:
214
+ - prompting.chain-of-thought-leakage
215
+ - retrieval.shared-context-poisoning
216
+
217
+ repair_contract:
218
+ allowed:
219
+ - Diversify retrieval queries per sample
220
+ - Vary temperature or seed across samples
221
+ - Add an external fact validator on aggregated output
222
+ - Add a human approval gate before high-impact actions
223
+ forbidden:
224
+ - Silently treating vote count as calibrated confidence
225
+ - Removing the aggregation entirely for performance reasons (does not address the architectural issue)
226
+ - Adding more samples without addressing context independence
227
+
228
+ validation_contract:
229
+ requires_tests_pass: false
230
+ requires_static_rules:
231
+ - aggregator_remains_present_after_patch
232
+ - independence_mechanism_introduced
233
+
234
+ unsafe_to_expose_fields:
235
+ - internal_rubric
236
+ - golden_transcripts
237
+ - exploit_templates
@@ -0,0 +1,348 @@
1
+ # Capsule: RAG context injection — retrieved content reaches the model without validation
2
+ # Spec: docs/specs/PATTERN-MATCHING-LIBRARY-V1.md
3
+ # Plan: docs/plans/LOCAL-REPO-GRAPH-IMPLEMENTATION.md
4
+ # Schema: schemas/pattern-detection-card.schema.json
5
+
6
+ id: retrieval.context-injection-no-validator
7
+ slug: context-injection-no-validator
8
+ version: 0.1.0
9
+ category: retrieval
10
+ title: Retrieval Context Injection — No Validator Between Retriever and Model
11
+ headline: Retrieved Content Flows Into the LLM With Nothing Inspecting It First
12
+
13
+ description: >
14
+ Detects retrieval-augmented generation (RAG) flows where the output of a
15
+ retriever (vector store, search index, document loader) is passed directly
16
+ into the model call with no fact-validator, source-attribution check, or
17
+ content sanitizer in between. Retrieval becomes a transparent injection
18
+ channel: anyone who can write to the knowledge base — directly, via a
19
+ scraping job, or via a tool the agent itself calls — can steer the model.
20
+
21
+ detection_tier: public
22
+ scoring_tier: proprietary
23
+
24
+ applicable_languages:
25
+ - typescript
26
+ - javascript
27
+ - python
28
+
29
+ relevance_filter:
30
+ any_of:
31
+ # LangChain / LlamaIndex RAG stacks
32
+ - dependency: langchain
33
+ direct_only: true
34
+ - dependency: "@langchain/core"
35
+ direct_only: true
36
+ - dependency: "@langchain/openai"
37
+ direct_only: true
38
+ - dependency: "@langchain/anthropic"
39
+ direct_only: true
40
+ - dependency: "@langchain/community"
41
+ direct_only: true
42
+ - dependency: llamaindex
43
+ direct_only: true
44
+ - dependency: "llama-index"
45
+ direct_only: true
46
+ # Manual RAG: any LLM SDK + a vector store / retrieval client
47
+ - dependency: openai
48
+ direct_only: true
49
+ - dependency: "@anthropic-ai/sdk"
50
+ direct_only: true
51
+ - dependency: anthropic
52
+ direct_only: true
53
+ - dependency: "@pinecone-database/pinecone"
54
+ direct_only: true
55
+ - dependency: pinecone-client
56
+ direct_only: true
57
+ - dependency: "@qdrant/js-client-rest"
58
+ direct_only: true
59
+ - dependency: qdrant-client
60
+ direct_only: true
61
+ - dependency: weaviate-ts-client
62
+ direct_only: true
63
+ - dependency: weaviate-client
64
+ direct_only: true
65
+ - dependency: chromadb
66
+ direct_only: true
67
+ - dependency: "@elastic/elasticsearch"
68
+ direct_only: true
69
+ - dependency: elasticsearch
70
+
71
+ strategies:
72
+ # AST as architectural evidence (NOT a vulnerability claim) — does this
73
+ # codebase even have a retrieval→LLM call shape? If it doesn't, the
74
+ # pattern can't apply.
75
+ - code: AST
76
+ language: typescript
77
+ expression: |
78
+ rule:
79
+ any:
80
+ # LangChain idioms
81
+ - pattern: $RETRIEVER.invoke($$$)
82
+ - pattern: $RETRIEVER.getRelevantDocuments($$$)
83
+ - pattern: new RetrievalQAChain($$$)
84
+ - pattern: RetrievalQAChain.fromLLM($$$)
85
+ - pattern: createRetrievalChain($$$)
86
+ # LlamaIndex
87
+ - pattern: $INDEX.asQueryEngine($$$)
88
+ - pattern: $QUERY_ENGINE.query($$$)
89
+ # Manual RAG: vector-store similarity search feeding a model call
90
+ - pattern: $STORE.similaritySearch($$$)
91
+ - pattern: $STORE.similaritySearchWithScore($$$)
92
+ evidence_fields: [file_path, line_span, symbol]
93
+ confidence_weight: 0.40
94
+
95
+ - code: AST
96
+ language: python
97
+ expression: |
98
+ rule:
99
+ any:
100
+ # LangChain
101
+ - pattern: $RETRIEVER.invoke($$$)
102
+ - pattern: $RETRIEVER.get_relevant_documents($$$)
103
+ - pattern: RetrievalQA.from_chain_type($$$)
104
+ - pattern: create_retrieval_chain($$$)
105
+ # LlamaIndex
106
+ - pattern: $INDEX.as_query_engine($$$)
107
+ - pattern: $QUERY_ENGINE.query($$$)
108
+ # Manual RAG: vector-store similarity search
109
+ - pattern: $STORE.similarity_search($$$)
110
+ - pattern: $STORE.similarity_search_with_score($$$)
111
+ evidence_fields: [file_path, line_span, symbol]
112
+ confidence_weight: 0.40
113
+
114
+ # GRAPH strategy — forward-compatible. Matcher v1 doesn't evaluate
115
+ # graph predicates yet (per Phase 3 v1 in LOCAL-REPO-GRAPH-IMPLEMENTATION),
116
+ # but writing it now means the card "lights up" when the matcher catches
117
+ # up, without re-authoring.
118
+ - code: GRAPH
119
+ expression: |
120
+ retrieval_node_returns_documents
121
+ AND llm_call_node_consumes_documents
122
+ AND NO_NODE_BETWEEN(retrieval_node, llm_call_node) matches
123
+ (validator | fact_checker | source_attribution | content_sanitizer)
124
+ evidence_fields: [graph_path, file_spans, node_ids]
125
+ confidence_weight: 0.30
126
+
127
+ # META — does the codebase declare any of the controls that would make
128
+ # this pattern safe? Absence is what we care about.
129
+ - code: META
130
+ expression:
131
+ none_of_controls:
132
+ - fact_validator_present
133
+ - source_attribution_present
134
+ evidence_fields: [missing_controls]
135
+ confidence_weight: 0.30
136
+
137
+ # INFER — the host LLM (Claude in the IDE) gets the actual source spans
138
+ # and decides whether what looks like RAG truly has no validator. This is
139
+ # the lane we want most matches to land in: ZIVIS surfaces the candidate,
140
+ # the frontier model validates against the code.
141
+ - code: INFER
142
+ expression: prompt_id:retrieval.context-injection-no-validator.identify
143
+ evidence_fields: [llm_rationale]
144
+ confidence_weight: 0.20
145
+ trusted: false
146
+
147
+ # Two deterministic strategies must fire for a trusted-lane match. AST
148
+ # alone won't promote — it's just "there is RAG-shaped code." AST + META
149
+ # (controls absent) WILL promote. GRAPH lights up later for free.
150
+ required_evidence_count: 2
151
+
152
+ control_negations:
153
+ - "presence_of(fact_validator_present)"
154
+ - "presence_of(source_attribution_present)"
155
+
156
+ threats:
157
+ - title: Indirect prompt injection via retrieved corpus
158
+ stride: [tampering, elevation_of_privilege]
159
+ description: >
160
+ An attacker who can write to the retrieval corpus — a public web page
161
+ indexed by a scraper, a Confluence space synced into the vector store,
162
+ a customer-uploaded document, or a tool the agent uses to fetch
163
+ content — embeds instructions that the model treats as authoritative
164
+ because they arrive inside the "trusted" retrieval channel. The model
165
+ executes those instructions or leaks data based on them. With no
166
+ validator inspecting the retrieved text, the system has no defense
167
+ between the corpus and the model.
168
+ remediation: >
169
+ Insert a validation step between retriever and model that (a) checks
170
+ retrieved content for prompt-injection patterns, (b) requires
171
+ source-attribution metadata before content can influence answers, and
172
+ (c) rate-limits or content-flags low-trust sources. Patterns like
173
+ guardrails-ai, NeMo Guardrails, Lakera Guard, or a custom
174
+ `validateRetrievedContent()` boundary are all valid; the requirement
175
+ is that *some* boundary exists between corpus and model.
176
+
177
+ - title: Sensitive-data exfiltration via crafted retrieval queries
178
+ stride: [information_disclosure]
179
+ description: >
180
+ An attacker who can influence the retrieval query — directly or via a
181
+ preceding LLM step that re-writes the query — pulls documents the
182
+ requesting user should not see (other tenants' data, internal-only
183
+ pages indexed by mistake, PII-laden support tickets). The model then
184
+ surfaces that content in the response. Without source-attribution and
185
+ access checks at the retrieval boundary, the model becomes an
186
+ authorization bypass.
187
+ remediation: >
188
+ Enforce access control at the retrieval layer, not just at the API
189
+ layer. Tag every indexed document with the access scope it inherits
190
+ from its source system, and filter retrieval by the requesting
191
+ user's scope before content reaches the model. Treat the retriever
192
+ as a privileged data path — same scrutiny as any other query.
193
+
194
+ - title: Long-running drift from poisoned corpus
195
+ stride: [tampering, repudiation]
196
+ description: >
197
+ A single poisoned document indexed months ago continues to surface in
198
+ relevant queries indefinitely. The model's behavior drifts in ways
199
+ that are hard to attribute to a specific bug because the cause is in
200
+ the corpus, not the code. With no audit log of which retrieved
201
+ documents influenced which responses, post-incident investigation
202
+ cannot trace bad behavior back to its source.
203
+ remediation: >
204
+ Log every retrieval — query, returned document IDs, document hashes,
205
+ source attribution — alongside the LLM call it fed. Periodically
206
+ revalidate corpus contents against current trust assumptions
207
+ (re-classify documents from sources that have been compromised or
208
+ whose access policy changed).
209
+
210
+ fixtures:
211
+ positive:
212
+ - "fixtures/positive/context-injection-no-validator/langchain_rag_chain_no_validator_typescript"
213
+ - "fixtures/positive/context-injection-no-validator/llamaindex_query_engine_no_validator_python"
214
+ - "fixtures/positive/context-injection-no-validator/manual_pinecone_to_openai_typescript"
215
+ negative:
216
+ - "fixtures/negative/context-injection-no-validator/guardrails_validator_present_python"
217
+ - "fixtures/negative/context-injection-no-validator/source_attribution_check_typescript"
218
+
219
+ lifecycle: draft
220
+ owner: platform-threat-modeling
221
+ tags:
222
+ - retrieval
223
+ - rag
224
+ - prompt-injection
225
+ - context-injection
226
+ - corpus-poisoning
227
+ - agentic-ai
228
+
229
+ sensitivity_level: customer_safe
230
+ allowed_execution_modes:
231
+ - local_only
232
+ - local_model
233
+ - hybrid_cloud_eval
234
+
235
+ safe_summary: >
236
+ The codebase has a retrieval-augmented generation (RAG) shape — content
237
+ is pulled from a vector store, search index, or document loader and
238
+ passed to the LLM — but there's no validator, sanitizer, or
239
+ source-attribution check between the retriever and the model. Anyone
240
+ who can write to the retrieval corpus can steer the model: an indexed
241
+ web page, a synced Confluence space, a customer-uploaded document, or
242
+ a tool the agent itself fetches from. The fix is to put a boundary
243
+ between corpus and model — a guardrails library, a custom validator,
244
+ or per-document source-attribution that the model is required to
245
+ surface in its answers.
246
+
247
+ detect_when: >
248
+ A retriever call (`retriever.invoke`, `similaritySearch`, query engine,
249
+ retrieval chain) is followed by an LLM call within the same handler or
250
+ function, and the path between them contains no recognizable validator
251
+ or source-attribution step. Most common in chat / Q&A / "ask the docs"
252
+ applications.
253
+
254
+ risk_hints:
255
+ - "Retrieval is a privileged data path — anything in the corpus is implicitly trusted by the model"
256
+ - "Prompt injection embedded in a web page or shared doc survives indefinitely until the document is re-indexed"
257
+ - "Query rewriting (HyDE, multi-query) compounds the problem — the rewritten query is itself an LLM output"
258
+ - "Access control at the API layer doesn't help if the retriever pulls from a corpus indexed under different rules"
259
+ - "Logging the LLM input/output without logging the retrieved documents leaves the actual injection invisible"
260
+
261
+ architectural_signals:
262
+ - "Retriever / vector store / search index call returns documents"
263
+ - "Documents are concatenated into a system or user prompt slot"
264
+ - "No intermediate function whose name suggests validation, sanitization, or fact-checking"
265
+ - "No source-attribution requirement in the prompt template"
266
+
267
+ model_task_prompt_ref: prompts/retrieval/context-injection-no-validator/identify.md
268
+
269
+ expected_output_schema:
270
+ type: object
271
+ required: [verdict, validator_location, evidence_spans]
272
+ properties:
273
+ verdict:
274
+ type: string
275
+ enum: [no_validator_present, validator_present, partial_validator, unclear]
276
+ validator_location:
277
+ type: string
278
+ enum: [pre_retrieval, between_retriever_and_model, post_model, none, multiple]
279
+ rationale:
280
+ type: string
281
+ corpus_sources:
282
+ type: array
283
+ description: "Best-effort enumeration of where the retrieved content comes from"
284
+ items:
285
+ type: string
286
+ blast_radius:
287
+ type: string
288
+ enum: [single_endpoint, route_family, service_wide, agent_wide, unclear]
289
+ recommended_controls:
290
+ type: array
291
+ items:
292
+ type: string
293
+ enum:
294
+ - guardrails_library
295
+ - custom_content_validator
296
+ - source_attribution_in_prompt
297
+ - per_document_access_control
298
+ - retrieval_audit_log
299
+ - none
300
+ evidence_spans:
301
+ type: array
302
+ items:
303
+ type: object
304
+ required: [file]
305
+ properties:
306
+ file: { type: string }
307
+ start_line: { type: integer }
308
+ end_line: { type: integer }
309
+ note: { type: string }
310
+
311
+ minimum_context_required:
312
+ lines: 120
313
+ symbols:
314
+ - retriever
315
+ - invoke
316
+ - similarity_search
317
+ - similaritySearch
318
+ - query_engine
319
+ - asQueryEngine
320
+ - RetrievalQA
321
+ - create_retrieval_chain
322
+
323
+ related_patterns:
324
+ - prompting.user-input-in-system-prompt
325
+ - agents.tool-dispatch-from-llm-output
326
+
327
+ repair_contract:
328
+ allowed:
329
+ - "Insert a validator step between retriever and model call"
330
+ - "Add source-attribution requirement to the prompt template"
331
+ - "Adopt guardrails-ai / NeMo Guardrails / Lakera Guard or equivalent"
332
+ - "Implement per-document access control at the retrieval boundary"
333
+ - "Add structured logging of retrieved-document IDs alongside LLM calls"
334
+ forbidden:
335
+ - "Removing retrieval entirely without first replacing the answering path"
336
+ - "Validating only LLM output instead of retrieved content (treats the wrong stage)"
337
+ - "Hand-rolling regex injection filters as the sole defense (well-known to be bypassable)"
338
+
339
+ validation_contract:
340
+ requires_tests_pass: false
341
+ requires_static_rules:
342
+ - validator_node_present_between_retrieval_and_llm
343
+ - retrieval_audit_log_present
344
+
345
+ unsafe_to_expose_fields:
346
+ - internal_rubric
347
+ - golden_transcripts
348
+ - exploit_templates