bugxhunter 0.13.0 → 0.14.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.
@@ -297,7 +297,8 @@ export function classifyCommand(command, ctx = {}) {
297
297
  // Shell metacharacters make a string's effect shell-dependent and unpredictable.
298
298
  // Reject them all: the allowed subset then runs identically via argv or a shell.
299
299
  // (`|` is handled by splitting into stages; `||` leaves an empty stage -> ask.)
300
- if (/[\r\n\\$`;&<>(){}[\]*?!~]/.test(command))
300
+ // The one exception is a query string, the commonest thing a read carries: see queryCharsMasked.
301
+ if (/[\r\n\\$`;&<>(){}[\]*?!~]/.test(queryCharsMasked(command)))
301
302
  return "ask";
302
303
  if (command.includes("||"))
303
304
  return "ask";
@@ -313,6 +314,33 @@ export function classifyCommand(command, ctx = {}) {
313
314
  }
314
315
  return "allow";
315
316
  }
317
+ /**
318
+ * `command` with the two characters of a query string blanked where a shell reads them as
319
+ * plain text, so `curl "http://target/search?q=a&page=2"` is not held up for a person:
320
+ * - `?` inside quotes of either kind. Unquoted it is a glob.
321
+ * - `&` inside DOUBLE quotes only. Unquoted it backgrounds or chains; inside single quotes
322
+ * it is literal to a POSIX shell but not to cmd.exe, which does not treat `'` as a quote.
323
+ * Everything else the metacharacter test refuses stays refused inside quotes too (`$`, a
324
+ * backtick, a backslash, `;`, `|`, brackets). Quotes are read over the whole command, as
325
+ * the shell reads them, so a character blanked here is one the shell will not act on.
326
+ */
327
+ function queryCharsMasked(command) {
328
+ let out = "", q = null;
329
+ for (const c of command) {
330
+ if (q) {
331
+ if (c === q)
332
+ q = null;
333
+ else if (c === "?" || (c === "&" && q === '"')) {
334
+ out += "_";
335
+ continue;
336
+ }
337
+ }
338
+ else if (c === '"' || c === "'")
339
+ q = c;
340
+ out += c;
341
+ }
342
+ return out;
343
+ }
316
344
  /** Split a stage into argv, honouring single/double quotes. null = unbalanced (ask). */
317
345
  function tokenize(s) {
318
346
  const out = [];
@@ -367,6 +395,11 @@ function stageAllow(argv, isFirst, ctx) {
367
395
  function curlAllow(args, ctx) {
368
396
  if (!ctx.scopeHost)
369
397
  return "ask";
398
+ // -v prints the request headers: with the captured session that would put its values in the transcript.
399
+ const usesSession = args.some((a) => (ctx.cookieFile && a === ctx.cookieFile) || (ctx.headerFile && a === `@${ctx.headerFile}`)
400
+ || (ctx.cookieFile && a === `--cookie=${ctx.cookieFile}`) || (ctx.headerFile && a === `--header=@${ctx.headerFile}`));
401
+ if (usesSession && args.some((a) => a === "--verbose" || (/^-[A-Za-z0-9#]+$/.test(a) && a.includes("v"))))
402
+ return "ask";
370
403
  let url = false;
371
404
  for (let i = 0; i < args.length; i++) {
372
405
  const a = args[i];
@@ -385,9 +418,9 @@ function curlAllow(args, ctx) {
385
418
  const v = eq >= 0 ? a.slice(eq + 1) : args[++i];
386
419
  if (v === undefined)
387
420
  return "ask";
388
- if (flag === "--header" && v.startsWith("@"))
421
+ if (flag === "--header" && v.startsWith("@") && !isSessionFile(v.slice(1), ctx.headerFile))
389
422
  return "ask"; // @file read
390
- if (flag === "--cookie" && !v.includes("="))
423
+ if (flag === "--cookie" && !v.includes("=") && !isSessionFile(v, ctx.cookieFile))
391
424
  return "ask"; // no "=" -> curl reads it as a cookie FILE
392
425
  continue;
393
426
  }
@@ -400,9 +433,9 @@ function curlAllow(args, ctx) {
400
433
  const v = args[++i];
401
434
  if (v === undefined)
402
435
  return "ask";
403
- if (a === "-H" && v.startsWith("@"))
436
+ if (a === "-H" && v.startsWith("@") && !isSessionFile(v.slice(1), ctx.headerFile))
404
437
  return "ask";
405
- if (a === "-b" && !v.includes("="))
438
+ if (a === "-b" && !v.includes("=") && !isSessionFile(v, ctx.cookieFile))
406
439
  return "ask"; // no "=" -> a cookie FILE
407
440
  continue;
408
441
  }
@@ -417,6 +450,14 @@ function curlAllow(args, ctx) {
417
450
  }
418
451
  return url ? "allow" : "ask";
419
452
  }
453
+ /**
454
+ * The one file a run's curl may read: the captured session the runner wrote for it, named
455
+ * exactly as the runner named it (no other spelling of the path). The URL check still
456
+ * applies, so the session only ever goes to the in-scope origin.
457
+ */
458
+ function isSessionFile(arg, allowed) {
459
+ return Boolean(allowed) && arg === allowed;
460
+ }
420
461
  /** True if `arg` is an http(s) URL for exactly the in-scope origin, no userinfo. */
421
462
  function okUrl(arg, ctx) {
422
463
  let u;
@@ -672,7 +713,7 @@ const STATUS_RULE = `End every turn with exactly one final line: "${STATUS_LINE}
672
713
  export const reconAgents = () => ({
673
714
  recon: subagent(modelFor("executor"), "Supervised recon/autopwn executor: enumerate the in-scope target, hypothesise weaknesses, test them with low-impact probes, and hand candidates to recon-verify. Read-only shell; never mutates state without an approved step.", "You are the EXECUTOR in a supervised penetration test of a single, explicitly in-scope target. Work one hypothesis at a time: enumerate -> hypothesise a specific weakness (name the OWASP/API Top 10 or WSTG id) -> test it with the smallest, lowest-impact probe that settles it -> record exactly what you observed. Prefer read-only probes (GET, HEAD, nmap -sV, DNS, reading saved responses). Anything that changes state (POST that writes, PUT, PATCH, DELETE, file writes) is a RED LINE: stop and hand it to the human for approval, with the one request you want to run and why. When you believe you have a finding, call the recon-verify subagent with the evidence — do NOT promote it yourself. Stay strictly inside the declared scope. If you are stuck after a couple of tries, say so plainly rather than widening scope. " + STATUS_RULE, executorPermission(), "all"),
674
715
  "recon-triage": subagent(modelFor("triage"), "Fast, cheap triage of tool output: is this response interesting, already seen, or noise? Returns a one-line verdict and the single most promising next direction.", "You triage raw tool output for the executor. In two or three sentences: is there anything security-relevant here, have we effectively seen it already, and what is the single most promising next probe? Do not run tools or speculate beyond the output you were given.", READ_ONLY),
675
- "recon-verify": subagent(modelFor("verify"), "Adversarially verifies one candidate finding, or one attack path that builds on findings, against the declared environment and the standards catalogue, assigns severity, and flags config-dependent findings before they are promoted.", "You VERIFY one candidate finding. Reject it unless there is concrete reproduction evidence (the request/command and the response that proves it). Assign severity with the project's rubric and cite the matching OWASP/API/WSTG id. CRITICAL: compare the finding against the declared environment fidelity — if it depends on a setting that differs from production (an auth flag off, a debug mode on, seed data), mark it config-dependent and say exactly what to re-test against production. Output exactly one fenced json block and nothing after it: {\"title\": \"short name of the finding\", \"verdict\": \"real\" | \"config-dependent\" | \"rejected\", \"severity\": \"low\" | \"medium\" | \"high\" | \"critical\", \"standard_id\": \"e.g. API1:2023\", \"repro\": \"the request or command and the response that proves it\", \"prod_caveat\": \"what to re-test against production, or an empty string\"}. When you are handed an ATTACK PATH (several steps that build on findings named F1, F2 and so on) instead of one finding, rule on the path as a whole. Reject it unless every step has its own request or command and response, and the evidence shows that what one step returned was used in the next: steps that each work but do not connect are not a path. A path that stops at a step that could not be shown is partial, never demonstrated. Rate severity on what the attacker ends up with, and apply the same environment check. For a path, output the block in this form instead: {\"kind\": \"chain\", \"title\": \"short name of the path\", \"verdict\": \"real\" | \"config-dependent\" | \"rejected\", \"severity\": \"low\" | \"medium\" | \"high\" | \"critical\", \"standard_id\": \"e.g. API1:2023\", \"impact\": \"what the attacker ends up with\", \"links\": [\"F1\", \"F3\"], \"steps\": [{\"action\": \"what was done\", \"evidence\": \"the request or command and the response\"}], \"status\": \"demonstrated\" | \"partial\", \"blocked_at\": the number of the step it stopped at, or null, \"blocked_why\": \"why it stopped, or an empty string\", \"prod_caveat\": \"what to re-test against production, or an empty string\"}.", READ_ONLY),
716
+ "recon-verify": subagent(modelFor("verify"), "Adversarially verifies one candidate finding, one attack path that builds on findings, or one retest of an earlier finding, against the declared environment and the standards catalogue, assigns severity, and flags config-dependent findings before they are promoted.", "You VERIFY one candidate finding. Reject it unless there is concrete reproduction evidence (the request/command and the response that proves it). Assign severity with the project's rubric and cite the matching OWASP/API/WSTG id. CRITICAL: compare the finding against the declared environment fidelity — if it depends on a setting that differs from production (an auth flag off, a debug mode on, seed data), mark it config-dependent and say exactly what to re-test against production. Output exactly one fenced json block and nothing after it: {\"title\": \"short name of the finding\", \"verdict\": \"real\" | \"config-dependent\" | \"rejected\", \"severity\": \"low\" | \"medium\" | \"high\" | \"critical\", \"standard_id\": \"e.g. API1:2023\", \"repro\": \"the request or command and the response that proves it\", \"quotes\": [\"one to three short excerpts of the response that prove it, copied character for character\"], \"prod_caveat\": \"what to re-test against production, or an empty string\"}. The quotes are checked by the program against what the commands of this run really returned, so copy them exactly from the response you were shown, never from memory or from a summary, and give an empty list if you were not shown the response itself. When you are handed an ATTACK PATH (several steps that build on findings named F1, F2 and so on) instead of one finding, rule on the path as a whole. Reject it unless every step has its own request or command and response, and the evidence shows that what one step returned was used in the next: steps that each work but do not connect are not a path. A path that stops at a step that could not be shown is partial, never demonstrated. Rate severity on what the attacker ends up with, and apply the same environment check. For a path, output the block in this form instead: {\"kind\": \"chain\", \"title\": \"short name of the path\", \"verdict\": \"real\" | \"config-dependent\" | \"rejected\", \"severity\": \"low\" | \"medium\" | \"high\" | \"critical\", \"standard_id\": \"e.g. API1:2023\", \"impact\": \"what the attacker ends up with\", \"links\": [\"F1\", \"F3\"], \"steps\": [{\"action\": \"what was done\", \"evidence\": \"the request or command and the response\"}], \"status\": \"demonstrated\" | \"partial\", \"blocked_at\": the number of the step it stopped at, or null, \"blocked_why\": \"why it stopped, or an empty string\", \"prod_caveat\": \"what to re-test against production, or an empty string\"}. When you are handed a RETEST (a finding an earlier run verified, with what the same request returns now), rule on whether it still holds, and on nothing else. It is \"still-reproducible\" only if the response now proves the weakness as it did then. It is \"fixed\" only if the same request now gets a response that shows the weakness is gone (a refusal, a corrected value): an error, a timeout, a missing page or a logged-out answer is not a fix. Anything else is \"cannot-confirm\". For a retest, output the block in this form instead: {\"kind\": \"retest\", \"title\": \"the finding's title as given\", \"result\": \"still-reproducible\" | \"fixed\" | \"cannot-confirm\", \"evidence\": \"the request or command and the response now\", \"quotes\": [\"one to three short excerpts of the response now, copied character for character\"], \"note\": \"one line on why\"}.", READ_ONLY),
676
717
  "recon-escalate": subagent(modelFor("escalate"), "Frontier escalation: called only when the executor is stuck or a High/Critical candidate needs deep adversarial review or multi-step exploit-chain reasoning. Read-only.", "You are the escalation reviewer, called rarely and only for hard cases: a stuck executor, or a High/Critical candidate that must survive adversarial scrutiny before it is reported. Reason carefully about exploitability and chaining, demand evidence, and be willing to downgrade or reject. Do not run tools; reason over what you are given and return a precise recommendation.", READ_ONLY),
677
718
  });
678
719
  //# sourceMappingURL=recon.js.map
@@ -238,6 +238,17 @@ export function unseal(dekB64) {
238
238
  dek = key;
239
239
  lastUse = Date.now();
240
240
  audit("vault.unsealed", {});
241
+ for (const listener of unsealListeners) {
242
+ try {
243
+ listener();
244
+ }
245
+ catch { /* a listener's failure must not fail the unlock */ }
246
+ }
247
+ }
248
+ const unsealListeners = [];
249
+ /** Run `listener` whenever the vault is unlocked: for work that had to wait for the key. */
250
+ export function onUnsealed(listener) {
251
+ unsealListeners.push(listener);
241
252
  }
242
253
  const sealListeners = [];
243
254
  /** Run `listener` whenever the vault is sealed: for secrets held outside it that a lock must drop too. */
@@ -0,0 +1,54 @@
1
+ /**
2
+ * A minimal zip writer (stored, no compression) for the handful of small text files the
3
+ * browser extension is made of. Enough for "download, unzip, load unpacked"; not a
4
+ * general-purpose archiver.
5
+ */
6
+ import zlib from "node:zlib";
7
+ // A fixed date (1 Jan 2026) so the same files always give the same archive.
8
+ const DOS_TIME = 0;
9
+ const DOS_DATE = ((2026 - 1980) << 9) | (1 << 5) | 1;
10
+ export function zip(entries) {
11
+ const parts = [];
12
+ const central = [];
13
+ let offset = 0;
14
+ for (const e of entries) {
15
+ const name = Buffer.from(e.name.replace(/\\/g, "/"), "utf8");
16
+ const crc = zlib.crc32(e.data);
17
+ const local = Buffer.alloc(30);
18
+ local.writeUInt32LE(0x04034b50, 0);
19
+ local.writeUInt16LE(20, 4); // version needed
20
+ local.writeUInt16LE(0x0800, 6); // names are UTF-8
21
+ local.writeUInt16LE(0, 8); // stored
22
+ local.writeUInt16LE(DOS_TIME, 10);
23
+ local.writeUInt16LE(DOS_DATE, 12);
24
+ local.writeUInt32LE(crc, 14);
25
+ local.writeUInt32LE(e.data.length, 18);
26
+ local.writeUInt32LE(e.data.length, 22);
27
+ local.writeUInt16LE(name.length, 26);
28
+ parts.push(local, name, e.data);
29
+ const head = Buffer.alloc(46);
30
+ head.writeUInt32LE(0x02014b50, 0);
31
+ head.writeUInt16LE(20, 4);
32
+ head.writeUInt16LE(20, 6);
33
+ head.writeUInt16LE(0x0800, 8);
34
+ head.writeUInt16LE(0, 10);
35
+ head.writeUInt16LE(DOS_TIME, 12);
36
+ head.writeUInt16LE(DOS_DATE, 14);
37
+ head.writeUInt32LE(crc, 16);
38
+ head.writeUInt32LE(e.data.length, 20);
39
+ head.writeUInt32LE(e.data.length, 24);
40
+ head.writeUInt16LE(name.length, 28);
41
+ head.writeUInt32LE(offset, 42);
42
+ central.push(head, name);
43
+ offset += local.length + name.length + e.data.length;
44
+ }
45
+ const dir = Buffer.concat(central);
46
+ const end = Buffer.alloc(22);
47
+ end.writeUInt32LE(0x06054b50, 0);
48
+ end.writeUInt16LE(entries.length, 8);
49
+ end.writeUInt16LE(entries.length, 10);
50
+ end.writeUInt32LE(dir.length, 12);
51
+ end.writeUInt32LE(offset, 16);
52
+ return Buffer.concat([...parts, dir, end]);
53
+ }
54
+ //# sourceMappingURL=zip.js.map