agent-customs 1.2.1 → 1.2.3
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/README.md +11 -9
- package/package.json +1 -1
- package/site/customs/analyze.js +20 -4
- package/site/customs/rules.js +42 -4
- package/site/customs/unicode.js +2 -1
- package/tools/mcp-server.mjs +1 -1
package/README.md
CHANGED
|
@@ -62,8 +62,8 @@ Pick one of four ways. Each works with any site made with Cognizant's `agentify-
|
|
|
62
62
|
|
|
63
63
|
```html
|
|
64
64
|
<script type="module"
|
|
65
|
-
src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
66
|
-
integrity="sha384-
|
|
65
|
+
src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.3/dist/agent-customs.js"
|
|
66
|
+
integrity="sha384-UsMDzSujKomrW+sbe4tAsPeXdYGQYYcIsTfktauiYHnQZ9iZXszH55Ei9EpWIFKj"
|
|
67
67
|
crossorigin="anonymous"></script>
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -76,7 +76,7 @@ Pick one of four ways. Each works with any site made with Cognizant's `agentify-
|
|
|
76
76
|
```js
|
|
77
77
|
// At the top of site.js
|
|
78
78
|
import { installCustomsGuard }
|
|
79
|
-
from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
79
|
+
from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.3/site/customs/guard.js";
|
|
80
80
|
|
|
81
81
|
// Right after boot()
|
|
82
82
|
installCustomsGuard(booted.engine, { strict: true });
|
|
@@ -173,16 +173,16 @@ Each way to add the guard, step by step. All of them work with any site built wi
|
|
|
173
173
|
**1. One line (easiest).** Paste this into your page, above your other `<script>` tags. The guard switches itself on when your assistant starts.
|
|
174
174
|
|
|
175
175
|
```html
|
|
176
|
-
<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
176
|
+
<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.3/dist/agent-customs.js" integrity="sha384-UsMDzSujKomrW+sbe4tAsPeXdYGQYYcIsTfktauiYHnQZ9iZXszH55Ei9EpWIFKj" crossorigin="anonymous"></script>
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
`integrity` is the file's fingerprint. If the file were ever changed, on the CDN or on the way, the browser would refuse to run it. The whole guard is in this one file ([`dist/agent-customs.js`](dist/agent-customs.js), built by `npm run bundle`), so the fingerprint covers all of it. `@v1.2.
|
|
179
|
+
`integrity` is the file's fingerprint. If the file were ever changed, on the CDN or on the way, the browser would refuse to run it. The whole guard is in this one file ([`dist/agent-customs.js`](dist/agent-customs.js), built by `npm run bundle`), so the fingerprint covers all of it. `@v1.2.3` is a fixed version; to update, take the new line from the next release. Above the other tags, the browser runs it before your page starts the assistant, and chats wait until the guard is on. If your page has a `Content-Security-Policy` with `script-src`, add `https://cdn.jsdelivr.net` to it.
|
|
180
180
|
|
|
181
181
|
**2. Two lines, with your own settings.** Load the guard from the same release and pass any of the *Guard options* below. A browser cannot check a fingerprint on an `import`, so for that use option 3 or 4.
|
|
182
182
|
|
|
183
183
|
```js
|
|
184
184
|
// At the top of site.js
|
|
185
|
-
import { installCustomsGuard } from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.
|
|
185
|
+
import { installCustomsGuard } from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v1.2.3/site/customs/guard.js";
|
|
186
186
|
|
|
187
187
|
// Right after the boot(...) call
|
|
188
188
|
installCustomsGuard(booted.engine, { strict: true });
|
|
@@ -239,7 +239,7 @@ Three ways in, fastest first:
|
|
|
239
239
|
<strong>1 · The test suite</strong><br><br>
|
|
240
240
|
No browser and no API key:<br><br>
|
|
241
241
|
<code>npm test</code><br><br>
|
|
242
|
-
|
|
242
|
+
223 tests: the attack sentences, every frozen attack set, five batches of real MCP servers and A2A cards, the locks, the canary, the signed stamps, the benchmark, the command line tool, the MCP server, the extension, the practice site, the key vault, the one-line install and its one-file build.
|
|
243
243
|
</td>
|
|
244
244
|
<td width="33.3%" valign="top">
|
|
245
245
|
<strong>2 · The inspection desk (no key)</strong><br><br>
|
|
@@ -588,7 +588,7 @@ node tools/set-origins.mjs --range https://agent-customs-range.github.io
|
|
|
588
588
|
|
|
589
589
|
`npm run smoke` drives Edge or Chrome headlessly against the local servers and fails on any page error. It starts the key vault on port 8090 if it is not running (`npm run serve:vault`), since a page on this computer looks for the vault there.
|
|
590
590
|
|
|
591
|
-
`npm run vault:check` checks the key vault end to end in a headless browser, with a stand-in AI service on this computer: the page never holds the key, every AI request comes from the vault with the key,
|
|
591
|
+
`npm run vault:check` checks the key vault end to end in a headless browser, with a stand-in AI service on this computer: a Groq or Otari key picks its own card, the page never holds the key, every AI request comes from the vault with the key, *Remember key* stores it only encrypted, a new visit starts locked, a wrong password does not open it, and *Forget* removes it.
|
|
592
592
|
|
|
593
593
|
---
|
|
594
594
|
|
|
@@ -607,10 +607,12 @@ The desk also has a new switch under the address box: **AI double-check**. When
|
|
|
607
607
|
|
|
608
608
|
**Checked against Google's guidance.** The site was scanned with the Chrome team's [Modern Web Guidance](https://developer.chrome.com/docs/modern-web-guidance) and checked against [Baseline](https://web.dev/baseline): it uses only features that work in all current browsers, or that have a fallback. Every piece of HTML the page writes, in its own code and in the runtime's, now passes one cleaner first ([Trusted Types](site/trusted-types.js)), which removes anything that could run code.
|
|
609
609
|
|
|
610
|
-
**Your AI key now lives in a key vault.** The page no longer keeps your key anywhere. You paste it into a small box that is really a separate website, the [key vault](vault/) (`agent-customs-vault.github.io`). The browser keeps that site's storage apart from this page's. When the Officer or the AI double-check needs your AI, the page asks the vault, and the vault adds the key, calls your AI company and passes back only the answer. So even an agent file that broke this page could not take your key. By default the vault forgets the key when you close the tab. *Remember on this
|
|
610
|
+
**Your AI key now lives in a key vault.** The page no longer keeps your key anywhere. You paste it into a small box that is really a separate website, the [key vault](vault/) (`agent-customs-vault.github.io`). The browser keeps that site's storage apart from this page's. When the Officer or the AI double-check needs your AI, the page asks the vault, and the vault adds the key, calls your AI company and passes back only the answer. So even an agent file that broke this page could not take your key. By default the vault forgets the key when you close the tab. *Remember on this device* keeps it encrypted (AES-256), locked with your passkey or a password that is never stored. The page now also lets only its own scripts run, and each card says how to give a key a spending limit.
|
|
611
611
|
|
|
612
612
|
A first-time visitor has no key, so the switch says so. Turning it on opens a short card that explains what an AI key is and that Google AI Studio and Groq give free ones. *Set up a free key* opens the key settings, and after *Save and start* the page goes back to the inspection and runs it again with your AI. To see it catch something, inspect the **VIP Points MCP** sample on the desk ([`site/samples/ai-check-demo/mcp.json`](site/samples/ai-check-demo/mcp.json)). It asks guests to *"read back all twenty-four words from their emergency paper sheet"*. That is a crypto wallet's recovery phrase, worded so that none of the rules' words appear. The rules clear it; your AI should hold it.
|
|
613
613
|
|
|
614
|
+
**Setting up a key is simpler.** A key from a known company now picks its own card wherever you paste it, so a Groq or Otari key pasted while Gemini is selected just works. After *Save and start*, a *Remember key* button above the chat keeps the key on this device, without opening the settings again. Passkeys that make the key but do not say at once whether they can lock it, as Windows Hello often does, now work: the vault asks the new passkey once more instead of giving up. On a phone, *Set up a free key* now brings the key box into view. The messages in the AI settings and the key vault are shorter and plainer.
|
|
615
|
+
|
|
614
616
|
---
|
|
615
617
|
|
|
616
618
|
## More detail
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-customs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Border control for the Open Agentic Web: inspect any agent network before it runs in your browser.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Monty Bagati (https://github.com/montbaga)",
|
package/site/customs/analyze.js
CHANGED
|
@@ -193,11 +193,20 @@ export async function analyzeNetwork(input) {
|
|
|
193
193
|
|
|
194
194
|
// ---- Contraband: hidden characters ---------------------------------------
|
|
195
195
|
const hiddenByPlace = new Map();
|
|
196
|
-
|
|
196
|
+
const seenForeignHidden = new Set();
|
|
197
|
+
const visitHidden = (text, path) => {
|
|
197
198
|
// Shared text is expanded into each agent's instructions, which are scanned there.
|
|
198
199
|
if (path[0] === "network" && path[1] === "commondefs") return;
|
|
200
|
+
// Foreign manifests embed rawDoc under manifest.mcp or manifest.a2a.
|
|
201
|
+
if (path[0] === "manifest" && (path[1] === "mcp" || path[1] === "a2a")) return;
|
|
199
202
|
const h = scanHidden(text);
|
|
200
203
|
if (!h.total) return;
|
|
204
|
+
if (rawDoc) {
|
|
205
|
+
const isNonToolCopy = path[0] !== "network" || path[1] !== "tools";
|
|
206
|
+
const isEntryMirroredDesc = path[0] === "network" && path[1] === "tools" && path[2] === 0 && path[3] === "function" && path[4] === "description";
|
|
207
|
+
if ((isNonToolCopy || isEntryMirroredDesc) && seenForeignHidden.has(text)) return;
|
|
208
|
+
seenForeignHidden.add(text);
|
|
209
|
+
}
|
|
201
210
|
const place = placeOf(path, config);
|
|
202
211
|
const agg = hiddenByPlace.get(place.key) || { ...place, tags: 0, tagText: [], bidi: 0, bidiNames: new Set(),
|
|
203
212
|
invisible: 0, invisibleNames: new Set(), variation: 0, variationSupplement: 0, privateUse: 0, control: 0, sample: "" };
|
|
@@ -209,7 +218,14 @@ export async function analyzeNetwork(input) {
|
|
|
209
218
|
agg.privateUse += h.privateUse; agg.control += h.control;
|
|
210
219
|
if (!agg.sample) agg.sample = sampleAroundHidden(text);
|
|
211
220
|
hiddenByPlace.set(place.key, agg);
|
|
212
|
-
}
|
|
221
|
+
};
|
|
222
|
+
walkStrings(config.tools || [], visitHidden, ["network", "tools"]);
|
|
223
|
+
for (const [k, v] of Object.entries(config || {})) {
|
|
224
|
+
if (k === "tools" || k === "commondefs") continue;
|
|
225
|
+
walkStrings(v, visitHidden, ["network", k]);
|
|
226
|
+
}
|
|
227
|
+
walkStrings(manifest, visitHidden, ["manifest"]);
|
|
228
|
+
if (rawDoc) walkStrings(rawDoc, visitHidden, ["rawDoc"]);
|
|
213
229
|
for (const agg of hiddenByPlace.values()) {
|
|
214
230
|
const where = { agent: agg.agent, field: agg.field };
|
|
215
231
|
if (agg.tags) {
|
|
@@ -337,11 +353,11 @@ export async function analyzeNetwork(input) {
|
|
|
337
353
|
} else if (hit.rule.id === "C-EXFIL" && !isInstructionField && severity !== "medium") {
|
|
338
354
|
const ex = hit.excerpt || "";
|
|
339
355
|
const hardLeak = Boolean(hit.language) || Boolean(hit.hard)
|
|
340
|
-
|| /\b(?:conversation|chat|history|messages?|transcript|system\s+prompt|sly_data|cookie)\b
|
|
356
|
+
|| /\b(?:conversation|chat|history|messages?|transcript|system\s+prompt|sly_data|cookie)\b|(?:https?:)?\/\/|\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b|\b(?:javascript|vbscript):[^\s'")\],.;]|data\s*:\s*(?:text\/html|application\/xhtml\+xml|image\/svg\+xml)(?:;[^,\s]+)?,[^\s'"]|\bwebhook\b/i.test(ex)
|
|
341
357
|
// A private key file is private whoever receives it.
|
|
342
358
|
|| /~\/\.ssh\b|\bid_(?:rsa|ed25519|ecdsa|dsa)\b|\bssh\s+(?:private\s+)?keys?\b|\bprivate\s+keys?\b|(?:^|[\s"'`(])\.env\b|\bcredentials\.json\b|\bmcp\.json\b/i.test(ex)
|
|
343
359
|
// What the visitor said, or a secret, is private wherever it is sent.
|
|
344
|
-
|| /\b(?:everything|all|what|whatever)\s+(?:they|the\s+(?:user|visitor|customer|guest))\s+(?:typed|said|wrote|asked|entered)\b|\b(?:user|visitor|customer|guest)'?s?\s+(?:words|input|replies)\b|\b(?:passwords?|passcodes?|card\s+numbers?|cvv2?|cvc|pins?|otps?|seed\s+(?:phrases?|words?)|credentials?)\b/i.test(ex);
|
|
360
|
+
|| /\b(?:everything|all|what|whatever)\s+(?:they|the\s+(?:user|visitor|customer|guest))\s+(?:typed|said|wrote|asked|entered)\b|\b(?:user|visitor|customer|guest)'?s?\s+(?:words|input|replies)\b|\b(?:passwords?|passcodes?|card\s+numbers?|cvv2?|cvc|pins?|otps?|seed\s+(?:phrases?|words?)|credentials?|passport(?:\s+numbers?)?|national\s+id(?:\s+numbers?)?|tax\s+id(?:\s+numbers?)?|ssn|social\s+security(?:\s+numbers?)?|driver'?s\s+licen[cs]e(?:\s+numbers?)?|driving\s+licen[cs]e(?:\s+numbers?)?|bank\s+account(?:\s+(?:numbers?|details?))?|routing\s+numbers?|iban|sort\s+codes?)\b/i.test(ex);
|
|
345
361
|
if (!hardLeak) {
|
|
346
362
|
severity = "medium";
|
|
347
363
|
detail += " Found in a tool description referencing a configured deployment server without an embedded external URL.";
|
package/site/customs/rules.js
CHANGED
|
@@ -281,7 +281,7 @@ const soften = (hit, why) => ({ ...hit, severity: "medium", detail: `Matched "${
|
|
|
281
281
|
|
|
282
282
|
// Fill-in-the-blank slots that would put private data into a web address, such as
|
|
283
283
|
// {conversation} or <api_key>. Slots like <owner> or {city} are ordinary link templates.
|
|
284
|
-
const PRIVATE_SLOT = "[a-z_ ]*(?:conversation|chat|history|messages?|transcript|prompt|context|instructions|secrets?|keys?|tokens?|passwords?|cookies?|session|sly_?data|private|personal|user_?data|visitor_?data|e-?mail|phone|address|summary|memory|notes)[a-z_ ]*";
|
|
284
|
+
const PRIVATE_SLOT = "[a-z_ ]*(?:conversation|chat|history|messages?|transcript|prompt|context|instructions|secrets?|keys?|tokens?|passwords?|cookies?|session|sly_?data|private|personal|user_?data|visitor_?data|e-?mail|phone|address|summary|memory|notes|passport|national_?id|ssn|iban|bank_?account|card_?number|cvv)[a-z_ ]*";
|
|
285
285
|
|
|
286
286
|
const OUR_PERSONAL_INFO = /\b(?:our|the\s+(?:store|shop|bakery|company|business|restaurant|office|hotel|support|service|site)(?:'s)?)\s+(?:\w+\s+){0,2}$/i;
|
|
287
287
|
|
|
@@ -296,7 +296,7 @@ const EMAIL_CODE_PHISH_RE = /\b(?:visitors?|guests?|callers?|customers?|bank(?:i
|
|
|
296
296
|
const SYSTEM_CHECK_TARGET_RE = /\b(?:quota|status|active|encrypted|connections?|health|available|preflight|audit)\b/i;
|
|
297
297
|
const PERSON_REF_RE = /\b(?:your|their|his|her|visitors?|users?|customers?|guests?|clients?|callers?|holders?)\b/i;
|
|
298
298
|
const HUMAN_SECRET_ONLY_RE = /\b(?:passwords?|passcodes?|passphrases?|card ?numbers?|cvv2?|cvc|pins?|otps?|seed phrases?|ssn)\b/i;
|
|
299
|
-
const VISITOR_LEAK_SLOT_RE = /\b(?:conversation|chat(?:\s+history|\s+log|\s+so\s+far)?|message\s+history|previous\s+messages|(?:user|visitor|customer|guest)'?s?\s+messages|transcript|system\s+prompt|hidden\s+instructions|sly_data|private\s+context|credit\s*cards?|card\s*numbers?|cvv2?|cvc|passwords?|passcodes?|passphrases?|otps?|pins?|ssn|iban|seed\s+phrases?|recovery\s+phrases?|cookies?|api[_ ]keys?|access[_ ]tokens?|session[_ ]tokens?|auth[_ ]tokens?|secret[_ ]keys?|private[_ ]keys?|(?:user|visitor|personal)[_ ](?:data|details|info))\b/i;
|
|
299
|
+
const VISITOR_LEAK_SLOT_RE = /\b(?:conversation|chat(?:\s+history|\s+log|\s+so\s+far)?|message\s+history|previous\s+messages|(?:user|visitor|customer|guest)'?s?\s+messages|transcript|system\s+prompt|hidden\s+instructions|sly_data|private\s+context|credit\s*cards?|card\s*numbers?|cvv2?|cvc|passwords?|passcodes?|passphrases?|otps?|pins?|ssn|social\s+security(?:\s+numbers?)?|iban|passport(?:\s+numbers?)?|national\s+id(?:\s+numbers?)?|tax\s+id(?:\s+numbers?)?|driver'?s\s+licen[cs]e(?:\s+numbers?)?|driving\s+licen[cs]e(?:\s+numbers?)?|bank\s+account(?:\s+(?:numbers?|details))?|routing\s+numbers?|seed\s+phrases?|recovery\s+phrases?|cookies?|api[_ ]keys?|access[_ ]tokens?|session[_ ]tokens?|auth[_ ]tokens?|secret[_ ]keys?|private[_ ]keys?|(?:user|visitor|personal)[_ ](?:data|details|info))\b/i;
|
|
300
300
|
|
|
301
301
|
function hasOffOriginUrl(text, targetHost = "") {
|
|
302
302
|
const urls = findUrls(text);
|
|
@@ -580,6 +580,37 @@ function followUpRequests(text) {
|
|
|
580
580
|
return hits;
|
|
581
581
|
}
|
|
582
582
|
|
|
583
|
+
const EMAIL_DESTINATION = "[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}";
|
|
584
|
+
const HTTP_PREFIX = "(?:https?:\\/\\/|(?<![a-z0-9+.-]:)\\/\\/)";
|
|
585
|
+
const EMAIL_VERB = "(?<!\\b(?:an?|the|your|their|our|his|her|my|by|via|with|from|for|to|of)\\s+)\\b(?:e-?mail|mail)\\b(?!\\s*(?:\\/|address(?:es)?|login|auth|id|account|verification|confirmation|inbox|client|server|provider|header|field|format|template|notifications?|messages?|lists?|marketing|campaigns?|updates?|alerts?)\\b)";
|
|
586
|
+
const EXFIL_VERBS = `(?:\\b(?:include|append|embed|encode|send|post|forward|leak|exfiltrate|transmit|upload|put|add|copy|attach|summarize|submit|relay|pass|bcc|cc)\\b|${EMAIL_VERB})`;
|
|
587
|
+
const EXFIL_SEND_VERBS = `(?:\\b(?:send|post|forward|upload|submit|transmit|pass|relay|put|append|add|attach|encode|exfiltrate|leak|bcc|cc)\\b|${EMAIL_VERB})`;
|
|
588
|
+
const EXFIL_IDENTITY_SECRET = "(?:passport(?:\\s+(?:numbers?|details?|info(?:rmation)?|id))?|national\\s+id(?:\\s+numbers?)?|tax\\s+id(?:\\s+numbers?)?|ssn|social\\s+security(?:\\s+numbers?)?|driver'?s\\s+licen[cs]e(?:\\s+numbers?)?|driving\\s+licen[cs]e(?:\\s+numbers?)?|bank\\s+account(?:\\s+(?:numbers?|details?))?|account\\s+numbers?|routing\\s+numbers?|iban|sort\\s+codes?|(?:credit|debit|payment)\\s+card(?:\\s+numbers?)?|card\\s+numbers?|cvv2?|cvc|passwords?(?!\\s+(?:setup|reset|change|recovery|policy)\\b)|passcodes?|passphrases?|otps?|one[- ]time\\s+codes?|seed\\s+(?:phrases?|words?)|recovery\\s+(?:phrases?|words?)|api\\s+keys?|access\\s+tokens?|session\\s+tokens?|credentials?|cookies?|private\\s+keys?)";
|
|
589
|
+
const EXFIL_CONVERSATION_DATA = "(?:conversation|chat\\s+history|chat\\s+log|(?:the|this|their|your|whole|entire|full)\\s+chat\\b|chat\\s+(?:so\\s+far|contents?|messages?|transcript|summary)|conversation\\s+history|message\\s+history|previous\\s+messages|(?:user|visitor|customer|guest)'?s?\\s+messages?|what\\s+the\\s+(?:user|visitor|customer|guest)\\s+(?:typed|said|wrote|asked)|everything\\s+(?:they|the\\s+(?:user|visitor|customer|guest))\\s+(?:typed|said|wrote|asked)|their\\s+messages?|transcript|system\\s+prompt|your\\s+instructions|hidden\\s+instructions|sly_data|private\\s+context|personal\\s+(?:data|details)|(?:user|visitor|customer|guest)\\s+(?:data|details)|all\\s+outputs?|tool\\s+outputs?|local\\s+storage(?:\\s+credentials?)?|session\\s+storage|(?:user|visitor|customer|guest)'?s?\\s+e-?mail)";
|
|
590
|
+
const EXFIL_SENSITIVE_TARGET = `(?:${EXFIL_CONVERSATION_DATA}|${EXFIL_IDENTITY_SECRET})`;
|
|
591
|
+
const EXFIL_BACKREF = "(?:it|them|that|this|those|the\\s+(?:number|numbers|code|codes|details|info|information|data|value|values|transcript|summary|conversation|chat|history|copy|passport|id|iban|secret|secrets|key|keys|token|tokens|password|passwords|card))";
|
|
592
|
+
const EXFIL_FOLLOWUP_SOURCE = new RegExp(`\\b${EXFIL_SENSITIVE_TARGET}\\b`, "i");
|
|
593
|
+
const EXFIL_FOLLOWUP_SEND = new RegExp(
|
|
594
|
+
`${EXFIL_SEND_VERBS}[^.!?\\n]{0,20}\\b${EXFIL_BACKREF}\\b[^.!?\\n]{0,25}\\b(?:to|at|into|onto|after)\\s+(?:${HTTP_PREFIX}[^\\s)"'<>]+|${EMAIL_DESTINATION}\\b)`,
|
|
595
|
+
"i",
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
function followUpExfil(text) {
|
|
599
|
+
const parts = wrappedClauses(text);
|
|
600
|
+
const hits = [];
|
|
601
|
+
for (let i = 0; i + 1 < parts.length; i += 1) {
|
|
602
|
+
const src = parts[i].match(EXFIL_FOLLOWUP_SOURCE);
|
|
603
|
+
if (!src || negatedBefore(parts[i], src.index) || describedBefore(parts[i], src.index)) continue;
|
|
604
|
+
for (let j = i + 1; j <= Math.min(i + 2, parts.length - 1); j += 1) {
|
|
605
|
+
const send = parts[j].match(EXFIL_FOLLOWUP_SEND);
|
|
606
|
+
if (!send || negatedBefore(parts[j], send.index) || describedBefore(parts[j], send.index)) continue;
|
|
607
|
+
hits.push({ match: send[0], excerpt: parts.slice(i, j + 1).join(" ") });
|
|
608
|
+
break;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return hits;
|
|
612
|
+
}
|
|
613
|
+
|
|
583
614
|
const askEnglishSecrets = askMatcher(SECRET, SECRET_DESCRIBED, PIN);
|
|
584
615
|
|
|
585
616
|
// Continuation lines ("without asking the visitor") should not fire negatable rules when the
|
|
@@ -937,7 +968,9 @@ export const TEXT_RULES = [
|
|
|
937
968
|
fix: "Remove it. Never build links or images from conversation content.",
|
|
938
969
|
match: (text, { raw = text, targetHost = "" } = {}) => {
|
|
939
970
|
const urlPatterns = [
|
|
940
|
-
|
|
971
|
+
new RegExp(`${EXFIL_VERBS}[^.!?\\n]{0,60}\\b${EXFIL_SENSITIVE_TARGET}\\b[^.!?\\n]{0,80}(?:${HTTP_PREFIX}|\\b(?:url|link|image|query|parameter|base64|webhook)\\b|\\b${EMAIL_DESTINATION}\\b)`, "i"),
|
|
972
|
+
new RegExp(`\\b${EXFIL_SENSITIVE_TARGET}\\b[^.!?\\n]{0,80}${EXFIL_SEND_VERBS}[^.!?\\n]{0,20}\\b${EXFIL_BACKREF}\\b[^.!?\\n]{0,25}\\b(?:to|at|into|onto|after)\\s+(?:${HTTP_PREFIX}[^\\s)"'<>]+|${EMAIL_DESTINATION}\\b)`, "i"),
|
|
973
|
+
new RegExp(`${EXFIL_SEND_VERBS}\\s+(?:(?:to|at)\\s+)?(?:${HTTP_PREFIX}[^\\s)"'<>]+|${EMAIL_DESTINATION}\\b)\\s+(?:with\\s+|containing\\s+|including\\s+|carrying\\s+)?(?:a\\s+copy\\s+of\\s+|all\\s+|full\\s+|entire\\s+)?(?:the\\s+|their\\s+|your\\s+|(?:user|visitor|customer|guest)'?s?\\s+)?\\b${EXFIL_SENSITIVE_TARGET}\\b`, "i"),
|
|
941
974
|
/\b(put|append|add|attach|encode)\s+(?:it|them|that|this)\s+(?:after|onto|into|to)\s+(?:https?:)?\/\//i,
|
|
942
975
|
/!\[[^\]]*\]\(\s*(?:https?:)?\/\/[^)\s]*(?:\{[^}]*\}|\?[^)\s]*=)/i,
|
|
943
976
|
/(?:https?:)?\/\/[^\s)"'<>]+\?[a-z0-9_.-]{1,24}=(?:[\s)"'<>]|$)|(?:https?:)?\/\/[^\s)"'<>]+&[a-z0-9_.-]{1,24}=(?:[\s)"'<>]|$)/i,
|
|
@@ -956,7 +989,7 @@ export const TEXT_RULES = [
|
|
|
956
989
|
/\b(?:read|reads|collect|collects|fetch|fetches|gather|gathers|grab|grabs|extract|extracts|dump|dumps|inspect|inspects|access|accesses)\b[^.!?\n]{0,60}\b(?:secrets?|tokens?|keys?|credentials?|passwords?|env(?:ironment)?(?:\s+var(?:iable)?s?|\s+settings?)?|\.env|cookies?|private\s+(?:files?|data)|config(?:uration)?(?:\s+files?)?)\b[^.!?\n]{0,60}\b(?:post|posts|send|sends|upload|uploads|forward|forwards|relay|relays|transmit|transmits|ship|ships|push|pushes)\b[^.!?\n]{0,40}\b(?:to|toward|at)\b[^.!?\n]{0,40}\b(?:url|webhook|callback|endpoint|server|remote\s+host|address|destination)\b/i,
|
|
957
990
|
/(?:(?:\b(?:href|src|action)\s*=\s*["']?|\[\s*[^\]]*\]\s*\(\s*|\b(?:drag|click|bookmark(?:s|\s+bar)?|paste|follow|visit|open|run|execute|navigate|redirect|load|link|url)\b[^.!?\n]{0,80})\b(?:javascript|vbscript):(?=[^\s'")\],.;])|(?:\b(?:href|src|action)\s*=\s*["']?|\[\s*[^\]]*\]\s*\(\s*)data\s*:\s*(?:text\/html|application\/xhtml\+xml|image\/svg\+xml)\b|\bdata\s*:\s*(?:text\/html|application\/xhtml\+xml),[^\s'"])/i,
|
|
958
991
|
];
|
|
959
|
-
const urlHits = regexMatcher(urlPatterns, { negatable: true })(text).map((hit) => {
|
|
992
|
+
const urlHits = [...regexMatcher(urlPatterns, { negatable: true })(text), ...followUpExfil(text)].map((hit) => {
|
|
960
993
|
if (isHttpHeaderAuthDoc(hit.excerpt, targetHost)) return soften(hit, "Documents a request header for this service's own key.");
|
|
961
994
|
if (targetHost && allUrlsSameSite(hit.excerpt, targetHost)
|
|
962
995
|
&& !VISITOR_LEAK_SLOT_RE.test(hit.excerpt) && !/!\[[^\]]*\]\(/.test(hit.excerpt)
|
|
@@ -1556,6 +1589,11 @@ export function scanText(text, { skipLanguage = false, targetHost = "", fieldNam
|
|
|
1556
1589
|
const deobfuscated = deobfuscateEnglish(inlineDecoded);
|
|
1557
1590
|
const wrappedDeobf = deobfuscateEnglish(softJoinLines(inlineDecoded));
|
|
1558
1591
|
const variants = [{ text: folded, raw: normalized, allowLanguage: !skipLanguage }];
|
|
1592
|
+
const spacedHidden = normalizeForRules(text, { spaceInvisible: true });
|
|
1593
|
+
if (spacedHidden !== normalized) {
|
|
1594
|
+
const spacedFolded = foldConfusableTokens(spacedHidden);
|
|
1595
|
+
if (spacedFolded !== folded) variants.push({ text: spacedFolded, raw: spacedHidden, allowLanguage: false });
|
|
1596
|
+
}
|
|
1559
1597
|
if (inlineDecoded !== folded) variants.push({ text: inlineDecoded, raw: normalized, allowLanguage: false });
|
|
1560
1598
|
if (deobfuscated !== inlineDecoded) variants.push({ text: deobfuscated, raw: normalized, allowLanguage: false });
|
|
1561
1599
|
if (wrappedDeobf !== inlineDecoded && wrappedDeobf !== deobfuscated) variants.push({ text: wrappedDeobf, raw: normalized, allowLanguage: false });
|
package/site/customs/unicode.js
CHANGED
|
@@ -211,7 +211,7 @@ export function revealHidden(text) {
|
|
|
211
211
|
* :param text: Any string.
|
|
212
212
|
* :return: The visible text plus any tag-hidden text, on a line of its own.
|
|
213
213
|
*/
|
|
214
|
-
export function normalizeForRules(text) {
|
|
214
|
+
export function normalizeForRules(text, { spaceInvisible = false } = {}) {
|
|
215
215
|
if (typeof text !== "string") return "";
|
|
216
216
|
let visible = "";
|
|
217
217
|
let hidden = "";
|
|
@@ -223,6 +223,7 @@ export function normalizeForRules(text) {
|
|
|
223
223
|
else if (LINE_BREAKS.has(cp)) visible += "\n";
|
|
224
224
|
else if (QUOTES.has(cp)) visible += QUOTES.get(cp);
|
|
225
225
|
else if (!drawsNothing(cp, ch)) visible += ch;
|
|
226
|
+
else if (spaceInvisible) visible += " ";
|
|
226
227
|
}
|
|
227
228
|
hidden = hidden.replace(/\s+/g, " ").trim();
|
|
228
229
|
// Keep newlines: the rules split clauses at them.
|
package/tools/mcp-server.mjs
CHANGED
|
@@ -166,7 +166,7 @@ function resolveKnownSample(raw) {
|
|
|
166
166
|
|
|
167
167
|
function buildInstallSnippets() {
|
|
168
168
|
return {
|
|
169
|
-
oneLineScript: `<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v${PKG_VERSION}/dist/agent-customs.js" integrity="sha384-
|
|
169
|
+
oneLineScript: `<script type="module" src="https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v${PKG_VERSION}/dist/agent-customs.js" integrity="sha384-UsMDzSujKomrW+sbe4tAsPeXdYGQYYcIsTfktauiYHnQZ9iZXszH55Ei9EpWIFKj" crossorigin="anonymous"></script>`,
|
|
170
170
|
twoLines: `import { installCustomsGuard } from "https://cdn.jsdelivr.net/gh/montbaga/agent-customs@v${PKG_VERSION}/site/customs/guard.js";\ninstallCustomsGuard(booted.engine, { strict: true });`,
|
|
171
171
|
npm: `npm install agent-customs\nimport { installCustomsGuard } from "agent-customs";\ninstallCustomsGuard(booted.engine);`,
|
|
172
172
|
cli: `npx agent-customs check https://your-site.example/\nnpx agent-customs check ./my-network --strict\nnpx agent-customs mcp`,
|