agent-customs 1.2.0 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- 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/site/desk.js +20 -0
- package/site/receipts/index.json +4 -4
- package/site/receipts/montbaga.github.io/agent-customs/agent_customs.json +4 -4
- package/tools/mcp-server.mjs +3 -2
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.2/dist/agent-customs.js"
|
|
66
|
+
integrity="sha384-1tuTNG+ZM3HXuLLt1VL1oKW4ipT8rkPZY2UJ0odqE26aB2FxENBJAKS+lQLgAzOo"
|
|
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.2/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.2/dist/agent-customs.js" integrity="sha384-1tuTNG+ZM3HXuLLt1VL1oKW4ipT8rkPZY2UJ0odqE26aB2FxENBJAKS+lQLgAzOo" 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.2` 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.2/site/customs/guard.js";
|
|
186
186
|
|
|
187
187
|
// Right after the boot(...) call
|
|
188
188
|
installCustomsGuard(booted.engine, { strict: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-customs",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
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/site/desk.js
CHANGED
|
@@ -218,6 +218,7 @@ export class CustomsDesk {
|
|
|
218
218
|
|
|
219
219
|
remember(input, report) {
|
|
220
220
|
const key = normalize(report.target.url || input);
|
|
221
|
+
this.reports.delete(key);
|
|
221
222
|
this.reports.set(key, report);
|
|
222
223
|
this.aliases.set(normalize(input), key);
|
|
223
224
|
}
|
|
@@ -399,12 +400,31 @@ export class CustomsDesk {
|
|
|
399
400
|
this.emit("border");
|
|
400
401
|
}
|
|
401
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Compact summaries of every network inspected in this visit, newest first.
|
|
405
|
+
*/
|
|
406
|
+
inspectedReports(limit = 12) {
|
|
407
|
+
return [...this.reports.values()]
|
|
408
|
+
.reverse()
|
|
409
|
+
.slice(0, limit)
|
|
410
|
+
.map((r) => ({
|
|
411
|
+
url: r.target.url,
|
|
412
|
+
brand: r.identity.brand || "",
|
|
413
|
+
verdict: r.verdict.code,
|
|
414
|
+
stamp: r.verdict.stamp,
|
|
415
|
+
fingerprint: r.identity.short || "",
|
|
416
|
+
inspectedAt: r.inspectedAt,
|
|
417
|
+
agents: r.identity.agents || [],
|
|
418
|
+
}));
|
|
419
|
+
}
|
|
420
|
+
|
|
402
421
|
/**
|
|
403
422
|
* The desk's state for the read tool.
|
|
404
423
|
*/
|
|
405
424
|
state() {
|
|
406
425
|
return {
|
|
407
426
|
latestReport: this.latest ? compact(this.latest, 6) : null,
|
|
427
|
+
inspectedReports: this.inspectedReports(),
|
|
408
428
|
aiDoubleCheck: this.aiCheckState(),
|
|
409
429
|
approvedVersions: this.pins.list().map((p) => ({ url: p.url, brand: p.brand, fingerprint: p.short, verdictWhenApproved: p.verdict, approvedAt: p.pinnedAt, how: p.how })),
|
|
410
430
|
testRange: EXAMPLES.map((e) => ({ name: e.label, kind: e.note, networkUrl: e.url, page: e.page })),
|
package/site/receipts/index.json
CHANGED
|
@@ -3,16 +3,16 @@
|
|
|
3
3
|
"issuer": "Agent Customs",
|
|
4
4
|
"site": "https://montbaga.github.io/agent-customs/",
|
|
5
5
|
"keyId": "-DC99sDa-qJjBp2N",
|
|
6
|
-
"signedAt": "2026-11-
|
|
6
|
+
"signedAt": "2026-11-23T16:56:15.994Z",
|
|
7
7
|
"receipts": [
|
|
8
8
|
{
|
|
9
9
|
"network": "https://montbaga.github.io/agent-customs/agent_customs",
|
|
10
10
|
"path": "montbaga.github.io/agent-customs/agent_customs.json",
|
|
11
11
|
"stamp": "Cleared",
|
|
12
12
|
"verdict": "CLEARED",
|
|
13
|
-
"fingerprint": "sha256:
|
|
14
|
-
"inspectedAt": "2026-11-
|
|
15
|
-
"expiresAt": "2026-12-
|
|
13
|
+
"fingerprint": "sha256:3c7633565f2e8078f7808645dc254ff6afa5c60e75f0b2f41c4d4e6720f75ab3",
|
|
14
|
+
"inspectedAt": "2026-11-23T16:56:15.994Z",
|
|
15
|
+
"expiresAt": "2026-12-28T16:56:15.994Z"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"network": "https://montbaga.github.io/agent-customs/practice/main_street_guide",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"type": "agent-customs-receipt",
|
|
4
4
|
"version": 1,
|
|
5
5
|
"network": "https://montbaga.github.io/agent-customs/agent_customs",
|
|
6
|
-
"fingerprint": "sha256:
|
|
6
|
+
"fingerprint": "sha256:3c7633565f2e8078f7808645dc254ff6afa5c60e75f0b2f41c4d4e6720f75ab3",
|
|
7
7
|
"verdict": "CLEARED",
|
|
8
8
|
"stamp": "Cleared",
|
|
9
9
|
"summary": "No issues found. Pin the fingerprint so you notice if it changes.",
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"passed": 16,
|
|
20
20
|
"total": 16
|
|
21
21
|
},
|
|
22
|
-
"inspectedAt": "2026-11-
|
|
23
|
-
"expiresAt": "2026-12-
|
|
22
|
+
"inspectedAt": "2026-11-23T16:56:15.994Z",
|
|
23
|
+
"expiresAt": "2026-12-28T16:56:15.994Z",
|
|
24
24
|
"inspector": {
|
|
25
25
|
"name": "Agent Customs",
|
|
26
26
|
"version": "1.0.0",
|
|
@@ -31,6 +31,6 @@
|
|
|
31
31
|
"signature": {
|
|
32
32
|
"alg": "ES256",
|
|
33
33
|
"keyId": "-DC99sDa-qJjBp2N",
|
|
34
|
-
"value": "
|
|
34
|
+
"value": "MI-m6Zzfg8DG4BqvkHglrsaE_tKMnZzVW5h69i3GsNMxP9a253uG7BdlqSDsF6mnqu-CDWxLBFeLdj7ra09pyg"
|
|
35
35
|
}
|
|
36
36
|
}
|
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-1tuTNG+ZM3HXuLLt1VL1oKW4ipT8rkPZY2UJ0odqE26aB2FxENBJAKS+lQLgAzOo" 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`,
|
|
@@ -793,7 +793,7 @@ export function createAgentCustomsMcp(options = {}) {
|
|
|
793
793
|
{
|
|
794
794
|
name: "get_desk_state",
|
|
795
795
|
description:
|
|
796
|
-
"Read the Agent Customs desk state: latest inspection report, AI double-check status, saved approvals, built-in test-range examples, protocol samples, Attack Lab scenarios, border log, and benchmark metrics.",
|
|
796
|
+
"Read the Agent Customs desk state: latest inspection report, all networks inspected in this session, AI double-check status, saved approvals, built-in test-range examples, protocol samples, Attack Lab scenarios, border log, and benchmark metrics.",
|
|
797
797
|
inputSchema: { type: "object", additionalProperties: false, properties: {} },
|
|
798
798
|
async execute() {
|
|
799
799
|
const ai = refreshDeskAi();
|
|
@@ -806,6 +806,7 @@ export function createAgentCustomsMcp(options = {}) {
|
|
|
806
806
|
const rawPins = pins.all();
|
|
807
807
|
return {
|
|
808
808
|
latestReport: desk.latest ? compactReport(desk.latest, 6) : null,
|
|
809
|
+
inspectedReports: desk.inspectedReports(),
|
|
809
810
|
aiDoubleCheck: {
|
|
810
811
|
enabled: desk.aiCheckOn,
|
|
811
812
|
state: ai ? (desk.aiCheckOn ? "ready" : "off-configured") : desk.aiCheckOn ? "needs-key" : "off",
|