@js-recon/js-recon 2.1.0-alpha.1 → 2.1.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +1 -0
- package/CHANGELOG.md +21 -0
- package/README.md +1 -0
- package/build/analyze/engine/taintwireEngine.js +111 -0
- package/build/analyze/engine/taintwireEngine.js.map +1 -0
- package/build/analyze/helpers/schemas.js +32 -3
- package/build/analyze/helpers/schemas.js.map +1 -1
- package/build/analyze/helpers/validate.js +9 -5
- package/build/analyze/helpers/validate.js.map +1 -1
- package/build/analyze/index.js +33 -29
- package/build/analyze/index.js.map +1 -1
- package/build/cliProgram.js +34 -2
- package/build/cliProgram.js.map +1 -1
- package/build/globalConfig.js +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/lazyLoad/methodFilter.js +1 -0
- package/build/lazyLoad/methodFilter.js.map +1 -1
- package/build/lazyLoad/next_js/NextJsCrawler.js +26 -15
- package/build/lazyLoad/next_js/NextJsCrawler.js.map +1 -1
- package/build/lazyLoad/next_js/next_interceptRouteNextUrl.js +339 -0
- package/build/lazyLoad/next_js/next_interceptRouteNextUrl.js.map +1 -0
- package/build/lazyLoad/next_js/next_routerStateForge.js +1 -1
- package/build/lazyLoad/next_js/next_routerStateForge.js.map +1 -1
- package/build/map/taintwire/apiCalls.js +17 -12
- package/build/map/taintwire/apiCalls.js.map +1 -1
- package/build/map/taintwire/next_js/index.js.map +1 -1
- package/build/map/taintwire/valueResolver.js +25 -14
- package/build/map/taintwire/valueResolver.js.map +1 -1
- package/build/mcp/mcpServer.js +1 -1
- package/build/mcp/mcpServer.js.map +1 -1
- package/build/taintwire/index.js +145 -0
- package/build/taintwire/index.js.map +1 -0
- package/build/utility/globals.js +8 -0
- package/build/utility/globals.js.map +1 -1
- package/build/utility/listFiles.js +22 -0
- package/build/utility/listFiles.js.map +1 -0
- package/build/utility/ruleVersionMap.js +1 -0
- package/build/utility/ruleVersionMap.js.map +1 -1
- package/npm-shrinkwrap.json +77 -70
- package/package.json +10 -6
package/AGENTS.md
CHANGED
|
@@ -71,6 +71,7 @@ npm run start -- <subcommand> [options]
|
|
|
71
71
|
| `mcp` | AI-powered CLI / one-shot chat (`-c`) / Model Context Protocol server (`--server`) |
|
|
72
72
|
| `cs-mast` | Compute CS-MAST structural hashes for downloaded JS files; find hash collisions |
|
|
73
73
|
| `sourcemaps` | Extract source files from `.map` sourcemap file(s) |
|
|
74
|
+
| `taintwire` | `build` a PookieGraph (`.pg`) from JS files; `analyze`/`validate` `.pgq` query files |
|
|
74
75
|
|
|
75
76
|
## Key source files
|
|
76
77
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 2.1.0-alpha.2 - 2026-11-06
|
|
4
|
+
|
|
5
|
+
### Security
|
|
6
|
+
|
|
7
|
+
- `npm audit` is clean again; it had reported 51 vulnerabilities (32 high). `zod` moves to 4.6.7: no 3.x release fixes the memory-exhaustion advisory, and `jimp`, which `cli-print-img` uses, is overridden to the same version. `undici` moves to 7.30.2. Transitive `@hono/node-server`, `body-parser`, `fast-uri`, `glob`, `ip-address`, `minimatch` and `qs` are updated, and `deepmerge` is pinned to 4.1.2, which predates the prototype-poisoning advisory. (all)
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- New `taintwire` command builds a PookieGraph (a `.pg` file) once and queries it with `.pgq` files. `taintwire build -d <dir> -o graph.pg` loads every JS file of a directory (for example lazyload's `output/<host>`) into one [taintwire](https://taintwire.js-recon.io) graph. The files are linked through the webpack or Turbopack module registry, so a value can flow from one chunk into another. `taintwire analyze -g graph.pg -q <file/dir>` runs the rules in `.pgq` query files against it and writes the findings to `taintwire.json` (the `analyze.json` shape). `taintwire validate -q <file/dir>` checks query files without a graph. A `.pgq` file is a TypeScript module of Cypher selectors and rules, evaluated in a separate, locked-down Node.js process that can read only its query pack (Node.js 22.15 or newer); the [taintwire-queries](https://github.com/js-recon/taintwire-queries) repository is the public pack. Each finding's `message` is the rule's own message. A rule that fails while running is reported and the other rules still run; the command then exits with `41`. New exit codes `37` to `41`. (`taintwire`)
|
|
12
|
+
- New rule type `taintwire` and the `--analyze-taintwire` flag on `analyze` and `run`. A taintwire rule's steps are Cypher queries over a [taintwire](https://taintwire.js-recon.io) graph of each `mapped.json` chunk: a step's row ids are passed to later steps as `$<step name>`, and a step with `taintFrom` keeps only the rows that a value from that step flows into (strict, lenient or deep, with an optional `maxHops`), following variables, function arguments and return values. An optional rule-level `prefilter` regex skips chunks before they are loaded. The rules run through taintwire's pgq runner (`runPgq`). They are opt-in because loading the graphs is slow: without the flag, `analyze` prints `Skipped N taintwire rule(s)`. A `taintFrom` must name an earlier step and `maxHops` can be `0`; a step whose `requires` names no earlier step gives no findings. Chunks over 8 MB are skipped with a warning, like `map --map-taintwire` files. When a taintwire rule fails, the other rules' findings are still written and the command exits with `41` (`run` still writes the report). js-recon-rules 2.0.0 ships 31 of them. (`analyze`, `run`)
|
|
13
|
+
- New Next.js lazyload method `next_interceptRouteNextUrl` covers intercepting routes defined under a path that middleware guards, such as `app/admin/@modal/(..)pub/[id]`. Next.js serves such a route through its public source route when the request sends a `Next-Url` header naming the guarded path, and the middleware matcher only sees the public URL. The method reads the intercepting-route rules from `_buildManifest.js` (`__rewrites.beforeFiles`, the `next-url` condition). When the crawl hasn't found that file, it builds the URL from the buildId in the landing page. Each rule's parent path and every crawled, `strings`-extracted or `--wordlist` path gets a plain request. A path that redirects then gets the same path and its `/_next/data/<buildId>/<path>.json` route with `x-nextjs-data: 1`. The path counts as middleware-guarded if a response carries a header only middleware sets (any `x-middleware-*`, `x-nextjs-redirect` or `x-nextjs-rewrite`). For each rule whose condition matches a guarded path, the public route is requested with `Next-Url: <parent>`, and chunk paths that are missing from the plain response are downloaded. Without a manifest, the method tries every pair of guarded path and public page, up to 200 pairs. Manifest strings that Next.js hoisted into the manifest function's parameters are resolved, only `header` conditions count, and a manifest that doesn't parse falls back to the pairs mode. Each matching guarded path is also tried as `Next-Url`, next to the rule's parent path. Data routes keep the `basePath`, new chunks resolve against the asset prefix or `basePath` of the known chunk URLs, and the crawl target is always a candidate. The rule's `next-url` regex comes from the target, so each match runs with a 100 ms time limit. It runs after `next_routerStateForge` on every Next.js lazyload pass, and `--include-methods`/`--exclude-methods` control it. (`lazyload`, `run`)
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- taintwire is updated to 0.2.0-alpha.2. (`analyze`, `map`, `run`, `taintwire`)
|
|
18
|
+
- `--wordlist` entries now also feed `next_interceptRouteNextUrl`, as well as `next_routerStateForge`. (`lazyload`, `run`)
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- `mcp --server` no longer prints the banner. The banner is an image written to stdout, which is the server's JSON-RPC channel, so MCP clients got a corrupted stream. (`mcp`)
|
|
23
|
+
|
|
3
24
|
## 2.1.0-alpha.1 - 2026-10-21
|
|
4
25
|
|
|
5
26
|
### Added
|
package/README.md
CHANGED
|
@@ -149,6 +149,7 @@ Oxylabs traffic goes through the datacenter entry endpoint `dc.oxylabs.io:8000`
|
|
|
149
149
|
| `load` | Populates the response cache from a Caido or Burp Suite export. | [Read Docs](https://js-recon.io/docs/docs/modules/load) |
|
|
150
150
|
| `cs-mast` | Computes CS-MAST structural hashes for JS files and finds hash collisions. | [Read Docs](https://js-recon.io/docs/docs/modules/cs-mast) |
|
|
151
151
|
| `sourcemaps` | Extracts original source files from `.map` sourcemap files. | [Read Docs](https://js-recon.io/docs/docs/modules/sourcemaps) |
|
|
152
|
+
| `taintwire` | Builds a PookieGraph (`.pg`) from JS files and queries it with `.pgq` rules. | [Read Docs](https://js-recon.io/docs/docs/modules/taintwire) |
|
|
152
153
|
| `completion` | Generates shell completion scripts for bash, zsh, or fish. | [Read Docs](https://js-recon.io/docs/docs/modules/completion) |
|
|
153
154
|
|
|
154
155
|
## Key Features
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { forEachGraph } from "../../map/taintwire/apiCalls.js";
|
|
11
|
+
import { printMsg, MSG } from "../../utility/printMsg.js";
|
|
12
|
+
// Characters of the sink expression kept in findingLocation.
|
|
13
|
+
const MAX_CODE = 300;
|
|
14
|
+
const SEVERITY_MSG = { info: MSG.Header, low: MSG.Warn, medium: MSG.Info, high: MSG.Err, critical: MSG.Err };
|
|
15
|
+
/**
|
|
16
|
+
* Print a runPgq finding and turn it into an EngineOutput: the rule's own message (its diagnostic), and the location
|
|
17
|
+
* plus up to 300 characters of the sink's code. The console line names the rule and the chunk.
|
|
18
|
+
*/
|
|
19
|
+
export const toEngineOutput = (graph, f, meta) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const at = (x) => `${x.file}:${x.line}:${x.col}`;
|
|
21
|
+
const message = `[+] "${meta.ruleName}" found in chunk ${f.file}`;
|
|
22
|
+
const code = (yield graph.code(f.id)).slice(0, MAX_CODE);
|
|
23
|
+
const via = f.source ? ` <- ${at(f.source)} (${f.hops} hops)` : "";
|
|
24
|
+
printMsg(SEVERITY_MSG[f.severity], message);
|
|
25
|
+
printMsg(MSG.Plain, `${at(f)}${via}\n${code}`);
|
|
26
|
+
return Object.assign(Object.assign({ ruleId: f.ruleId }, meta), { severity: f.severity, message: f.message, findingLocation: `// ${at(f)}${via}\n\n${code}` });
|
|
27
|
+
});
|
|
28
|
+
/**
|
|
29
|
+
* A YAML taintwire rule as a pgq rule. Steps run in order: each step's row ids are a Cypher parameter
|
|
30
|
+
* (`$<step name>`) for the steps after it, so step k `uses` every earlier step (an empty one empties it, as a step
|
|
31
|
+
* with no rows used to end the rule). `taintFrom` becomes `from`, with no hop limit unless the rule sets one. The
|
|
32
|
+
* last step's rows are the findings. A `taintFrom` or `requires` that names no earlier step leaves the rule without
|
|
33
|
+
* findings, as in the AST engine, where such a step never completes.
|
|
34
|
+
*/
|
|
35
|
+
export const toPgRule = (rule) => {
|
|
36
|
+
var _a, _b, _c, _d;
|
|
37
|
+
// A Map, so a step name such as `toString` or `__proto__` can't resolve to an Object.prototype member.
|
|
38
|
+
const steps = new Map();
|
|
39
|
+
let last;
|
|
40
|
+
let broken = false;
|
|
41
|
+
for (const step of rule.steps) {
|
|
42
|
+
const tw = step.taintwire;
|
|
43
|
+
const sel = {
|
|
44
|
+
cypher: [tw.query].flat().map((query) => ({ query })),
|
|
45
|
+
uses: Object.fromEntries(steps),
|
|
46
|
+
};
|
|
47
|
+
if ((_a = step.requires) === null || _a === void 0 ? void 0 : _a.some((r) => !steps.has(r)))
|
|
48
|
+
broken = true;
|
|
49
|
+
if (tw.taintFrom) {
|
|
50
|
+
if (!steps.has(tw.taintFrom))
|
|
51
|
+
broken = true; // no such earlier step: nothing flows, so no findings
|
|
52
|
+
sel.from = steps.get(tw.taintFrom);
|
|
53
|
+
sel.mode = (_b = tw.mode) !== null && _b !== void 0 ? _b : "deep";
|
|
54
|
+
sel.maxHops = (_c = tw.maxHops) !== null && _c !== void 0 ? _c : Number.POSITIVE_INFINITY;
|
|
55
|
+
}
|
|
56
|
+
steps.set(step.name, (last = sel));
|
|
57
|
+
}
|
|
58
|
+
const lastStep = rule.steps[rule.steps.length - 1];
|
|
59
|
+
return {
|
|
60
|
+
id: rule.id,
|
|
61
|
+
name: rule.name,
|
|
62
|
+
severity: rule.severity,
|
|
63
|
+
message: (_d = lastStep === null || lastStep === void 0 ? void 0 : lastStep.message) !== null && _d !== void 0 ? _d : rule.name,
|
|
64
|
+
return: last && !broken ? [last] : [],
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
/** Runs YAML taintwire `rules` on one graph through taintwire's pgq runner. */
|
|
68
|
+
export const runTaintwireRules = (graph, rules) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const { runPgq } = yield import("@js-recon/taintwire");
|
|
70
|
+
const byId = new Map(rules.map((r) => [r.id, r]));
|
|
71
|
+
const { findings, errors } = yield runPgq(graph, rules.map(toPgRule));
|
|
72
|
+
for (const e of errors)
|
|
73
|
+
printMsg(MSG.Err, `[!] taintwire rule ${e.ruleId} failed: ${e.message}`);
|
|
74
|
+
const out = [];
|
|
75
|
+
for (const f of findings) {
|
|
76
|
+
const r = byId.get(f.ruleId);
|
|
77
|
+
out.push(yield toEngineOutput(graph, f, {
|
|
78
|
+
ruleName: r.name,
|
|
79
|
+
ruleType: r.type,
|
|
80
|
+
ruleDescription: r.description,
|
|
81
|
+
ruleAuthor: r.author,
|
|
82
|
+
ruleTech: r.tech,
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
return { findings: out, failedRules: errors.map((e) => e.ruleId) };
|
|
86
|
+
});
|
|
87
|
+
/**
|
|
88
|
+
* Loads the chunks of `mapped.json` into taintwire graphs (one graph file per chunk, about 2 MB of
|
|
89
|
+
* source per graph) and runs every rule on each. A chunk is loaded only if some rule's prefilter
|
|
90
|
+
* matches it, or some rule has none: taintwire builds no cross-chunk edges, so a chunk without a
|
|
91
|
+
* source can't produce a finding. A rule that fails on any graph is listed in `failedRules`.
|
|
92
|
+
*/
|
|
93
|
+
const taintwireEngine = (rules, chunks) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const filters = rules.map((r) => (r.prefilter ? new RegExp(r.prefilter) : null));
|
|
95
|
+
const units = Object.values(chunks)
|
|
96
|
+
.filter((c) => c.code && filters.some((f) => !f || f.test(c.code)))
|
|
97
|
+
.map((c) => ({ name: c.id, size: c.code.length, code: () => c.code }));
|
|
98
|
+
printMsg(MSG.Header, `[i] Running ${rules.length} taintwire rule(s) on ${units.length} of ${Object.keys(chunks).length} chunk(s)`);
|
|
99
|
+
const findings = [];
|
|
100
|
+
const failed = new Set();
|
|
101
|
+
yield forEachGraph(units, (graph) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const run = yield runTaintwireRules(graph, rules);
|
|
103
|
+
for (const f of run.findings)
|
|
104
|
+
findings.push(f);
|
|
105
|
+
for (const id of run.failedRules)
|
|
106
|
+
failed.add(id);
|
|
107
|
+
}));
|
|
108
|
+
return { findings, failedRules: [...failed] };
|
|
109
|
+
});
|
|
110
|
+
export default taintwireEngine;
|
|
111
|
+
//# sourceMappingURL=taintwireEngine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taintwireEngine.js","sourceRoot":"","sources":["../../../src/analyze/engine/taintwireEngine.ts"],"names":[],"mappings":";;;;;;;;;AAIA,OAAO,EAAa,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAE1D,6DAA6D;AAC7D,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,EAAW,CAAC;AAKtH;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAO,KAAkB,EAAE,CAAa,EAAE,IAAiB,EAAyB,EAAE;IAChH,MAAM,EAAE,GAAG,CAAC,CAAc,EAAE,EAAE,CAAC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AAG,MAAM,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAClD,KAAK,MAAM,CAAC,IAAI,GAAG,CAAC,QAAQ;YAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC/C,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,WAAW;YAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC,CAAA,CAAC,CAAC;IACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,GAAG,MAAM,CAAC,EAAE,CAAC;AAClD,CAAC,CAAA,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -36,6 +36,12 @@ const regexMatchStepSchema = z.object({
|
|
|
36
36
|
const csMastSStepSchema = z.object({
|
|
37
37
|
signature: z.string(),
|
|
38
38
|
});
|
|
39
|
+
const taintwireStepSchema = z.object({
|
|
40
|
+
query: z.union([z.string(), z.array(z.string()).min(1)]),
|
|
41
|
+
taintFrom: z.string().optional(),
|
|
42
|
+
mode: z.enum(["strict", "lenient", "deep"]).optional(),
|
|
43
|
+
maxHops: z.number().int().nonnegative().optional(),
|
|
44
|
+
});
|
|
39
45
|
const stepSchema = z.object({
|
|
40
46
|
name: z.string(),
|
|
41
47
|
message: z.string(),
|
|
@@ -46,8 +52,10 @@ const stepSchema = z.object({
|
|
|
46
52
|
checkAssignmentExist: checkAssignmentExistStepSchema.optional(),
|
|
47
53
|
regexMatch: regexMatchStepSchema.optional(),
|
|
48
54
|
csMastS: csMastSStepSchema.optional(),
|
|
55
|
+
taintwire: taintwireStepSchema.optional(),
|
|
49
56
|
});
|
|
50
|
-
export const ruleSchema = z
|
|
57
|
+
export const ruleSchema = z
|
|
58
|
+
.object({
|
|
51
59
|
id: z.string(),
|
|
52
60
|
name: z.string(),
|
|
53
61
|
author: z.string(),
|
|
@@ -56,7 +64,28 @@ export const ruleSchema = z.object({
|
|
|
56
64
|
js_recon_max_version: z.string().optional(),
|
|
57
65
|
tech: z.array(z.enum(["next", "vue", "react", "svelte", "angular", "all"])),
|
|
58
66
|
severity: z.enum(["info", "low", "medium", "high"]),
|
|
59
|
-
type: z.enum(["request", "ast", "cs-mast-s"]),
|
|
67
|
+
type: z.enum(["request", "ast", "cs-mast-s", "taintwire"]),
|
|
68
|
+
prefilter: z.string().optional(),
|
|
60
69
|
steps: z.array(stepSchema),
|
|
61
|
-
})
|
|
70
|
+
})
|
|
71
|
+
.refine((r) => r.type !== "taintwire" ||
|
|
72
|
+
r.steps.every((s) => s.taintwire && /^[A-Za-z_]\w*$/.test(s.name) && s.name !== "__proto__"),
|
|
73
|
+
// step names become Cypher parameters ($<name>) for later steps; __proto__ would be lost as an object key
|
|
74
|
+
{
|
|
75
|
+
message: "every step of a taintwire rule needs a taintwire block and a name made of letters, digits and _ (not __proto__)",
|
|
76
|
+
})
|
|
77
|
+
.refine((r) => r.type !== "taintwire" ||
|
|
78
|
+
r.steps.every((s, i) => {
|
|
79
|
+
var _a;
|
|
80
|
+
const from = (_a = s.taintwire) === null || _a === void 0 ? void 0 : _a.taintFrom;
|
|
81
|
+
return from === undefined || r.steps.slice(0, i).some((earlier) => earlier.name === from);
|
|
82
|
+
}), { message: "a taintwire step's taintFrom must name an earlier step" })
|
|
83
|
+
.refine((r) => {
|
|
84
|
+
try {
|
|
85
|
+
return !r.prefilter || !!new RegExp(r.prefilter);
|
|
86
|
+
}
|
|
87
|
+
catch (_a) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
}, { message: "prefilter must be a valid regular expression", path: ["prefilter"] });
|
|
62
91
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/analyze/helpers/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC;IAC9B,CAAC,CA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ACpC,OAAO,IAAI,KAAK,SAAS,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;IAC9F,CAAC,CAAC,EACN,EAAE,OAAO,EAAE,wDAAwD,EAAE,CACxE;KACA,MAAM,CACH,CAAC,CAAC,EAAE,EAAE;IACF,IAAI,CAAC;QACD,OAAO,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACrD,CAAC;IAAC,WAAM,CAAC;QACL,OAAO,KAAK,CAAC;IACjB,CAAC;AACL,CAAC,EACD,EAAE,OAAO,EAAE,8CAA8C,EAAE,IAAI,EAAE,CAAC,WAAW,CAAC,EAAE,CACnF,CAAC"}
|
|
@@ -66,22 +66,26 @@ const validateRules = (ruleFiles) => __awaiter(void 0, void 0, void 0, function*
|
|
|
66
66
|
try {
|
|
67
67
|
const ruleData = fs.readFileSync(ruleFile, "utf8");
|
|
68
68
|
const rule = yaml.parse(ruleData);
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
// Version first: a rule written for a newer js-recon (say, a rule type this version
|
|
70
|
+
// doesn't know) is skipped rather than failing schema validation.
|
|
71
|
+
if (typeof (rule === null || rule === void 0 ? void 0 : rule.js_recon_version) === "string" &&
|
|
72
|
+
!isVersionCompatible(rule.js_recon_version, CONFIG.version)) {
|
|
71
73
|
printMsg(MSG.Warn, `[!] Skipping ${ruleFile}: requires js-recon ${rule.js_recon_version} (current: ${CONFIG.version})`);
|
|
72
74
|
continue;
|
|
73
75
|
}
|
|
74
|
-
if (rule
|
|
76
|
+
if (typeof (rule === null || rule === void 0 ? void 0 : rule.js_recon_max_version) === "string" &&
|
|
77
|
+
!isVersionCompatible(rule.js_recon_max_version, CONFIG.version)) {
|
|
75
78
|
printMsg(MSG.Warn, `[!] Skipping ${ruleFile}: requires js-recon ${rule.js_recon_max_version} (current: ${CONFIG.version})`);
|
|
76
79
|
continue;
|
|
77
80
|
}
|
|
81
|
+
ruleSchema.parse(rule);
|
|
78
82
|
compatibleRuleFiles.push(ruleFile);
|
|
79
83
|
}
|
|
80
84
|
catch (error) {
|
|
81
85
|
allValid = false;
|
|
82
86
|
printMsg(MSG.Err, `[!] Invalid rule in ${ruleFile}:`);
|
|
83
|
-
if (error.
|
|
84
|
-
for (const err of error.
|
|
87
|
+
if (error.issues) {
|
|
88
|
+
for (const err of error.issues) {
|
|
85
89
|
printMsg(MSG.Err, ` - ${err.path.join(".")} - ${err.message}`);
|
|
86
90
|
}
|
|
87
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../src/analyze/helpers/validate.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAA4B,EAAE;IACtE,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACpC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG,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AK,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;oBAC7B,QAAQ,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;gBACpE,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC;AAC7C,CAAC,CAAA,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/build/analyze/index.js
CHANGED
|
@@ -16,6 +16,8 @@ import yaml from "yaml";
|
|
|
16
16
|
import initRules from "./helpers/initRules.js";
|
|
17
17
|
import { generateEngineOutput } from "./helpers/outputHelper.js";
|
|
18
18
|
import { printMsg, MSG } from "../utility/printMsg.js";
|
|
19
|
+
import { getAnalyzeTaintwire } from "../utility/globals.js";
|
|
20
|
+
import { listFilesRecursive } from "../utility/listFiles.js";
|
|
19
21
|
const availableTechs = {
|
|
20
22
|
next: "Next.js",
|
|
21
23
|
vue: "Vue.js",
|
|
@@ -23,32 +25,6 @@ const availableTechs = {
|
|
|
23
25
|
svelte: "Svelte/Astro",
|
|
24
26
|
angular: "Angular",
|
|
25
27
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Recursively searches for YAML rule files in a directory.
|
|
28
|
-
*
|
|
29
|
-
* @param dir - The directory path to search for rule files
|
|
30
|
-
* @returns An array of file paths to YAML rule files (.yml or .yaml)
|
|
31
|
-
*/
|
|
32
|
-
const getRuleFilesRecursive = (dir) => {
|
|
33
|
-
let results = [];
|
|
34
|
-
const list = fs.readdirSync(dir);
|
|
35
|
-
list.forEach(function (entry) {
|
|
36
|
-
// skip hidden directories (e.g. .github)
|
|
37
|
-
if (entry.startsWith("."))
|
|
38
|
-
return;
|
|
39
|
-
const file = path.join(dir, entry);
|
|
40
|
-
const stat = fs.statSync(file);
|
|
41
|
-
if (stat && stat.isDirectory()) {
|
|
42
|
-
results = results.concat(getRuleFilesRecursive(file));
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
if (file.endsWith(".yml") || file.endsWith(".yaml")) {
|
|
46
|
-
results.push(file);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
return results;
|
|
51
|
-
};
|
|
52
28
|
/**
|
|
53
29
|
* Analyzes JavaScript code using custom rules and generates findings.
|
|
54
30
|
*
|
|
@@ -82,7 +58,7 @@ const analyze = (rulesPath_1, mappedJson_1, tech_1, list_1, openapi_1, validate_
|
|
|
82
58
|
// now that the rule thing exist, check if it is a direcotory or a file
|
|
83
59
|
let ruleFiles = [];
|
|
84
60
|
if (fs.lstatSync(rulesPath).isDirectory()) {
|
|
85
|
-
ruleFiles =
|
|
61
|
+
ruleFiles = listFilesRecursive(rulesPath, [".yml", ".yaml"]);
|
|
86
62
|
}
|
|
87
63
|
else {
|
|
88
64
|
ruleFiles = [rulesPath];
|
|
@@ -145,18 +121,46 @@ const analyze = (rulesPath_1, mappedJson_1, tech_1, list_1, openapi_1, validate_
|
|
|
145
121
|
}
|
|
146
122
|
// iterate over the ruleFiles
|
|
147
123
|
const ruleFindings = [];
|
|
124
|
+
const taintwireRules = [];
|
|
148
125
|
for (const ruleFile of compatibleRuleFiles) {
|
|
149
126
|
// load the rule
|
|
150
127
|
const rule = yaml.parse(fs.readFileSync(ruleFile, "utf8"));
|
|
128
|
+
// taintwire rules share one set of graphs, so they run together below
|
|
129
|
+
if (rule.type === "taintwire") {
|
|
130
|
+
if (rule.tech.includes(tech) || rule.tech.includes("all"))
|
|
131
|
+
taintwireRules.push(rule);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
151
134
|
// run the rule
|
|
152
135
|
const engineFindings = yield engine(rule, mappedJsonData, openapiData, tech);
|
|
153
136
|
// add findings to the global findings
|
|
154
|
-
|
|
155
|
-
|
|
137
|
+
// one at a time: spreading a large array into push() exceeds the argument limit
|
|
138
|
+
if (engineFindings)
|
|
139
|
+
for (const finding of engineFindings)
|
|
140
|
+
ruleFindings.push(finding);
|
|
141
|
+
}
|
|
142
|
+
let failedTaintwireRules = [];
|
|
143
|
+
if (taintwireRules.length > 0 && mappedJsonData) {
|
|
144
|
+
if (getAnalyzeTaintwire()) {
|
|
145
|
+
// dynamic import: the native graph database loads only when taintwire rules run
|
|
146
|
+
const { default: taintwireEngine } = yield import("./engine/taintwireEngine.js");
|
|
147
|
+
const { findings, failedRules } = yield taintwireEngine(taintwireRules, mappedJsonData);
|
|
148
|
+
for (const finding of findings)
|
|
149
|
+
ruleFindings.push(finding);
|
|
150
|
+
failedTaintwireRules = failedRules;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
printMsg(MSG.Info, `[i] Skipped ${taintwireRules.length} taintwire rule(s); pass --analyze-taintwire to run them`);
|
|
156
154
|
}
|
|
157
155
|
}
|
|
158
156
|
// generate the engine output
|
|
159
157
|
generateEngineOutput(outputFile, ruleFindings);
|
|
158
|
+
// The findings of the other rules are written; the exit code tells a caller this analysis is incomplete.
|
|
159
|
+
// exitCode, not exit(): run keeps going to the report step and exits with it.
|
|
160
|
+
if (failedTaintwireRules.length > 0) {
|
|
161
|
+
printMsg(MSG.Err, `[!] ${failedTaintwireRules.length} taintwire rule(s) failed: ${failedTaintwireRules.join(", ")}`);
|
|
162
|
+
process.exitCode = 41;
|
|
163
|
+
}
|
|
160
164
|
});
|
|
161
165
|
export default analyze;
|
|
162
166
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/analyze/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,wBAAwB,MAAM,yCAAyC,CAAC;AAE/E,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,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AAoB,GAAa,EAAE,CAAC;IACxC,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,IAAI,cAAc,EAAE,CAAC;QAC9C,IAAI,mBAAmB,EAAE,EAAE,CAAC;YACxB,gFAAgF;YAChF,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,MAAM,MAAM,CAAC,6BAA6B,CAAC,CAAC;YACjF,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,MAAM,eAAe,CAAC,cAAc,EAAE,cAAc,CAAC,CAAC;YACxF,KAAK,MAAM,OAAO,IAAI,QAAQ;gBAAE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3D,oBAAoB,GAAG,WAAW,CAAC;QACvC,CAAC;aAAM,CAAC;YACJ,QAAQ,CACJ,GAAG,CAAC,IAAI,EACR,eAAe,cAAc,CAAC,MAAM,0DAA0D,CACjG,CAAC;QACN,CAAC;IACL,CAAC;IAED,6BAA6B;IAC7B,oBAAoB,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;IAE/C,yGAAyG;IACzG,8EAA8E;IAC9E,IAAI,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,QAAQ,CACJ,GAAG,CAAC,GAAG,EACP,OAAO,oBAAoB,CAAC,MAAM,8BAA8B,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACpG,CAAC;QACF,OAAO,CAAC,QAAQ,GAAG,EAAE,CAAC;IAC1B,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
package/build/cliProgram.js
CHANGED
|
@@ -30,6 +30,7 @@ import fingerprint from "./fingerprint/index.js";
|
|
|
30
30
|
import { applyHeapLimit } from "./utility/heap.js";
|
|
31
31
|
import csMast from "./cs_mast/index.js";
|
|
32
32
|
import sourcemaps from "./sourcemaps/index.js";
|
|
33
|
+
import * as taintwire from "./taintwire/index.js";
|
|
33
34
|
import completion from "./completion/index.js";
|
|
34
35
|
import { getLoadedApplicationConfig, prepareProgramConfiguration } from "./config/applicationConfig.js";
|
|
35
36
|
import { configureOxylabsFallback, getOxylabsFallbackConfiguration, OxylabsFallbackConfigurationError, resolveOxylabsFallback, } from "./proxy/oxylabsFallback.js";
|
|
@@ -148,7 +149,7 @@ export function buildProgram() {
|
|
|
148
149
|
.option("--detection-timeout <seconds>", "Timeout for front-end framework detection in seconds (0 = no timeout)", "30")
|
|
149
150
|
.option("--max-pages <pages>", "Maximum HTML pages to visit during Next.js crawl (0 = unlimited)", "200")
|
|
150
151
|
.option("--rsc-param-bruteforce-limit <n>", "Max harvested dynamic-route param-name candidates to try per URL in next_routerStateForge's RSC-body keyword fallback (0 = disable the fallback)", "20")
|
|
151
|
-
.option("--wordlist <file>", "Newline-separated file of path segments/prefixes (e.g. 'admin'); each entry is added as <origin>/<entry> to
|
|
152
|
+
.option("--wordlist <file>", "Newline-separated file of path segments/prefixes (e.g. 'admin'); each entry is added as <origin>/<entry> to the candidate URLs of next_routerStateForge and next_interceptRouteNextUrl")
|
|
152
153
|
.option("--verbose", "Show detailed file write error messages", false)
|
|
153
154
|
.option("--max-redirects <n>", "Maximum redirects to follow when resolving the default crawl scope for generic tech", "20")
|
|
154
155
|
.option("--strings", "Enable strings-based recursive JS discovery for generic tech (scans downloaded files for string-literal JS paths)", false)
|
|
@@ -415,7 +416,9 @@ export function buildProgram() {
|
|
|
415
416
|
.option("--disable-rules-version-check", "Skip the GitHub rules version check and use cached rules as-is", false)
|
|
416
417
|
.option("--determine-compatible-version", "Report the js_recon_version/js_recon_max_version each rule actually requires, based on the features it uses", false)
|
|
417
418
|
.option("--apply-compatible-versions", "Same as --determine-compatible-version, but rewrites the rule files in place", false)
|
|
419
|
+
.option("--analyze-taintwire", "Run taintwire rules (Cypher taint queries over the AST graph); they are skipped otherwise", false)
|
|
418
420
|
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
421
|
+
globalsUtil.setAnalyzeTaintwire(cmd.analyzeTaintwire);
|
|
419
422
|
yield analyze(cmd.rules, cmd.mappedJson, cmd.tech, cmd.list, cmd.openapi, cmd.validate, cmd.output, !!cmd.disableRulesVersionCheck, cmd.determineCompatibleVersion, cmd.applyCompatibleVersions);
|
|
420
423
|
}));
|
|
421
424
|
program
|
|
@@ -520,6 +523,7 @@ export function buildProgram() {
|
|
|
520
523
|
.option("--no-graphql", "Disable GraphQL operation extraction during OpenAPI generation")
|
|
521
524
|
.option("--ngql", "Alias for --no-graphql")
|
|
522
525
|
.option("--map-taintwire", "Resolve API calls in the map step with taintwire (Cypher queries over the AST graph) instead of the legacy Babel resolvers", false)
|
|
526
|
+
.option("--analyze-taintwire", "Run taintwire rules in the analyze step (Cypher taint queries over the AST graph); they are skipped otherwise", false)
|
|
523
527
|
.option("--timeout <timeout>", "Request timeout in ms", "30000")
|
|
524
528
|
.option("-k, --insecure", "Disable SSL certificate verification", false)
|
|
525
529
|
.option("--no-sandbox", "Disable browser sandbox")
|
|
@@ -533,7 +537,7 @@ export function buildProgram() {
|
|
|
533
537
|
.option("--max-heap <mb>", "V8 heap size cap in MB (0 = all available RAM)")
|
|
534
538
|
.option("--max-pages <pages>", "Maximum HTML pages to visit during Next.js crawl (0 = unlimited)", "200")
|
|
535
539
|
.option("--rsc-param-bruteforce-limit <n>", "Max harvested dynamic-route param-name candidates to try per URL in next_routerStateForge's RSC-body keyword fallback (0 = disable the fallback)", "20")
|
|
536
|
-
.option("--wordlist <file>", "Newline-separated file of path segments/prefixes (e.g. 'admin'); each entry is added as <origin>/<entry> to
|
|
540
|
+
.option("--wordlist <file>", "Newline-separated file of path segments/prefixes (e.g. 'admin'); each entry is added as <origin>/<entry> to the candidate URLs of next_routerStateForge and next_interceptRouteNextUrl")
|
|
537
541
|
.option("--verbose", "Show detailed file write error messages", false)
|
|
538
542
|
.option("--max-redirects <n>", "Maximum redirects to follow when resolving the default crawl scope for generic tech", "20")
|
|
539
543
|
.option("--strings", "Enable strings-based recursive JS discovery for generic tech (scans downloaded files for string-literal JS paths)", false)
|
|
@@ -612,6 +616,7 @@ export function buildProgram() {
|
|
|
612
616
|
globalsUtil.setOpenapiChunkTag(cmd.mapOpenapiChunkTag);
|
|
613
617
|
globalsUtil.setGraphqlEnabled(cmd.graphql !== false && !cmd.ngql);
|
|
614
618
|
globalsUtil.setMapTaintwire(cmd.mapTaintwire);
|
|
619
|
+
globalsUtil.setAnalyzeTaintwire(cmd.analyzeTaintwire);
|
|
615
620
|
globalsUtil.setDisableCache(cmd.disableCache);
|
|
616
621
|
globalsUtil.setRespCacheFile(cmd.cacheFile);
|
|
617
622
|
globalsUtil.setCacheOnly(cmd.cacheOnly);
|
|
@@ -739,6 +744,33 @@ export function buildProgram() {
|
|
|
739
744
|
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
740
745
|
yield sourcemaps(cmd.input, cmd.output);
|
|
741
746
|
}));
|
|
747
|
+
const taintwireCmd = program
|
|
748
|
+
.command("taintwire")
|
|
749
|
+
.description("Build PookieGraphs (.pg) from JS files and query them with .pgq files");
|
|
750
|
+
taintwireCmd
|
|
751
|
+
.command("build")
|
|
752
|
+
.description("Load every JS file of a directory into one linked PookieGraph (.pg)")
|
|
753
|
+
.requiredOption("-d, --directory <directory>", "Directory of JS files (e.g. lazyload's output/<host>)")
|
|
754
|
+
.option("-o, --output <file>", "PookieGraph file to write", "graph.pg")
|
|
755
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
756
|
+
yield taintwire.build(cmd.directory, cmd.output);
|
|
757
|
+
}));
|
|
758
|
+
taintwireCmd
|
|
759
|
+
.command("analyze")
|
|
760
|
+
.description("Run .pgq query files against a PookieGraph")
|
|
761
|
+
.requiredOption("-g, --graph <file>", "PookieGraph (.pg) file built by `taintwire build`")
|
|
762
|
+
.requiredOption("-q, --queries <file/dir>", "A .pgq file, or a directory searched recursively for them")
|
|
763
|
+
.option("-o, --output <file>", "Findings JSON file", "taintwire.json")
|
|
764
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
765
|
+
yield taintwire.analyze(cmd.graph, cmd.queries, cmd.output);
|
|
766
|
+
}));
|
|
767
|
+
taintwireCmd
|
|
768
|
+
.command("validate")
|
|
769
|
+
.description("Check .pgq query files: evaluate, validate and compile every query")
|
|
770
|
+
.requiredOption("-q, --queries <file/dir>", "A .pgq file, or a directory searched recursively for them")
|
|
771
|
+
.action((cmd) => __awaiter(this, void 0, void 0, function* () {
|
|
772
|
+
yield taintwire.validate(cmd.queries);
|
|
773
|
+
}));
|
|
742
774
|
program
|
|
743
775
|
.command("completion")
|
|
744
776
|
.description("Install shell completion for bash, zsh, or fish")
|