deployready 0.1.3 → 0.3.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 (135) hide show
  1. package/README.md +75 -9
  2. package/dist/active/accessControl.js +77 -0
  3. package/dist/active/accessControl.js.map +1 -0
  4. package/dist/active/httpAdapter.js +54 -0
  5. package/dist/active/httpAdapter.js.map +1 -0
  6. package/dist/active/jwt.js +48 -0
  7. package/dist/active/jwt.js.map +1 -0
  8. package/dist/active/requestPlan.js +78 -0
  9. package/dist/active/requestPlan.js.map +1 -0
  10. package/dist/active/runner.js +184 -0
  11. package/dist/active/runner.js.map +1 -0
  12. package/dist/active/tamper.js +94 -0
  13. package/dist/active/tamper.js.map +1 -0
  14. package/dist/active/tokenHelp.js +33 -0
  15. package/dist/active/tokenHelp.js.map +1 -0
  16. package/dist/active/types.js +3 -0
  17. package/dist/active/types.js.map +1 -0
  18. package/dist/agent/FileEditor.js +91 -17
  19. package/dist/agent/FileEditor.js.map +1 -1
  20. package/dist/agent/FixManager.js +128 -4
  21. package/dist/agent/FixManager.js.map +1 -1
  22. package/dist/agent/lineFixers.js +29 -0
  23. package/dist/agent/lineFixers.js.map +1 -0
  24. package/dist/ai/CliHandler.js +80 -0
  25. package/dist/ai/CliHandler.js.map +1 -0
  26. package/dist/ai/ModelRouter.js +42 -1
  27. package/dist/ai/ModelRouter.js.map +1 -1
  28. package/dist/ai/cli/argv.js +67 -0
  29. package/dist/ai/cli/argv.js.map +1 -0
  30. package/dist/ai/cli/env.js +46 -0
  31. package/dist/ai/cli/env.js.map +1 -0
  32. package/dist/ai/cli/errors.js +15 -0
  33. package/dist/ai/cli/errors.js.map +1 -0
  34. package/dist/ai/cli/parseOutput.js +151 -0
  35. package/dist/ai/cli/parseOutput.js.map +1 -0
  36. package/dist/ai/cli/providers.js +30 -0
  37. package/dist/ai/cli/providers.js.map +1 -0
  38. package/dist/ai/cli/ready.js +121 -0
  39. package/dist/ai/cli/ready.js.map +1 -0
  40. package/dist/ai/cli/resolve.js +108 -0
  41. package/dist/ai/cli/resolve.js.map +1 -0
  42. package/dist/ai/cli/runCli.js +265 -0
  43. package/dist/ai/cli/runCli.js.map +1 -0
  44. package/dist/ai/parseAiResponse.js +24 -11
  45. package/dist/ai/parseAiResponse.js.map +1 -1
  46. package/dist/ai/verifyAiFindings.js +106 -0
  47. package/dist/ai/verifyAiFindings.js.map +1 -0
  48. package/dist/analysis/ScoreCalculator.js +22 -2
  49. package/dist/analysis/ScoreCalculator.js.map +1 -1
  50. package/dist/analysis/SeverityScorer.js +6 -0
  51. package/dist/analysis/SeverityScorer.js.map +1 -1
  52. package/dist/analysis/VulnerabilityDetector.js +39 -7
  53. package/dist/analysis/VulnerabilityDetector.js.map +1 -1
  54. package/dist/analysis/rls.js +32 -0
  55. package/dist/analysis/rls.js.map +1 -0
  56. package/dist/analysis/rules.js +89 -1
  57. package/dist/analysis/rules.js.map +1 -1
  58. package/dist/cli/Commands.js +83 -2
  59. package/dist/cli/Commands.js.map +1 -1
  60. package/dist/cli/InteractiveShell.js +132 -33
  61. package/dist/cli/InteractiveShell.js.map +1 -1
  62. package/dist/cli/Onboarding.js +13 -1
  63. package/dist/cli/Onboarding.js.map +1 -1
  64. package/dist/cli/cliSetup.js +48 -0
  65. package/dist/cli/cliSetup.js.map +1 -0
  66. package/dist/config/ConfigManager.js +11 -0
  67. package/dist/config/ConfigManager.js.map +1 -1
  68. package/dist/core/CiGate.js +80 -13
  69. package/dist/core/CiGate.js.map +1 -1
  70. package/dist/core/Orchestrator.js +211 -15
  71. package/dist/core/Orchestrator.js.map +1 -1
  72. package/dist/core/Verifier.js +7 -1
  73. package/dist/core/Verifier.js.map +1 -1
  74. package/dist/deploy/PlatformRecommender.js +110 -0
  75. package/dist/deploy/PlatformRecommender.js.map +1 -0
  76. package/dist/dynamic/DynamicTester.js +92 -8
  77. package/dist/dynamic/DynamicTester.js.map +1 -1
  78. package/dist/dynamic/EndpointMapper.js +54 -24
  79. package/dist/dynamic/EndpointMapper.js.map +1 -1
  80. package/dist/dynamic/LocalhostDetector.js +11 -23
  81. package/dist/dynamic/LocalhostDetector.js.map +1 -1
  82. package/dist/dynamic/SecurityTester.js +55 -10
  83. package/dist/dynamic/SecurityTester.js.map +1 -1
  84. package/dist/dynamic/adminEvidence.js +47 -0
  85. package/dist/dynamic/adminEvidence.js.map +1 -0
  86. package/dist/dynamic/advertised.js +293 -0
  87. package/dist/dynamic/advertised.js.map +1 -0
  88. package/dist/dynamic/catchAll.js +57 -0
  89. package/dist/dynamic/catchAll.js.map +1 -0
  90. package/dist/dynamic/commonPaths/evidence.js +112 -0
  91. package/dist/dynamic/commonPaths/evidence.js.map +1 -0
  92. package/dist/dynamic/commonPaths/prober.js +210 -0
  93. package/dist/dynamic/commonPaths/prober.js.map +1 -0
  94. package/dist/dynamic/commonPaths/signatures.js +381 -0
  95. package/dist/dynamic/commonPaths/signatures.js.map +1 -0
  96. package/dist/parser/CodeParser.js +138 -28
  97. package/dist/parser/CodeParser.js.map +1 -1
  98. package/dist/parser/adapters/BabelAdapter.js +558 -27
  99. package/dist/parser/adapters/BabelAdapter.js.map +1 -1
  100. package/dist/parser/adapters/PythonAdapter.js +360 -14
  101. package/dist/parser/adapters/PythonAdapter.js.map +1 -1
  102. package/dist/parser/adapters/authMiddleware.js +256 -0
  103. package/dist/parser/adapters/authMiddleware.js.map +1 -0
  104. package/dist/parser/adapters/nest.js +162 -0
  105. package/dist/parser/adapters/nest.js.map +1 -0
  106. package/dist/parser/miniYaml.js +308 -0
  107. package/dist/parser/miniYaml.js.map +1 -0
  108. package/dist/parser/nextRoutes.js +204 -0
  109. package/dist/parser/nextRoutes.js.map +1 -0
  110. package/dist/parser/openapi.js +180 -0
  111. package/dist/parser/openapi.js.map +1 -0
  112. package/dist/parser/pathUtil.js +22 -0
  113. package/dist/parser/pathUtil.js.map +1 -0
  114. package/dist/ui/DeploymentGuide.js +107 -29
  115. package/dist/ui/DeploymentGuide.js.map +1 -1
  116. package/dist/ui/ExportManager.js +61 -3
  117. package/dist/ui/ExportManager.js.map +1 -1
  118. package/dist/ui/HtmlReporter.js +113 -31
  119. package/dist/ui/HtmlReporter.js.map +1 -1
  120. package/dist/ui/IssuePresenter.js +54 -5
  121. package/dist/ui/IssuePresenter.js.map +1 -1
  122. package/dist/ui/commonPathSection.js +42 -0
  123. package/dist/ui/commonPathSection.js.map +1 -0
  124. package/dist/utils/FileWalker.js +126 -17
  125. package/dist/utils/FileWalker.js.map +1 -1
  126. package/dist/utils/GitIgnore.js +162 -0
  127. package/dist/utils/GitIgnore.js.map +1 -0
  128. package/dist/utils/finding.js +5 -0
  129. package/dist/utils/finding.js.map +1 -1
  130. package/dist/utils/logger.js +4 -0
  131. package/dist/utils/logger.js.map +1 -1
  132. package/dist/utils/sanitize.js +30 -0
  133. package/dist/utils/sanitize.js.map +1 -0
  134. package/docs/sample-config.json +2 -1
  135. package/package.json +12 -4
package/README.md CHANGED
@@ -1,11 +1,21 @@
1
1
  # DeployReady
2
2
 
3
- > Local-first, AI-optional production-readiness scanner. It runs 30+ structured tests against your code **and** your running localhost app, gives you a 0–100 readiness score, and **optionally** sends only the structured findings report — never your source code — to an AI model for deeper analysis.
3
+ > **AI wrote it fast. DeployReady checks if it's safe to ship.**
4
+
5
+ A pre-flight check for vibe-coded apps: run 30+ structured tests across your code **and** your running app, get a 0–100 readiness score, and apply **AI-powered fixes** — all in one command. Built for people shipping with Cursor, Copilot, Claude Code, v0, or bolt — not a lecture about them.
4
6
 
5
7
  ```bash
6
8
  npx deployready@latest analyze ./my-app
7
9
  ```
8
10
 
11
+ <p align="center">
12
+ <img src="docs/scan-demo.svg" alt="Terminal recording of DeployReady scanning a small AI-generated Express app and finding a SQL injection, a hardcoded AWS key, eval() code injection, and an unprotected .env file — readiness score 39/100" width="720">
13
+ </p>
14
+
15
+ <p align="center"><sub>Unedited output from a real scan of a small AI-generated app — see <a href="tests/sample-app"><code>tests/sample-app</code></a>.</sub></p>
16
+
17
+ > _Privacy:_ scanning runs locally. Only a redacted findings report is ever sent to an AI — after you approve it, never your source code — and you can use a local model (Ollama) to keep everything 100% offline.
18
+
9
19
  ## Install
10
20
 
11
21
  **Run without installing** (recommended — always works, nothing to set up):
@@ -62,11 +72,11 @@ deployready › exit
62
72
  |---|---|
63
73
  | `scan` · `parse` · `dynamic` · `ai` | run the whole pipeline, or one step at a time |
64
74
  | `issues [crit\|warn\|info]` · `show <n>` | list findings (optionally filtered) · show one in detail |
65
- | `fix <n>` | auto-fix where safe; otherwise an AI-proposed diff you approve (creates a backup); otherwise guidance |
75
+ | `fix <n>` | deterministic auto-fix where safe (weak hashes, disabled TLS verification, `yaml.load`, `verify=False`, Flask `debug=True`, gitignore `.env`); otherwise an AI-proposed diff you approve (creates a backup); otherwise guidance |
66
76
  | `verify <n>` | re-run the relevant checks to confirm a fix actually resolved the issue |
67
77
  | `done <n>` · `ignore <n>` | mark fixed / ignored — the score recomputes immediately |
68
78
  | `score` · `status` | show the current readiness score / session state |
69
- | `deploy [aws\|do]` | deployment walkthrough for your stack |
79
+ | `deploy [platform]` | recommend a host for this project (no arg) or print a step-by-step guide for a chosen one (`aws`, `do`, `vercel`, `render`, `railway`, `fly`, `netlify`) |
70
80
  | `export` · `open` | write `deployready-report.md` · open the HTML dashboard |
71
81
  | `config` · `help` · `menu` · `clear` · `exit` | session utilities |
72
82
 
@@ -92,6 +102,11 @@ npx deployready@latest config # show the active confi
92
102
  | `--html` / `--open` | write an HTML dashboard / and open it in your browser |
93
103
  | `--json` | print a machine-readable JSON report (implies `--yes`) |
94
104
  | `--fail-on <severity>` | exit non-zero if findings at/above `critical \| warning \| info \| none` exist |
105
+ | `--baseline <file>` | gate only on findings **not** in the baseline file (existing issues are grandfathered) |
106
+ | `--write-baseline <file>` | write the current findings to a baseline file and exit `0` (accept current state) |
107
+ | `--active` | run **active** authenticated authorization tests (needs `--token`; consented, loopback-only, GET-only) |
108
+ | `--token <jwt>` | bearer JWT for the active scan (your logged-in test user) |
109
+ | `--token-b <jwt>` | a second user's JWT — enables tenant / IDOR isolation tests |
95
110
  | `-v, --verbose` | verbose debug output |
96
111
 
97
112
  **CI gate:** exit codes are `0` (clean), `2` (gate failed), `1` (tool error).
@@ -100,15 +115,52 @@ npx deployready@latest config # show the active confi
100
115
  npx deployready@latest analyze . --no-ai --no-dynamic --fail-on critical
101
116
  ```
102
117
 
118
+ **Grandfather existing issues (baseline):** adopt the current findings once, then fail the
119
+ build only on *new* ones — so you can turn the gate on for an existing codebase without
120
+ drowning in pre-existing debt:
121
+
122
+ ```bash
123
+ npx deployready@latest analyze . --no-ai --no-dynamic --write-baseline .deployready-baseline.json # once
124
+ npx deployready@latest analyze . --no-ai --no-dynamic --baseline .deployready-baseline.json --fail-on warning # in CI
125
+ ```
126
+
103
127
  A ready-to-copy GitHub Action is in [`docs/github-action-example.yml`](docs/github-action-example.yml).
104
128
 
129
+ ### Active (authenticated) testing — "try to hack it"
130
+
131
+ With your app running locally, DeployReady can act as a logged-in user and try to break access control — the checks you'd otherwise do by hand in Burp/Postman:
132
+
133
+ ```bash
134
+ npx deployready@latest analyze . --active --token "<your-JWT>" --token-b "<second-user-JWT>"
135
+ ```
136
+
137
+ - **Broken object-level auth (IDOR/BOLA)** — swaps resource ids to reach another user's data.
138
+ - **Broken tenant isolation** — swaps `org_id`/tenant to reach another tenant's data.
139
+ - **Privilege escalation** — forges a `role: admin` claim and checks whether a forbidden route opens up.
140
+ - **JWT not verified** — checks whether the server accepts a forged `alg:none` token.
141
+
142
+ It is **opt-in and consented**, **loopback-only**, and **GET-only** (it never writes). Need a token? Run `--active` without one and DeployReady prints step-by-step instructions for grabbing your JWT from the browser.
143
+
144
+ ### Route discovery (on by default, nothing guessed)
145
+
146
+ **OpenAPI/Swagger from disk.** DeployReady reads `openapi.*` / `swagger.*` (JSON or block-style YAML) files in your project and treats their paths as routes, with the spec's `security` as the guard evidence. No request is needed to read them, and it works for stacks without a code parser.
147
+
148
+ **Advertised links.** From pages it already fetched from those routes, DeployReady also follows up to 25 same-origin GET links your running app advertises (`<a>`, `<link>`, `Link:` headers, and a `robots.txt`/`sitemap.xml`/OpenAPI document only if your project or a response points at it), one level deep, never logout/delete-style links. Details: [`docs/ROUTE-DISCOVERY.md`](docs/ROUTE-DISCOVERY.md).
149
+
150
+ ### Common-path probe (opt-in)
151
+
152
+ By default the live tests never guess paths. With `--probe-common-paths` (or `"probeCommonPaths": true` in your config, interactive runs only) DeployReady also requests a fixed list of 16 well-known paths such as `/.env` and `/.git/config` from your local app, at most 20 GET requests, after showing you the list and asking first. A path is reported only when its content proves it (a `200` alone is never enough), and findings are labelled as guessed, lower confidence, in their own report section. In `--yes`, `--json` and CI only the explicit flag enables it. Details: [`docs/COMMON-PATH-PROBE.md`](docs/COMMON-PATH-PROBE.md).
153
+
105
154
  ## What it checks
106
155
 
107
156
  - **Static analysis** — Babel-based AST parsing (pure JS, no native build) for JavaScript/TypeScript, plus Python. Dependency graph, route-mount resolution across files, and stack detection (Express, Next.js, Fastify, NestJS, Koa, FastAPI, Flask, Django, Laravel).
108
- - **Secrets & vulnerabilities** — hardcoded credentials, `eval`/command/SQL injection, XSS sinks, weak crypto, insecure randomness, disabled TLS verification, committed `.env`, log injection — each mapped to **OWASP Top 10 (2025)** and **CWE**.
109
- - **Live dynamic testing** — detects your running localhost app and checks for auth bypass, exposed admin routes, secrets in responses, wildcard CORS, missing security headers, missing rate limiting, slow endpoints, missing cache headers, and version/stack-trace leaks.
157
+ - **Secrets & vulnerabilities** — hardcoded credentials, `eval`/command/SQL injection, XSS sinks, weak crypto, insecure randomness, disabled TLS verification, JWT `none` algorithm, insecure cookies, unsafe deserialization, insecure temp files, committed `.env`, log injection — each mapped to **OWASP Top 10 (2025)** and **CWE**.
158
+ - **Access control & transport** — Row-Level Security disabled or never enabled on a table, Supabase `service_role` key used in app code (RLS bypass), and insecure cleartext `http://` endpoints.
159
+ - **Live dynamic testing** — finds a local server listening on a common port and, for the routes your code defines (never guessed paths), checks for auth bypass, exposed admin routes, secrets in responses, wildcard CORS, missing security headers, missing rate limiting, slow endpoints, missing cache headers, and version/stack-trace leaks.
160
+ - **Active authorization testing** (opt-in, `--active`) — acts as a logged-in user to find broken object-level auth (IDOR/BOLA), broken tenant isolation, privilege escalation (forged `role`), and unverified JWTs (`alg:none`).
110
161
  - **Readiness score (0–100)** with a critical / warning / info breakdown.
111
- - **Reports** — terminal output, markdown export, and an HTML dashboard.
162
+ - **Deployment recommendation** — suggests where to host based on your stack, size, and whether you're frontend / backend / full-stack, flags when to split frontend and backend across platforms, and marks suitable free tiers.
163
+ - **Reports** — terminal output, markdown export, and a branded HTML dashboard.
112
164
 
113
165
  ## How it works
114
166
 
@@ -125,9 +177,23 @@ DeployReady works fully offline with no AI. To enable deeper analysis, configure
125
177
 
126
178
  | Model | Notes |
127
179
  |---|---|
128
- | Claude (Anthropic) | Set `ANTHROPIC_API_KEY` or store via `init`. Default: `claude-sonnet-4-6`. |
129
- | OpenAI | Set `OPENAI_API_KEY` or store via `init`. |
180
+ | Claude API (Anthropic) | Set `ANTHROPIC_API_KEY` or store via `init`. Default: `claude-sonnet-4-6`. |
181
+ | OpenAI API | Set `OPENAI_API_KEY` or store via `init`. |
130
182
  | Ollama (local) | Fully offline, no key — nothing leaves your machine. |
183
+ | Claude (CLI login) | Uses your own installed `claude` CLI and **your own Claude plan** — no API key. See below. |
184
+ | Codex (CLI login) | Uses your own installed `codex` CLI and **your own ChatGPT/OpenAI plan** — no API key. See below. |
185
+
186
+ ### CLI-login providers (Claude / Codex)
187
+
188
+ Choose these in `init` (or in the interactive menu under "Set up or change the AI model") if you already use the `claude` or `codex` command-line tool and prefer that login to an API key.
189
+
190
+ - **Login status** is read from the CLI itself (`claude auth status`, `codex login status`). If the CLI is installed but not logged in, DeployReady offers to run the CLI's own login command (`claude auth login` / `codex login`) in your terminal. You sign in inside that tool: DeployReady never sees, reads, copies or stores your token or the CLI's auth files.
191
+ - **Your plan's rules apply, not the API terms.** Data is handled under the data policy of your own plan and counts against your plan's usage allowance. The consent prompt says so before anything is sent.
192
+ - **Same data as the API providers:** only the redacted structured findings report (or, for `fix`, one redacted snippet you confirm first). Never your source files.
193
+ - **Text in, text out.** The CLI is started with its tools disabled, from an empty temporary folder, with a minimal environment, and its answer is treated as untrusted text. It is never asked to edit your files. When you accept a fix, DeployReady applies it with its own editor: a backup (`<file>.bak.<timestamp>`) is written first, the path is confined to your project and the result is syntax-checked.
194
+ - AI findings stay marked unverified and never change your score or the CI gate.
195
+ - **Codex can be switched off.** To disable the Codex provider, set `"codexEnabled": false` in `~/.deployready/config.json`; it then refuses to run and sends nothing. The Claude provider has no such switch.
196
+ - These providers are meant for interactive, local use. Each call uses your own plan allowance.
131
197
 
132
198
  ## Security & privacy
133
199
 
@@ -135,7 +201,7 @@ DeployReady reads your code, probes your ports, and holds your keys — so it's
135
201
 
136
202
  - API keys are read from environment variables first and **never logged**; the on-disk config is written with `0600` permissions.
137
203
  - All terminal output and any AI payload pass through a central **secret redactor**.
138
- - Dynamic testing is **loopback-only** and **GET-only** by default; aggressive tests require explicit consent.
204
+ - Dynamic testing is **loopback-only** and **GET-only** by default; aggressive tests require explicit consent. It only requests routes your code (or your OpenAPI/Swagger file) defines, plus up to 25 same-origin paths your running app itself advertises in pages it already served (links, `Link:` headers, and a `robots.txt`/`sitemap.xml`/OpenAPI document only if your project or one of those responses points at it; one level deep, never logout/delete-style links) — it never guesses paths like `/admin` or `/.env`, and never invents ids for routes with path parameters (those are listed as "could not check"). Use `--verbose` to see every request decision.
139
205
  - File scanning is confined to the project root, with symlink/traversal protection and size caps.
140
206
 
141
207
  ## Configuration
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.bodiesEqual = bodiesEqual;
4
+ exports.classifyAuthzResult = classifyAuthzResult;
5
+ function canonicalize(text) {
6
+ const trimmed = text.trim();
7
+ try {
8
+ return JSON.stringify(sortKeys(JSON.parse(trimmed)));
9
+ }
10
+ catch {
11
+ return trimmed;
12
+ }
13
+ }
14
+ function sortKeys(v) {
15
+ if (Array.isArray(v))
16
+ return v.map(sortKeys);
17
+ if (typeof v === 'object' && v !== null) {
18
+ return Object.fromEntries(Object.entries(v)
19
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
20
+ .map(([k, val]) => [k, sortKeys(val)]));
21
+ }
22
+ return v;
23
+ }
24
+ /** Equality of two response bodies: JSON deep-equal ignoring key order, else trimmed text. */
25
+ function bodiesEqual(a, b) {
26
+ return canonicalize(a) === canonicalize(b);
27
+ }
28
+ /** Empty / `{}` / `[]` / `null` carry no data, so matching them proves nothing. */
29
+ function isTrivialBody(text) {
30
+ return ['', '{}', '[]', 'null', '""'].includes(canonicalize(text));
31
+ }
32
+ function is2xx(status) {
33
+ return status >= 200 && status < 300;
34
+ }
35
+ function classifyAuthzResult(input) {
36
+ const { status, bodyText, ownBaselineBody, ownerBaseline, foreignValue } = input;
37
+ if (status === 401 || status === 403) {
38
+ return { verdict: 'denied', reason: `Access correctly denied (HTTP ${status}).` };
39
+ }
40
+ if (status === 404) {
41
+ return { verdict: 'denied', reason: 'Resource not exposed to this identity (HTTP 404).' };
42
+ }
43
+ if (!is2xx(status)) {
44
+ return { verdict: 'inconclusive', reason: `HTTP ${status} — inconclusive; the endpoint may have errored.` };
45
+ }
46
+ if (bodiesEqual(bodyText, ownBaselineBody)) {
47
+ return {
48
+ verdict: 'inconclusive',
49
+ reason: `HTTP ${status} returned the test user's own data — the swapped value was ignored.`,
50
+ };
51
+ }
52
+ if (ownerBaseline && is2xx(ownerBaseline.status)) {
53
+ if (!isTrivialBody(bodyText) && bodiesEqual(bodyText, ownerBaseline.bodyText)) {
54
+ return {
55
+ verdict: 'broken',
56
+ proof: 'owner-baseline',
57
+ reason: `Tampered request returned HTTP ${status} with exactly what the owning identity receives — access control failed.`,
58
+ };
59
+ }
60
+ return {
61
+ verdict: 'inconclusive',
62
+ reason: `HTTP ${status} returned, but it differs from what the owning identity receives — verify manually.`,
63
+ };
64
+ }
65
+ if (bodyText.includes(String(foreignValue))) {
66
+ return {
67
+ verdict: 'broken',
68
+ proof: 'echo',
69
+ reason: `Tampered request returned HTTP ${status} containing the other identity's value — access control failed (no owner baseline to confirm).`,
70
+ };
71
+ }
72
+ return {
73
+ verdict: 'inconclusive',
74
+ reason: `HTTP ${status} returned, but no clear foreign data in the response — verify manually.`,
75
+ };
76
+ }
77
+ //# sourceMappingURL=accessControl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accessControl.js","sourceRoot":"","sources":["../../src/active/accessControl.ts"],"names":[],"mappings":";;AAqDA,kCAEC;AAWD,kDA6CC;AAhFD,SAAS,YAAY,CAAC,IAAY;IAChC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,CAAC;IACjB,CAAC;AACH,CAAC;AAED,SAAS,QAAQ,CAAC,CAAU;IAC1B,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC7C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,CAA4B,CAAC;aACzC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aAChD,GAAG,CAAC,C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EAAE,CAAC;QAC3C,OAAO;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,QAAQ,MAAM,qEAAqE;SAC5F,CAAC;IACJ,CAAC;IAED,IAAI,aAAa,IAAI,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,QAAQ,EAAE,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9E,OAAO;gBACL,OAAO,EAAE,QAAQ;gBACjB,KAAK,EAAE,gBAAgB;gBACvB,MAAM,EAAE,kCAAkC,MAAM,0EAA0E;aAC3H,CAAC;QACJ,CAAC;QACD,OAAO;YACL,OAAO,EAAE,cAAc;YACvB,MAAM,EAAE,QAAQ,MAAM,qFAAqF;SAC5G,CAAC;IACJ,CAAC;IAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QAC5C,OAAO;YACL,OAAO,EAAE,QAAQ;YACjB,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,kCAAkC,MAAM,gGAAgG;SACjJ,CAAC;IACJ,CAAC;IACD,OAAO;QACL,OAAO,EAAE,cAAc;QACvB,MAAM,EAAE,QAAQ,MAAM,yEAAyE;KAChG,CAAC;AACJ,CAAC"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.buildUrl = buildUrl;
7
+ exports.createActiveHttpAdapter = createActiveHttpAdapter;
8
+ /**
9
+ * The real network transport for the active scan (Phase 5a) — the ONE place that
10
+ * actually sends requests, so it carries the safety rails:
11
+ * - loopback-only target (SSRF/scope guard, same bar as the dynamic suite),
12
+ * re-checked on every derived URL so a request can never leave the host;
13
+ * - dry-run that sends nothing;
14
+ * - hard timeout, no redirects, response-size cap.
15
+ *
16
+ * It returns the minimal `ActiveResponse` the runner needs. Consent + the request
17
+ * budget live above this (Orchestrator + runner).
18
+ */
19
+ const axios_1 = __importDefault(require("axios"));
20
+ const httpClient_1 = require("../dynamic/httpClient");
21
+ const TIMEOUT_MS = 8000;
22
+ const MAX_BODY = 5 * 1024 * 1024;
23
+ /** Build an absolute URL from base + path (+ query). Pure. */
24
+ function buildUrl(baseUrl, path, query) {
25
+ const url = new URL(path, baseUrl);
26
+ if (query) {
27
+ for (const [k, v] of Object.entries(query))
28
+ url.searchParams.set(k, String(v));
29
+ }
30
+ return url.toString();
31
+ }
32
+ function createActiveHttpAdapter(opts) {
33
+ (0, httpClient_1.assertLoopback)(opts.baseUrl); // scope is fixed to this loopback host
34
+ const timeout = opts.timeoutMs ?? TIMEOUT_MS;
35
+ return async (req) => {
36
+ const url = buildUrl(opts.baseUrl, req.path, req.query);
37
+ (0, httpClient_1.assertLoopback)(url); // defense in depth: never leave the loopback host
38
+ if (opts.dryRun)
39
+ return { status: 0, bodyText: '' };
40
+ const res = await axios_1.default.request({
41
+ url,
42
+ method: req.method,
43
+ headers: { 'User-Agent': 'DeployReady-Scanner/0.1', ...req.headers },
44
+ data: req.body,
45
+ timeout,
46
+ maxRedirects: 0,
47
+ validateStatus: () => true,
48
+ maxContentLength: MAX_BODY,
49
+ });
50
+ const bodyText = typeof res.data === 'string' ? res.data : JSON.stringify(res.data ?? '');
51
+ return { status: res.status, bodyText };
52
+ };
53
+ }
54
+ //# sourceMappingURL=httpAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpAdapter.js","sourceRoot":"","sources":["../../src/active/httpAdapter.ts"],"names":[],"mappings":";;;;;AAmBA,4BAMC;AASD,0DAuBC;AAzDD;;;;;;;;;;GAUG;AACH,kDAA0B;AAC1B,sDAAuD;AAGvD,MAAM,UAAU,GAAG,IAAI,CAAC;AACxB,MAAM,QAAQ,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AA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AC3B,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QAC1F,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decodeJwt = decodeJwt;
4
+ exports.forgeNoneAlg = forgeNoneAlg;
5
+ exports.tamperClaimsKeepSig = tamperClaimsKeepSig;
6
+ function decodeSegment(seg) {
7
+ return JSON.parse(Buffer.from(seg, 'base64url').toString('utf8'));
8
+ }
9
+ function encodeSegment(obj) {
10
+ return Buffer.from(JSON.stringify(obj), 'utf8').toString('base64url');
11
+ }
12
+ function isPlainObject(v) {
13
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
14
+ }
15
+ /** Decode a JWT's header + payload. Returns null if it isn't a valid JWT shape. */
16
+ function decodeJwt(token) {
17
+ const parts = token.split('.');
18
+ if (parts.length !== 3)
19
+ return null;
20
+ try {
21
+ const header = decodeSegment(parts[0]);
22
+ const payload = decodeSegment(parts[1]);
23
+ if (!isPlainObject(header) || !isPlainObject(payload))
24
+ return null;
25
+ return { header, payload, signature: parts[2] };
26
+ }
27
+ catch {
28
+ return null;
29
+ }
30
+ }
31
+ /** Forge an `alg:"none"` token (empty signature), optionally patching claims. */
32
+ function forgeNoneAlg(token, claimPatch = {}) {
33
+ const d = decodeJwt(token);
34
+ if (!d)
35
+ return null;
36
+ const header = { ...d.header, alg: 'none' };
37
+ const payload = { ...d.payload, ...claimPatch };
38
+ return `${encodeSegment(header)}.${encodeSegment(payload)}.`;
39
+ }
40
+ /** Mutate claims but keep the original header + signature unchanged. */
41
+ function tamperClaimsKeepSig(token, patch) {
42
+ const d = decodeJwt(token);
43
+ if (!d)
44
+ return null;
45
+ const payload = { ...d.payload, ...patch };
46
+ return `${encodeSegment(d.header)}.${encodeSegment(payload)}.${d.signature}`;
47
+ }
48
+ //# sourceMappingURL=jwt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwt.js","sourceRoot":"","sources":["../../src/active/jwt.ts"],"names":[],"mappings":";;AAiCA,8BAWC;AAGD,oCAMC;AAGD,kDAKC;AAzCD,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACxE,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAC/B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,mFAAmF;AACnF,SAAgB,SAAS,CAAC,KAAa;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;QACxC,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;QACzC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC;YAAE,OAAO,IAAI,CAAC;QACnE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAE,EAAE,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,iFAAiF;AACjF,SAAgB,YAAY,CAAC,KAAa,EAAE,aAAsC,EAAE;IAClF,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,MAAM,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAC5C,MAAM,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,UAAU,EAAE,CAAC;IAChD,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC;AAC/D,CAAC;AAED,wEAAwE;AACxE,SAAgB,mBAAmB,CAAC,KAAa,EAAE,KAA8B;IAC/E,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;IAC3B,IAAI,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IACpB,MAAM,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC;IAC3C,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.planActiveRequests = planActiveRequests;
4
+ exports.buildActiveRequests = buildActiveRequests;
5
+ const PARAM_RE = /^(?::(.+)|\{(.+)\})$/; // :name or {name}
6
+ const TENANT_PARAM_RE = /^(?:org|organization|tenant|team|company|workspace)/i;
7
+ const ID_PARAM_RE = /(?:^id$|_?id$|^uid$|^user$)/i;
8
+ const PATTERN_SEGMENT = /[:{}<>*()?+[\]\\]/;
9
+ function firstClaim(claims, names) {
10
+ for (const name of names) {
11
+ const value = claims[name];
12
+ if (typeof value === 'string' || typeof value === 'number')
13
+ return { name, value };
14
+ }
15
+ return null;
16
+ }
17
+ const userClaim = (claims) => firstClaim(claims, ['sub', 'user_id', 'uid', 'id']);
18
+ const tenantClaim = (claims) => firstClaim(claims, ['org_id', 'organization_id', 'tenant_id', 'tenant', 'workspace_id']);
19
+ /** Resolve a single path, or say why a param/pattern can't be filled. */
20
+ function resolvePath(path, claims) {
21
+ const out = [];
22
+ const pathParams = [];
23
+ const filled = [];
24
+ for (const [index, seg] of path.split('/').entries()) {
25
+ const m = PARAM_RE.exec(seg);
26
+ if (!m) {
27
+ if (PATTERN_SEGMENT.test(seg)) {
28
+ return { ok: false, reason: `segment "${seg}" is a pattern or partial parameter, not a concrete value (values are never invented)` };
29
+ }
30
+ out.push(seg);
31
+ continue;
32
+ }
33
+ const name = m[1] ?? m[2] ?? '';
34
+ const claim = TENANT_PARAM_RE.test(name) ? tenantClaim(claims) : ID_PARAM_RE.test(name) ? userClaim(claims) : null;
35
+ if (claim === null) {
36
+ return { ok: false, reason: `no claim in your token can fill path parameter "${name}" (values are never invented)` };
37
+ }
38
+ out.push(String(claim.value));
39
+ pathParams.push({ index, name });
40
+ filled.push(`"${name}" from claim "${claim.name}"`);
41
+ }
42
+ return { ok: true, path: out.join('/'), pathParams, filled };
43
+ }
44
+ function planActiveRequests(routes, claims) {
45
+ const seen = new Set();
46
+ const requests = [];
47
+ const skipped = [];
48
+ const log = [];
49
+ for (const route of routes) {
50
+ const method = route.method.toUpperCase();
51
+ const skip = (reason) => {
52
+ skipped.push({ method, path: route.path, reason });
53
+ log.push(`[active] skip ${method} ${route.path}: ${reason}`);
54
+ };
55
+ if (method !== 'GET') {
56
+ skip('non-GET route: the scanner never mutates data');
57
+ continue;
58
+ }
59
+ const resolved = resolvePath(route.path, claims);
60
+ if (!resolved.ok) {
61
+ skip(resolved.reason);
62
+ continue;
63
+ }
64
+ if (seen.has(resolved.path))
65
+ continue;
66
+ seen.add(resolved.path);
67
+ const filled = resolved.filled.length ? `; filled ${resolved.filled.join(', ')}` : '';
68
+ log.push(`[active] request GET ${resolved.path}: discovered at ${route.file}${route.line ? `:${route.line}` : ''}${filled}`);
69
+ requests.push(resolved.pathParams.length
70
+ ? { method: 'GET', path: resolved.path, pathParams: resolved.pathParams }
71
+ : { method: 'GET', path: resolved.path });
72
+ }
73
+ return { requests, skipped, log };
74
+ }
75
+ function buildActiveRequests(routes, claims) {
76
+ return planActiveRequests(routes, claims).requests;
77
+ }
78
+ //# sourceMappingURL=requestPlan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requestPlan.js","sourceRoot":"","sources":["../../src/active/requestPlan.ts"],"names":[],"mappings":";;AA0EA,gDA+BC;AAED,kDAEC;AA9FD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,CAAC,kBAAkB;AAC3D,MAAM,eAAe,GAAG,sDAAsD,CAAC;AAC/E,MAAM,WAAW,GAAG,8BAA8B,CAAC;AACnD,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAO5C,SAAS,UAAU,CAAC,MAA+B,EAAE,KAAe;IAClE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IACrF,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,SAAS,GAAG,CAAC,MAA+B,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AAC3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;YACjB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtB,SAAS;QACX,CAAC;QACD,IAAI,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QACtC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACxB,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACtF,GAAG,CAAC,IAAI,CAAC,wBAAwB,QAAQ,CAAC,IAAI,mBAAmB,KAAK,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;QAC7H,QAAQ,CAAC,IAAI,CACX,QAAQ,CAAC,UAAU,CAAC,MAAM;YACxB,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,UAAU,EAAE;YACzE,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAC3C,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;AACpC,CAAC;AAED,SAAgB,mBAAmB,CAAC,MAAe,EAAE,MAA+B;IAClF,OAAO,kBAAkB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC;AACrD,CAAC"}
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.runActiveScan = runActiveScan;
4
+ /**
5
+ * Consented active-scan runner (Phase 5a/5b).
6
+ *
7
+ * Replays real, authenticated requests with a tampered identity to prove broken
8
+ * access control. The HTTP transport is INJECTED (`HttpFn`) so the engine is
9
+ * pure-logic and fully unit-testable, and so the one place that actually touches
10
+ * the network (the real adapter) carries all the safety rails: explicit consent,
11
+ * single-host scope, request budget, and traffic redaction.
12
+ *
13
+ * Checks implemented here:
14
+ * - jwt-not-verified — server accepts a forged alg:none token (CWE-347)
15
+ * - bola-idor — A can read another user's object (CWE-639)
16
+ * - tenant-isolation-broken — A can read another tenant's data (CWE-639)
17
+ *
18
+ * It never sends a tampered request to an endpoint the test user can't already
19
+ * reach (non-2xx baseline), and it honours `maxRequests`.
20
+ */
21
+ const finding_1 = require("../utils/finding");
22
+ const jwt_1 = require("./jwt");
23
+ const tamper_1 = require("./tamper");
24
+ const accessControl_1 = require("./accessControl");
25
+ const BUDGET_DEFAULT = 200;
26
+ /** Claims we try to set to impersonate an admin during escalation tests. */
27
+ const ADMIN_CLAIMS = { role: 'admin', is_admin: true, isAdmin: true, admin: true };
28
+ function bearer(token) {
29
+ return { Authorization: `Bearer ${token}` };
30
+ }
31
+ function is2xx(status) {
32
+ return status >= 200 && status < 300;
33
+ }
34
+ /** Pull the value of `point`'s category from another identity's JWT claims. */
35
+ function foreignValueFor(category, claims) {
36
+ const candidates = category === 'tenant-id'
37
+ ? [claims.org_id, claims.organization_id, claims.tenant_id, claims.tenant, claims.workspace_id]
38
+ : [claims.sub, claims.user_id, claims.uid, claims.id];
39
+ for (const v of candidates) {
40
+ if (typeof v === 'string' || typeof v === 'number')
41
+ return v;
42
+ }
43
+ return null;
44
+ }
45
+ /**
46
+ * A 403 endpoint: see whether forging an admin role (with the signature kept, or
47
+ * via alg:none) flips it to a 2xx — which proves the server trusts the client's
48
+ * role claim instead of verifying it.
49
+ */
50
+ async function tryEscalate(req, token, send, hasBudget) {
51
+ const variants = [(0, jwt_1.tamperClaimsKeepSig)(token, ADMIN_CLAIMS), (0, jwt_1.forgeNoneAlg)(token, ADMIN_CLAIMS)];
52
+ for (const variant of variants) {
53
+ if (!variant || !hasBudget())
54
+ continue;
55
+ const r = await send(req, variant);
56
+ if (is2xx(r.status)) {
57
+ return (0, finding_1.makeFinding)({
58
+ rule: 'privilege-escalation',
59
+ title: 'Privilege escalation via forged role claim',
60
+ severity: 'critical',
61
+ category: 'security',
62
+ source: 'dynamic',
63
+ endpoint: req.path,
64
+ owasp: 'A01:2025',
65
+ cwe: 'CWE-269',
66
+ description: `${req.path} returned 403 for the test user but 200 once the token's role was changed to "admin" — the server trusts the client-supplied role instead of verifying it.`,
67
+ recommendation: 'Derive authorization from a server-verified token (validate the signature) and never trust role/claims that the client can modify.',
68
+ });
69
+ }
70
+ }
71
+ return null;
72
+ }
73
+ async function runActiveScan(config, http) {
74
+ const findings = [];
75
+ const budget = config.maxRequests ?? BUDGET_DEFAULT;
76
+ let used = 0;
77
+ const send = (req, token) => {
78
+ used++;
79
+ return http({ method: req.method, path: req.path, query: req.query, body: req.body, headers: bearer(token) });
80
+ };
81
+ const sendAnonymous = (req) => {
82
+ used++;
83
+ return http({ method: req.method, path: req.path, query: req.query, body: req.body, headers: {} });
84
+ };
85
+ const bClaims = config.tokenB ? (0, jwt_1.decodeJwt)(config.tokenB)?.payload ?? null : null;
86
+ let jwtReported = false;
87
+ const ownerCache = new Map();
88
+ for (const req of config.requests) {
89
+ if (used >= budget)
90
+ break;
91
+ // Baseline as the real test user.
92
+ const baseline = await send(req, config.token);
93
+ // Forbidden for this user? Try to escalate via a forged admin role claim.
94
+ if (baseline.status === 403 && used < budget) {
95
+ const escalated = await tryEscalate(req, config.token, send, () => used < budget);
96
+ if (escalated)
97
+ findings.push(escalated);
98
+ continue;
99
+ }
100
+ // Only the remaining checks need an endpoint A can actually reach.
101
+ if (!is2xx(baseline.status))
102
+ continue;
103
+ // --- JWT verification: does the server accept a forged alg:none token? ---
104
+ // Only meaningful on an endpoint that actually requires auth, so first send
105
+ // the same request with no credentials: a public route (2xx) proves nothing.
106
+ if (!jwtReported && used < budget) {
107
+ const forged = (0, jwt_1.forgeNoneAlg)(config.token);
108
+ if (forged) {
109
+ const control = await sendAnonymous(req);
110
+ if ((control.status === 401 || control.status === 403) && used < budget) {
111
+ const r = await send(req, forged);
112
+ if (is2xx(r.status)) {
113
+ findings.push((0, finding_1.makeFinding)({
114
+ rule: 'jwt-not-verified',
115
+ title: 'JWT signature not verified (alg:none accepted)',
116
+ severity: 'critical',
117
+ category: 'security',
118
+ source: 'dynamic',
119
+ endpoint: req.path,
120
+ owasp: 'A02:2025',
121
+ cwe: 'CWE-347',
122
+ description: `${req.path} rejected the request without a token but accepted a forged "alg:none" token — the server does not verify JWT signatures, so anyone can mint a valid-looking token.`,
123
+ recommendation: 'Verify the JWT signature server-side and reject the "none" algorithm; pin the allowed algorithms (e.g. RS256/HS256).',
124
+ }));
125
+ jwtReported = true;
126
+ }
127
+ }
128
+ }
129
+ }
130
+ // --- Cross-access (IDOR / tenant): request B's resource while authed as A ---
131
+ if (bClaims) {
132
+ for (const point of (0, tamper_1.findInjectionPoints)(req)) {
133
+ if (used >= budget)
134
+ break;
135
+ const foreign = foreignValueFor(point.category, bClaims);
136
+ if (foreign === null || String(foreign) === String(point.value))
137
+ continue;
138
+ const tampered = (0, tamper_1.applyInjection)(req, point, foreign);
139
+ const r = await send(tampered, config.token);
140
+ // Judge against the owner's baseline: the same resource fetched as B.
141
+ // Only fetched when the verdict could still depend on it.
142
+ let ownerBaseline = null;
143
+ if (is2xx(r.status) && !(0, accessControl_1.bodiesEqual)(r.bodyText, baseline.bodyText) && config.tokenB) {
144
+ const key = JSON.stringify([tampered.method, tampered.path, tampered.query, tampered.body]);
145
+ ownerBaseline = ownerCache.get(key) ?? null;
146
+ if (!ownerBaseline && used < budget) {
147
+ ownerBaseline = await send(tampered, config.tokenB);
148
+ ownerCache.set(key, ownerBaseline);
149
+ }
150
+ }
151
+ const { verdict, proof } = (0, accessControl_1.classifyAuthzResult)({
152
+ status: r.status,
153
+ bodyText: r.bodyText,
154
+ ownBaselineBody: baseline.bodyText,
155
+ ownerBaseline,
156
+ foreignValue: foreign,
157
+ });
158
+ if (verdict !== 'broken')
159
+ continue;
160
+ const isTenant = point.category === 'tenant-id';
161
+ findings.push((0, finding_1.makeFinding)({
162
+ rule: isTenant ? 'tenant-isolation-broken' : 'bola-idor',
163
+ title: isTenant
164
+ ? 'Cross-tenant data access (broken tenant isolation)'
165
+ : 'Broken object-level authorization (IDOR / BOLA)',
166
+ severity: 'critical',
167
+ category: 'security',
168
+ source: 'dynamic',
169
+ endpoint: req.path,
170
+ owasp: 'A01:2025',
171
+ cwe: 'CWE-639',
172
+ description: `Setting ${point.label}=${foreign} (another identity's value) and calling ${req.path} as the test user returned HTTP ${r.status} ${proof === 'owner-baseline'
173
+ ? 'with exactly what that identity itself receives for the same resource'
174
+ : "containing that identity's value (no owner baseline was available to confirm)"}.`,
175
+ recommendation: isTenant
176
+ ? 'Scope every query by the authenticated tenant derived from the session — never trust a tenant id supplied in the request.'
177
+ : 'Enforce per-object ownership checks server-side; never authorize access based on an id supplied by the client.',
178
+ }));
179
+ }
180
+ }
181
+ }
182
+ return findings;
183
+ }
184
+ //# sourceMappingURL=runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/active/runner.ts"],"names":[],"mappings":";;AA2GA,sCA4HC;AAvOD;;;;;;;;;;;;;;;;GAgBG;AACH,8CAA+C;AAC/C,+BAAqE;AACrE,qCAA+D;AAC/D,mDAAmE;AA6BnE,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,4EAA4E;AAC5E,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAEnF,SAAS,MAAM,CAAC,KAAa;IAC3B,OAAO,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,KAAK,CAAC,MAAc;IAC3B,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