@acepaste/ingress 0.9.28 → 0.9.30

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.
@@ -31,6 +31,14 @@ export declare function withoutProtectiveNotices(text: string): {
31
31
  text: string;
32
32
  setAside: number;
33
33
  };
34
+ /**
35
+ * The string values (and keys) of JSON text, or undefined when the text is not JSON. Tried in turn: the whole
36
+ * text; what lies between its first and last bracket (a line of prose before the data), with the text around
37
+ * it returned as values too; one value per line. A value that is itself JSON text, with or without a tool
38
+ * server's notice around it, is returned as it is and opened the same way. Opening JSON never takes text out
39
+ * of what is read: only a tool server's exact notice is left out, as everywhere in this pass.
40
+ */
41
+ export declare function jsonValues(text: string, depth?: number): string[] | undefined;
34
42
  export interface ClassifierInput {
35
43
  /** the text that would be delivered */
36
44
  visible: string;
@@ -205,6 +205,110 @@ export function withoutProtectiveNotices(text) {
205
205
  }
206
206
  return setAside ? { text: out + text.slice(from), setAside } : { text, setAside: 0 };
207
207
  }
208
+ /**
209
+ * Values read one by one (0.9.30). The learned pass scores a text as one bag of words, so what a text holds is
210
+ * averaged: an attack that scores 0.99 alone scored 0.61 beside three ordinary database rows and 0.08 beside
211
+ * thirty. Of 550 public attack texts that only this pass catches as a lone row of a database result, 125 were
212
+ * still refused with thirty ordinary rows around them. A table is not one text. Each value in it was written
213
+ * by whoever filled that field, and one of them is all an attacker needs.
214
+ *
215
+ * So where the text is JSON (a JSON document, a tool result that carries JSON as text, JSON printed by a
216
+ * command, one JSON value per line), every string value of some length is also scored as a text of its own:
217
+ * its opening, the rest in windows, the allowance for what it quotes. Nothing is taken away: the whole text is
218
+ * still scored as before, at its own line.
219
+ */
220
+ const JSON_DEPTH = 3;
221
+ /**
222
+ * Every value is one more chance to be wrong, and a table has thousands. So a value is held to a stricter line
223
+ * than a lone text (0.85): 0.9 for a value of 60 characters and nine words or more, the size and the line
224
+ * hidden text is judged by; and 0.95 for a shorter one, which must still have 20 characters and four different
225
+ * words (three words and some numbers give a bag of words nothing to judge, see scanClassifier).
226
+ * Measured: of 10,796 ordinary long values in the JSON files of this repository's dependencies, five are over
227
+ * 0.9, all compiler messages in French; of 13,478 short ones, four are over 0.95; of 2,508 ordinary short text
228
+ * messages, none. Of the public attack texts the rules miss, 616 of 1,565 long ones and 29 of 173 short ones
229
+ * are over their lines.
230
+ */
231
+ const VALUE_LINE = 0.9, SHORT_VALUE_LINE = 0.95;
232
+ /** scripts written without spaces: a sentence is one "word" */
233
+ const UNSPACED = /[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Thai}]/gu;
234
+ const longValue = (t) => t.length >= 60 && (t.split(/\s+/).length >= 9 || (t.match(UNSPACED) ?? []).length >= 30);
235
+ const shortValue = (t) => t.length >= 20 && new Set(t.toLowerCase().match(/\p{L}{2,}/gu) ?? []).size >= MIN_LOG_WORDS;
236
+ function parsed(text) {
237
+ if (!/^[\[{]/.test(text))
238
+ return undefined;
239
+ try {
240
+ return { doc: JSON.parse(text) };
241
+ }
242
+ catch {
243
+ return undefined;
244
+ }
245
+ }
246
+ /**
247
+ * The string values (and keys) of JSON text, or undefined when the text is not JSON. Tried in turn: the whole
248
+ * text; what lies between its first and last bracket (a line of prose before the data), with the text around
249
+ * it returned as values too; one value per line. A value that is itself JSON text, with or without a tool
250
+ * server's notice around it, is returned as it is and opened the same way. Opening JSON never takes text out
251
+ * of what is read: only a tool server's exact notice is left out, as everywhere in this pass.
252
+ */
253
+ export function jsonValues(text, depth = 0) {
254
+ const t = text.trim();
255
+ if (t.length < 2)
256
+ return undefined;
257
+ let docs;
258
+ // what stands before and after the data, when the data is only part of the text: values like any other, so
259
+ // that nothing a text holds goes unread for having a pair of brackets after it
260
+ let before = "", after = "";
261
+ const whole = parsed(t);
262
+ if (whole)
263
+ docs = [whole.doc];
264
+ if (!docs) {
265
+ const first = t.search(/[\[{]/), last = Math.max(t.lastIndexOf("]"), t.lastIndexOf("}"));
266
+ const inner = first >= 0 && last > first && (first > 0 || last < t.length - 1) ? parsed(t.slice(first, last + 1)) : undefined;
267
+ if (inner) {
268
+ docs = [inner.doc];
269
+ before = t.slice(0, first).trim();
270
+ after = t.slice(last + 1).trim();
271
+ }
272
+ }
273
+ if (!docs) {
274
+ const lines = t.split("\n").map((l) => l.trim()).filter(Boolean);
275
+ if (lines.length >= 2 && lines.every((l) => /^[\[{]/.test(l))) {
276
+ const each = lines.map((l) => parsed(l));
277
+ if (each.every((x) => x))
278
+ docs = each.map((x) => x.doc);
279
+ }
280
+ }
281
+ if (!docs)
282
+ return undefined;
283
+ const out = before ? [before] : [];
284
+ const walk = (v, d) => {
285
+ if (d > 64)
286
+ return;
287
+ if (typeof v === "string") {
288
+ // a value that is JSON text is read both ways: as the text it is, and value by value. Otherwise an
289
+ // attack cut into an array of short strings inside one field would be read as neither.
290
+ const mayBeJson = /[\[{]/.test(v);
291
+ const bare = mayBeJson ? withoutProtectiveNotices(v).text.trim() : v;
292
+ out.push(bare);
293
+ const inner = mayBeJson && depth < JSON_DEPTH ? jsonValues(bare, depth + 1) : undefined;
294
+ if (inner)
295
+ out.push(...inner);
296
+ }
297
+ else if (Array.isArray(v))
298
+ for (const x of v)
299
+ walk(x, d + 1);
300
+ else if (v && typeof v === "object")
301
+ for (const [k, x] of Object.entries(v)) {
302
+ out.push(k);
303
+ walk(x, d + 1);
304
+ }
305
+ };
306
+ for (const d of docs)
307
+ walk(d, 0);
308
+ if (after)
309
+ out.push(after);
310
+ return out;
311
+ }
208
312
  /**
209
313
  * The classifier pass. A finding from here scores between the suspect line and well under the hostile line,
210
314
  * so on its own it refuses with an override and never more.
@@ -241,20 +345,46 @@ export function scanClassifier(input) {
241
345
  });
242
346
  /** recorded on the receipt, deciding nothing */
243
347
  const note = (p, where) => ({ pass: "classifier", kind: "classifier.injection_likely", confidence: 0, severity: 0, message: `resembles an injection or jailbreak attempt (learned classifier, ${(p * 100).toFixed(0)}%); not decisive for visible ${authority} text`, location: where, action: "none" });
348
+ /** a text's score as a lone text gets it: its opening, then the rest in overlapping windows */
349
+ const read = (text) => {
350
+ const cps = Array.from(text);
351
+ let p = visibleScore(cps.slice(0, maxChars).join("")), pastOpening = false;
352
+ for (let s = STEP, n = 0; s < cps.length - 200 && n < MAX_WINDOWS && cps.length > maxChars; s += STEP, n++) {
353
+ const q = visibleScore(cps.slice(s, s + WINDOW).join(""));
354
+ if (q > p) {
355
+ p = q;
356
+ pastOpening = true;
357
+ }
358
+ }
359
+ return { p, pastOpening };
360
+ };
244
361
  const visible = judged.text.trim();
245
362
  if (visible.length >= 20) {
246
- const cps = Array.from(visible);
247
- let best = visibleScore(cps.slice(0, maxChars).join("")), where = "visible text";
248
- // the rest of a long text, in overlapping windows
249
- for (let s = STEP, n = 0; s < cps.length - 200 && n < MAX_WINDOWS && cps.length > maxChars; s += STEP, n++) {
250
- const p = visibleScore(cps.slice(s, s + WINDOW).join(""));
251
- if (p > best) {
252
- best = p;
253
- where = "visible text (past the opening)";
363
+ const whole = read(visible);
364
+ let best = whole.p, where = whole.pastOpening ? "visible text (past the opening)" : "visible text";
365
+ // JSON: each value is also read as a text of its own (see jsonValues). Only where this pass may decide.
366
+ let value, values = 0;
367
+ if (authority === "text" && !tooFewWords) {
368
+ const sources = input.kind === "json" ? input.segments.filter((s) => s.visibility === "visible").map((s) => withoutProtectiveNotices(s.text).text) : [judged.text];
369
+ for (const src of sources) {
370
+ const opened = jsonValues(src);
371
+ // a JSON document's own values are pieces as they stand; other text is a piece only when it is JSON
372
+ for (const v of opened ?? (input.kind === "json" && sources.length > 1 ? [src] : [])) {
373
+ const t = v.trim();
374
+ const at = longValue(t) ? VALUE_LINE : shortValue(t) ? SHORT_VALUE_LINE : 0;
375
+ if (!at)
376
+ continue;
377
+ values++;
378
+ const p = read(t).p;
379
+ if (p >= at && p > (value?.p ?? 0))
380
+ value = { p, at };
381
+ }
254
382
  }
255
383
  }
256
384
  if (best >= line)
257
385
  out.push(finding(best, line, where, false));
386
+ else if (value)
387
+ out.push(finding(value.p, value.at, `one value in the data, read by itself (${values} read)`, false));
258
388
  else if (best >= Math.max(threshold, 0.9))
259
389
  out.push(note(best, where));
260
390
  }
@@ -26,7 +26,7 @@ export { adaptEmail, parseEmail, looksLikeEmailJson, looksLikeRawEmail } from ".
26
26
  export type { EmailPart } from "./email.js";
27
27
  export { adaptCalendar, parseIcs, looksLikeCalendarJson } from "./calendar.js";
28
28
  export { passagesOnlyIn } from "./served.js";
29
- export { classifyText, scanClassifier, classifierInfo, withoutProtectiveNotices } from "./classifier.js";
29
+ export { classifyText, scanClassifier, classifierInfo, withoutProtectiveNotices, jsonValues } from "./classifier.js";
30
30
  export { CLASSIFIER_MODEL } from "./classifier-model.js";
31
31
  export { shellTokens, shellInvocations, shellOutputSource, shellWrites, shellUploads } from "./shell-commands.js";
32
32
  export { inspectImage, helperRunner, visionHelperPath, visionHelperProblem, visionHelperSource, buildVisionHelper, buildNativeHelper } from "./image.js";
package/dist/src/index.js CHANGED
@@ -17,7 +17,7 @@ export { adaptTerminal } from "./terminal.js";
17
17
  export { adaptEmail, parseEmail, looksLikeEmailJson, looksLikeRawEmail } from "./email.js";
18
18
  export { adaptCalendar, parseIcs, looksLikeCalendarJson } from "./calendar.js";
19
19
  export { passagesOnlyIn } from "./served.js";
20
- export { classifyText, scanClassifier, classifierInfo, withoutProtectiveNotices } from "./classifier.js";
20
+ export { classifyText, scanClassifier, classifierInfo, withoutProtectiveNotices, jsonValues } from "./classifier.js";
21
21
  export { CLASSIFIER_MODEL } from "./classifier-model.js";
22
22
  export { shellTokens, shellInvocations, shellOutputSource, shellWrites, shellUploads } from "./shell-commands.js";
23
23
  export { inspectImage, helperRunner, visionHelperPath, visionHelperProblem, visionHelperSource, buildVisionHelper, buildNativeHelper } from "./image.js";
@@ -103,6 +103,12 @@ const INSTRUCTION_SHAPES = [
103
103
  * the dotenv README, Wikipedia's Kernel panic article, the sudoers man page and 23 of 27 everyday developer
104
104
  * sentences. Topic words now either sit behind IMPERATIVE or count as weak evidence.
105
105
  */
106
+ /** the named jailbreak personas: refused wherever they stand, with no allowance for quotation or a code block (see their rules) */
107
+ const DAN_PERSONA = "DAN persona";
108
+ const OTHER_PERSONA = "STAN, AIM or DUDE persona";
109
+ const ALWAYS_REFUSED = new Set([DAN_PERSONA, OTHER_PERSONA]);
110
+ /** "mode" as a word of its own, in English and where the same prompts circulate: Turkish (modu, modunda), Spanish, Portuguese and Italian (modo), German (Modus). Not "model", "modern", "moderate". */
111
+ const MODE = "[Mm]od(?:es?|o|us|u(?:n[uae]|nda(?:n)?|yla|dur)?)";
106
112
  const AGENT_SHAPES = [
107
113
  [/\b(ignore|disregard|forget|override|supersede)\b[^.\n]{0,40}\b(previous|prior|above|earlier|all|your|original|initial)\b[^.\n]{0,20}\b(instructions?|directions?|directives?|system\s+prompt|guidelines|programming|code\s+review\s+guidelines|processing\s+task|formatting\s+task|task)\b/i, 0.85, "drop prior instructions"],
108
114
  [/\b(previous|prior|all\s+previous|original)\s+(system\s+prompt|instructions|directives|rules)\s+(is|are)\s+(now\s+)?(revoked|deprecated|void|superseded|cancelled|canceled|overridden)/i, 0.9, "revokes prior instructions"],
@@ -116,10 +122,33 @@ const AGENT_SHAPES = [
116
122
  // "system configuration", "write your system prompt" (prompting guides) and "list the initial setup" are documentation
117
123
  [imp(/(output|print|show|reveal|share|tell\s+me|give\s+me|repeat|recite|translate|summari[sz]e|encode|convert|spell\s+out|dump|display|quote|leak|paste)\b[^.\n]{0,60}\b((your|the|my)\s+)?(full\s+|complete\s+|exact\s+|entire\s+|original\s+|initial\s+|current\s+|hidden\s+)?(system\s+(prompt|instructions?)|initial\s+(prompt|instructions?)|original\s+instructions?|hidden\s+instructions?|internal\s+instructions?)\b/), 0.85, "system prompt request"],
118
124
  [/\byour\s+(system\s+(prompt|instructions?|message)|initial\s+(prompt|instructions?)|original\s+instructions|internal\s+configuration)\b|\b(instructions|prompts?)\s+you\s+(were|have\s+been|'ve\s+been)\s+given\b|\binstructions\s+you('ve|\s+have)\s+received\b|\bmessages\[0\]/i, 0.6, "references the model's own prompt"],
119
- // the persona acronyms are names only in capitals: "aim" and "dan" are ordinary words (docs.python.org matched "aim ... version")
120
- [/\b(DAN|STAN|AIM|DUDE)\b(?=[^.\n]{0,80}\b([Ss]tands\s+for|[Mm]ode|[Vv]ersion|\d+\.\d|[Aa]nything|[Nn]orms|[Mm]achiavellian))/, 0.85, "jailbreak persona"],
125
+ // The named jailbreak personas (0.9.29, the owner's rule): naming one is refused wherever it stands, as an
126
+ // order, in a list of technique names on a dataset card, in a citation, in quotation marks or in a code
127
+ // block. Refused as suspect, so a person can still ask for the page. The acronyms are names only in capitals
128
+ // ("aim" and "dan" are ordinary words: docs.python.org matched "aim ... version"), and even in capitals they
129
+ // are words too, so each counts only where it is the persona.
130
+ //
131
+ // DAN: its spelled-out name; or DAN in capitals (not after an apostrophe or a letter: Turkish writes
132
+ // ANKARA'DAN, "from Ankara") with a version number right after it, with a persona word after it in the same
133
+ // sentence, with "jailbreak", "persona" or "role-play" before it, or with the model told to be it (in
134
+ // English, and in Turkish as the public Turkish set writes it: "DAN adlı bir modelsin", you are a model
135
+ // called DAN, which 0.9.28 caught only because "mode" matched the start of "modelsin").
136
+ [/\bdo\s+anything\s+now\b/i, 0.85, DAN_PERSONA],
137
+ [new RegExp(`(?<![\\p{L}\\p{N}'’])DAN\\b(?=[\\s-]*([Vv]\\.?\\s*\\d|[Vv]ersion\\s+\\d|\\d+\\.\\d)|[^.\\n]{0,80}\\b([Ss]tands\\s+for|${MODE}|[Aa]nything|[Jj]ailbreak\\w*|[Pp]ersonas?|[Pp]rompts?)\\b)|\\b([Jj]ailbreak\\w*|[Pp]ersonas?|[Rr]ole-?play\\w*)\\b[^.\\n]{0,80}(?<![\\p{L}\\p{N}'’])DAN\\b|\\b([Yy]ou\\s+are|[Yy]ou're|[Aa]ct(ing)?\\s+as|[Pp]retend(ing)?\\s+to\\s+be|[Bb]ecome|[Cc]alled|[Nn]amed)\\s+(now\\s+)?DAN\\b|(?<![\\p{L}\\p{N}'’])DAN\\b[^.\\n]{0,40}\\b(modelsin|asistans[ıi]n|botsun|karaktersin|zekas[ıi]n|olarak\\s+davran\\p{L}*|gibi\\s+davran\\p{L}*|rol[üu]n\\p{L}*)(?!\\p{L})`, "u"), 0.85, DAN_PERSONA],
138
+ // STAN, AIM, DUDE: their spelled-out names; or the acronym with "jailbreak" or "persona" in the same sentence,
139
+ // or with the model told to be one. A bare acronym near "mode", "version" or a number is NOT enough for
140
+ // these three, which is what 0.9.28 and earlier took: the Stan modelling language ("the STAN model": "mode"
141
+ // also matched the start of "model" and "modern"), the AIM stock market and its rule-book versions, "the AIM
142
+ // of this section", a greeting. Nothing in the word itself tells the persona from those.
143
+ // (DUDE is not an acronym; its prompt's own line, "can do anything and everything at the same time", is its name spelled out)
144
+ [/\bstrive\s+to\s+avoid\s+norms\b|\balways\s+intelligent\s+and\s+machiavellian\b|\bdo\s+anything\s+and\s+everything\s+at\s+the\s+same\s+time\b/i, 0.85, OTHER_PERSONA],
145
+ // how their prompts introduce them: "an AI called X", "a character named X", "take on the role of X", "respond as X".
146
+ // The noun before "called" matters: "a market called AIM" and "a language called STAN" are not introductions.
147
+ [/\b([Cc]haracter|[Pp]ersona|[Cc]hatbot|[Bb]ot|[Aa]ssistant|[Aa]lter\s+ego|AI(\s+model)?)\s+(named|called|known\s+as)\s+(STAN|AIM|DUDE)\b|\b(([Tt]ake|[Aa]ssume|[Pp]lay|[Aa]dopt)(\s+on)?\s+the\s+(role|part)\s+of|[Rr]espond(ing)?\s+as|[Aa]nswer(ing)?\s+as|[Rr]ole-?play(ing)?\s+as|[Ss]tay(ing)?\s+as)\s+(STAN|AIM|DUDE)\b|\bDUDE\b(?=[^.\n]{0,80}\b(can\s+do\s+anything|anything\s+and\s+everything)\b)/, 0.85, OTHER_PERSONA],
148
+ // (not after a letter or an apostrophe: PAKİSTAN and KAZAKİSTAN end in the acronym, and İ is no word character to \b)
149
+ [/(?<![\p{L}\p{N}'’])(STAN|AIM|DUDE)\b(?=[^.\n]{0,80}\b([Aa]void\s+[Nn]orms|[Mm]achiavellian|[Jj]ailbreak\w*|[Pp]ersonas?)\b)|\b([Jj]ailbreak\w*|[Pp]ersonas?)\b[^.\n]{0,80}(?<![\p{L}\p{N}'’])(STAN|AIM|DUDE)\b|\b([Yy]ou\s+are|[Yy]ou're|[Aa]ct(ing)?\s+as|[Pp]retend(ing)?\s+to\s+be|[Bb]ecome)\s+(now\s+)?(STAN|AIM|DUDE)\b/u, 0.85, OTHER_PERSONA],
121
150
  // "Developer Mode is enabled" is a Windows setting the os docs need for symlinks; "free version" is pricing
122
- [/\bdo\s+anything\s+now\b|\bdeveloper\s+mode\s+(output|response)s?\b|\b(enable|activate|enter)\s+developer\s+mode\b[^.\n]{0,60}\b(you|your|chatgpt|gpt|ai|assistant|model|claude)\b|\bjailbreak(ed)?\s+mode\b|\b(evil|unrestricted|unfiltered|uncensored)[-\s]?(gpt|ai|assistant|bot|chatbot|response|machine|version\s+of\s+(you|yourself))\b|\bfreed\s+from\s+the\s+(typical\s+)?confines\b|\bmongo\s+tom\b/i, 0.85, "jailbreak persona"],
151
+ [/\bdeveloper\s+mode\s+(output|response)s?\b|\b(enable|activate|enter)\s+developer\s+mode\b[^.\n]{0,60}\b(you|your|chatgpt|gpt|ai|assistant|model|claude)\b|\bjailbreak(ed)?\s+mode\b|\b(evil|unrestricted|unfiltered|uncensored)[-\s]?(gpt|ai|assistant|bot|chatbot|response|machine|version\s+of\s+(you|yourself))\b|\bfreed\s+from\s+the\s+(typical\s+)?confines\b|\bmongo\s+tom\b/i, 0.85, "jailbreak persona"],
123
152
  // "no restrictions" alone is ordinary prose (the Python tutorial); the safety, ethical or content qualifier is the tell
124
153
  [/\b(no|without(\s+any)?|zero|free\s+of)\s+(safety|ethical|content|moral)\s+(restrictions|guardrails|limitations|filters?|guidelines|constraints|polic(y|ies)|measures)\b|(?<!\b(?:if|as\s+long\s+as|so\s+long\s+as|when|whenever|unless|provided|assuming|while|because|since|once|where|that)\s+)\byou\s+(now\s+)?(have|operate\s+with|are\s+under|are\s+bound\s+by)\s+no\s+(restrictions|limitations|limits|rules|guidelines|filters|guardrails)\b(?!\s+(on|in|over|about|for|regarding|around|with|to|as|preventing|stopping|blocking|against)\b)|\b(safety|content)\s+(filters?|guidelines|guardrails|module|classifiers?)\s+(are|is|have\s+been|has\s+been)\s+(now\s+)?(temporarily\s+)?(disabled|suspended|removed|bypassed|corrupted|lifted|deprecated)\b|\b(disable|remove|bypass|turn\s+off|lift|ignore)\s+(all\s+(of\s+)?)?your\s+(safety|content|ethical)\s+(filters?|guidelines|measures|classifiers?|restrictions|checks?|module|guardrails)/i, 0.85, "safety removal"],
125
154
  // bracketed headers that claim a speaker or an authority. Log levels ([CRITICAL]), forum ranks ([Admin]), chat exports
@@ -290,7 +319,7 @@ function isQuotedOrAttributed(text, match) {
290
319
  * or "like" in a request are not quotation. Payload shapes (commands, paths, parameters) are never discounted:
291
320
  * an attack hands its payload over in quotes.
292
321
  */
293
- const UNDISCOUNTED = new Set(["destructive or escalating command", "parameter tampering", "sensitive path", "decode and obey", "fake system or agent header", "fake system message", "tool impersonation", "approval or privilege claim"]);
322
+ const UNDISCOUNTED = new Set([...ALWAYS_REFUSED, "destructive or escalating command", "parameter tampering", "sensitive path", "decode and obey", "fake system or agent header", "fake system message", "tool impersonation", "approval or privilege claim"]);
294
323
  function isQuotedStrict(text, match, label) {
295
324
  if (UNDISCOUNTED.has(label))
296
325
  return false;
@@ -358,8 +387,10 @@ function scoreText(text, hidden, where, findings, inCode = false) {
358
387
  const visibleFactor = asHidden ? 1 : n >= 2 || strong ? 0.75 : 0.55;
359
388
  const severity = asHidden ? 0.9 : n >= 2 || strong ? 0.6 : 0.45;
360
389
  // visible text that quotes or attributes an instruction (news, fiction, training material) is not issuing it
361
- const quotedFactor = !asHidden && (AGENT_LABELS.has(best.label) ? isQuotedStrict(text, best.match, best.label) : isQuotedOrAttributed(text, best.match)) ? 0.55 : 1;
362
- const conf = Math.min(0.98, (best.weight * visibleFactor + boost + Math.min(0.15, (n - 1) * 0.05)) * best.discount * codeFactor * quotedFactor);
390
+ // ...except where the text names one of the jailbreak personas: that is refused wherever it stands, quoted or in a code block
391
+ const namesDan = hits.some((h) => ALWAYS_REFUSED.has(h.label));
392
+ const quotedFactor = !namesDan && !asHidden && (AGENT_LABELS.has(best.label) ? isQuotedStrict(text, best.match, best.label) : isQuotedOrAttributed(text, best.match)) ? 0.55 : 1;
393
+ const conf = Math.min(0.98, (best.weight * visibleFactor + boost + Math.min(0.15, (n - 1) * 0.05)) * best.discount * (namesDan ? 1 : codeFactor) * quotedFactor);
363
394
  findings.push({
364
395
  pass: "meaning", kind: n >= 3 || /system\s+prompt/i.test(best.match) ? "meaning.system_prompt_imitation" : "meaning.instruction_shaped",
365
396
  confidence: conf, severity,
@@ -404,10 +435,16 @@ function scoreText(text, hidden, where, findings, inCode = false) {
404
435
  // tokens are symbol-laced as a matter of course, and four ordinary emails in three thousand were refused for it.
405
436
  // In those channels a visible suffix is weak evidence: it counts beside something else, never alone.
406
437
  if (!inCode) {
407
- const sfx = adversarialSuffix(text);
438
+ // In JSON the visible text is its values joined, and the suffix test read the last value as a suffix on the
439
+ // values before it: a short ordinary value with a few symbols in it, last in a document, was refused (55 of
440
+ // 4,615 benign public texts, as the last value after thirty rows). A suffix is appended to a prompt, so in
441
+ // JSON each value is tested as a text of its own, wherever it stands (0.9.30). And values are option names,
442
+ // identifiers and placeholders as a matter of course (a compiler's message catalogue has thousands that end
443
+ // in three of them), so in JSON a visible suffix is weak evidence, as in a message or a log.
444
+ const sfx = !hidden && valueTexts ? valueTexts.map(adversarialSuffix).find((x) => x) ?? null : adversarialSuffix(text);
408
445
  if (sfx)
409
446
  findings.push({
410
- pass: "meaning", kind: "meaning.adversarial_suffix", confidence: hidden ? 0.7 : SUFFIX_WEAK.has(channelKind) ? 0.3 : 0.55, severity: 0.6,
447
+ pass: "meaning", kind: "meaning.adversarial_suffix", confidence: hidden ? 0.7 : SUFFIX_WEAK.has(channelKind) || valueTexts ? 0.3 : 0.55, severity: 0.6,
411
448
  message: `optimizer-style adversarial suffix: ${sfx.weird} of the last ${sfx.tokens} tokens are symbol-laced fragments after ordinary prose (GCG-style jailbreak)`,
412
449
  excerpt: sfx.tail.slice(-120), location: where, inHidden: hidden, action: "neutralized",
413
450
  });
@@ -505,6 +542,8 @@ function adversarialSuffix(text) {
505
542
  const SUFFIX_WEAK = new Set(["email", "log", "calendar", "message", "notification"]);
506
543
  /** the kind of the content being scanned; set for the duration of one scanMeaning call (the pass is synchronous) */
507
544
  let channelKind = "";
545
+ /** in JSON, the delivered values one by one: what the suffix test reads in place of the joined text (same lifetime) */
546
+ let valueTexts;
508
547
  export function scanMeaning(input) {
509
548
  channelKind = input.kind ?? "";
510
549
  try {
@@ -512,6 +551,7 @@ export function scanMeaning(input) {
512
551
  }
513
552
  finally {
514
553
  channelKind = "";
554
+ valueTexts = undefined;
515
555
  }
516
556
  }
517
557
  function scanMeaningInner(input) {
@@ -525,6 +565,7 @@ function scanMeaningInner(input) {
525
565
  // code blocks are scored separately with the documentation discount
526
566
  const codeBlocks = [...(visibleRaw.match(FENCED) ?? []), ...delivered.filter(inPre).map((s) => s.text)];
527
567
  const visible = visibleRaw.replace(FENCED, " ");
568
+ valueTexts = input.kind === "json" && delivered.length > 1 ? delivered.map((s) => s.text) : undefined;
528
569
  if (visible.trim()) {
529
570
  scoreText(visible, false, "visible text", findings);
530
571
  // a foreign-language article quoting the phrase is reporting it, the same discount English gets
@@ -5,9 +5,9 @@
5
5
  * at the same source would not see is suspect by default.
6
6
  */
7
7
  import type { NetPolicy } from "./netpolicy.js";
8
- export declare const ENGINE_VERSION = "0.9.28";
8
+ export declare const ENGINE_VERSION = "0.9.30";
9
9
  /** bump whenever a detector's behavior changes; receipts carry it so verdicts are reproducible */
10
- export declare const RULESET_VERSION = "2026.11.21-1";
10
+ export declare const RULESET_VERSION = "2026.11.21-3";
11
11
  /**
12
12
  * clean: delivered. suspect: refused, overridable. hostile: refused, not overridable.
13
13
  * unreachable: nothing could be fetched or read (network error, timeout, redirect loop,
package/dist/src/types.js CHANGED
@@ -4,9 +4,9 @@
4
4
  * Governing principle: anything the model would receive that a human looking
5
5
  * at the same source would not see is suspect by default.
6
6
  */
7
- export const ENGINE_VERSION = "0.9.28";
7
+ export const ENGINE_VERSION = "0.9.30";
8
8
  /** bump whenever a detector's behavior changes; receipts carry it so verdicts are reproducible */
9
- export const RULESET_VERSION = "2026.11.21-1";
9
+ export const RULESET_VERSION = "2026.11.21-3";
10
10
  export const CONTENT_KINDS = ["html", "markdown", "json", "text", "javascript", "log", "email", "calendar", "message", "notification", "nearby", "automation", "captions", "image", "audio", "video"];
11
11
  /** Read a content kind and source from untyped input (an HTTP body, tool arguments). Unknown values are dropped, never guessed. */
12
12
  export function parseScanHints(o) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acepaste/ingress",
3
- "version": "0.9.28",
3
+ "version": "0.9.30",
4
4
  "description": "AcePaste Ingress engine: acquire, visibility, character, script, supply-chain, sandbox, meaning, verdict, envelope, receipts.",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",