feat(active): grade a short URL token that base64-decodes to text as carrying
Gap 6 closed. _is_opaque has a fourth branch for host labels and path segments of 8-19 chars (calibration.URL_SHORT_B64_MIN_LEN). It fires when the token is alphanumeric, not 1 mod 4, not itself a word, and its base64 plaintext reads as text: only letters, digits, space and . , : @ _ - + / ! ? ' =, at least 80% letters/digits/spaces (URL_SHORT_B64_TEXT_SHARE), and no lowercase-to-uppercase seam.  is now HIGH; a link with it MEDIUM. "Printable" alone fired on Pygments, a Norwegian path word and a JSON size parameter. Each condition removes a measured twin (Pygments, aktuelle, Slovenly, {"w":200}, PT00M01S, endsWith). Measured before building, with the shipped tokenizer: 0 of 22,725 URLs in the 3,583 clean documents and 577 package READMEs, 0 of 530,625 dictionary words, 9 of 336,122 identifiers and prose tokens (all real base64 of text). Recall 32 of 35. Measured before and after on the same trees: all 4,160 documents are byte-identical under both presets (disposition, labels, severity, count, offset); OKF import stays 47/31; positive control WARN -> FAIL_SECURE. is_ordinary_url about 4 us slower per URL; 1M-char worst case unchanged. 26 new tests (attacks red first), 11 of 11 mutations red. Matrix 147/147 + 4/4 gaps, suite 1300 passed, ReDoS sweep 173 patterns, 0 flags on the new.
This commit is contained in:
parent
6cf0eb1263
commit
7430d7855a
14 changed files with 350 additions and 50 deletions
|
|
@ -142,9 +142,9 @@ live payload:
|
|||
python -m llm_ingestion_guard.coverage # exit 0 = all as documented
|
||||
```
|
||||
|
||||
As of `v1.10.0`: **146 / 146 defended classes demonstrated (recall 100%)** and **5 /
|
||||
5 documented gaps still hold** (a *closed* gap fails the test, forcing a doc
|
||||
update). The matrix is the single source of truth for the test suite (**1274
|
||||
As of `v1.10.0`: **147 / 147 defended classes demonstrated (recall 100%)** and **4 /
|
||||
4 documented gaps still hold** (a *closed* gap fails the test, forcing a doc
|
||||
update). The matrix is the single source of truth for the test suite (**1300
|
||||
passing**), which also asserts total recall, that every lexicon pattern has a
|
||||
case (so the matrix cannot fall behind the lexicon), the full LLM02:2026 secret-egress
|
||||
set, and the container-layer front-end (CSV formula-injection, zip-slip/bomb,
|
||||
|
|
|
|||
|
|
@ -257,13 +257,22 @@ items; this is the full list, each with the mechanism.
|
|||
renderer touches it, leaking reader IP, user-agent and timing. Grading the fetch
|
||||
itself would re-block every ordinary document, which is precisely the 0.3.0
|
||||
regression this replaced — so beaconing is conceded, not covered.
|
||||
- **Short opaque URL segments slip through the same grading.** Opacity is decided by
|
||||
`entropy`'s primitives: base64 that decodes to text (≥20 chars), a hex id
|
||||
(≥32 chars), or Shannon entropy ≥4.4 at ≥24 chars. A shorter payload segment —
|
||||
`https://evil.test/aGVsbG8gd29ybGQ` — cannot be told from a name, because entropy
|
||||
is bounded by `log2(length)` at short lengths. Mitigation in depth, not in this
|
||||
detector: a literal credential in a URL is still caught by the LLM02:2026 egress
|
||||
patterns in the same `scan_output` pass, whatever severity the carrier gets.
|
||||
- **A short URL segment is caught only when its base64 plaintext reads as text.**
|
||||
Opacity is decided by base64 that decodes to text (≥20 chars), a hex id (≥32
|
||||
chars), Shannon entropy ≥4.4 at ≥24 chars, and since 1.11.0 a short-text branch
|
||||
for tokens of 8 to 19 characters (`docs/URL-SHAPE.md`). Entropy cannot tell a
|
||||
short token from a name, so the short branch decodes it and asks more of the
|
||||
plaintext than "printable": the token must not be a word, and the plaintext must
|
||||
use only letters, digits, space and `. , : @ _ - + / ! ? ' =`, be at least 80%
|
||||
letters, digits or spaces, and have no lowercase letter followed by an uppercase
|
||||
one. What still passes as ordinary: a token under 8 characters (5 bytes or less,
|
||||
such as `aGVsbG8` for "hello"); a plaintext with other characters (`Tr0ub4dor&3`,
|
||||
JSON); a camelCase plaintext (`JohnSmith`); a payload that is not base64 at all
|
||||
(hex under 32 characters, a custom alphabet, a lookup id the attacker's server
|
||||
maps back); and a value split into tokens of fewer than 8 characters each. On 35 short attack
|
||||
plaintexts the branch catches 32. Mitigation in depth, not in this detector: a
|
||||
literal credential in a URL is still caught by the LLM02:2026 egress patterns in
|
||||
the same `scan_output` pass, whatever severity the carrier gets.
|
||||
- **A value carried by the order of images is caught only when each symbol is short
|
||||
and the run shares one URL template.** Since 1.7.0
|
||||
`active:markdown-image-sequence` (MEDIUM) reports a run of at least 4 ordinary
|
||||
|
|
@ -689,7 +698,7 @@ items; this is the full list, each with the mechanism.
|
|||
missed; on one preset it is held for review instead of halted.
|
||||
|
||||
- **The ReDoS sweep has a measured sensitivity floor, not a clean bill of
|
||||
health.** All 169 compiled patterns across all eleven regex-bearing modules are
|
||||
health.** All 173 compiled patterns across all eleven regex-bearing modules are
|
||||
swept arm by arm — payloads synthesised per run from each pattern's own
|
||||
skeleton, so `[`, `[system]` and `[system](` are each probed separately rather
|
||||
than relying on generic units, and each pattern is timed in the call mode the
|
||||
|
|
@ -847,11 +856,15 @@ were measured too.
|
|||
the 3,583, but that measurement is blind: none of them holds an external image.
|
||||
On the 569 READMEs it fires on 52 and would stop **23** of the 211 that pass
|
||||
today. The fetch itself is what an ordinary README does.
|
||||
6. **Short opaque URL segment (<24 chars)** — below what entropy can resolve (above).
|
||||
Open. The cheapest rule (a segment of 8 to 23 characters that base64-decodes to at
|
||||
least 6 printable bytes) fired on 4 of 14,943 README URLs, among them a size
|
||||
parameter in an image URL and the word "Pygments". It has to demand more of the
|
||||
decoded text and be measured again before it is built.
|
||||
6. **Short opaque URL segment (<24 chars)** — **closed in 1.11.0.** A URL token of
|
||||
8 to 19 characters is opaque when its base64 plaintext reads as text (see "A short
|
||||
URL segment is caught only when..." above). The first rule tried, "decodes to at
|
||||
least 6 printable bytes", fired on the word `Pygments`, a Norwegian path word and
|
||||
a JSON size parameter. The rule as built fires on none of the 7,525 URLs in the
|
||||
3,583 documents or the 15,200 in 577 package READMEs (the README population
|
||||
rebuilt on 2026-11-01; it was 569 in session 1). Measured as built: all 4,160
|
||||
documents keep their disposition under both presets, and every finding keeps its
|
||||
label, severity, `count` and offset.
|
||||
7. **Unmarked prose task (toxic agent flow, A12)** — no address, deferral, memory or
|
||||
concealment to read (above). **Measured reason:** a rule for "gather it from
|
||||
private places" gave **6** new alarms. Adding "and put it into this document" in
|
||||
|
|
|
|||
64
docs/PLAN.md
64
docs/PLAN.md
|
|
@ -326,6 +326,70 @@ ikke (en base64-innpakket gjør det). Det står i LIMITATIONS.
|
|||
- **Rad 2:** hull 1 og 4 er lukket, og 2, 3, 5 og 7 står med målt begrunnelse. Hull 6
|
||||
er åpent og neste: regelen må kreve mer av klarteksten og måles på nytt (§ V.6).
|
||||
|
||||
## V.10 Økt 5, hull 6 lukket (01.11.2026, release 1.11.0)
|
||||
|
||||
**Hull 6 (kort ugjennomsiktig URL-ledd):** `_is_opaque` har en fjerde gren,
|
||||
`_is_short_text_base64`, for tokener på 8–19 tegn (`calibration.URL_SHORT_B64_MIN_LEN`).
|
||||
Den fyrer når tokenet er alfanumerisk, lengden ikke gir rest 1 ved deling på 4, tokenet
|
||||
ikke er et ord (`[A-Z]?[a-z]+` eller `[A-Z]+`), og klarteksten er ASCII med bare
|
||||
bokstaver, sifre, mellomrom og `. , : @ _ - + / ! ? ' =`, minst 80 % bokstaver, sifre
|
||||
eller mellomrom (`URL_SHORT_B64_TEXT_SHARE`), og ingen liten bokstav fulgt av stor.
|
||||
Matrisesaken `short-opaque` står som fanget og sjekker også at et ord med samme lengde
|
||||
forblir LOW. `CLOSED` har nå `short-opaque`.
|
||||
|
||||
**Målt før bygging, med bibliotekets egen tokenisering.** Session 1-regelens
|
||||
tokenisering var en annen. Med den som faktisk brukes, ga «skrivbart» 3 treff: `aktuelle` i
|
||||
referansekorpuset (`jKnzY^`, ikke sett i økt 1), `Pygments` og Patreons `{"w":200}`.
|
||||
GitHubs `package_id` var et resultat av den andre tokeniseringen. Kandidatene ble målt
|
||||
token for token:
|
||||
|
||||
| Krav til klarteksten | 3 583 dok. + 577 README (22 725 URL-er) | Ordbok, 530 625 (små, Stor, STORE) | Identifikatorer og prosa, 336 122 | Fangst, 35 angrep |
|
||||
|---|---|---|---|---|
|
||||
| skrivbart (økt 1) | 3 | 254 | 125 | 35 |
|
||||
| lesbart alfabet | 0 | 101 | 27 (18 søppel) | 34 |
|
||||
| + ikke et ord + ≥ 80 % + ingen skjøt (bygget) | **0** | **0** | **9, alle ekte base64 av tekst** | **32** |
|
||||
|
||||
Hver betingelse fjerner en målt tvilling: ordtesten `Pygments`, `aktuelle` og
|
||||
`Slovenly` (`JZ/zyr`, som består alle krav til klarteksten), alfabetet `{"w":200}`,
|
||||
andelen `PT00M01S` (`==43MR`), og skjøten `endsWith` (`zwlZ+a`, en MDN-adresse).
|
||||
De tre bommene er `Tr0ub4dor&3` (`&`), `JohnSmith` og «OpenAI key» (skjøt).
|
||||
Base64 av skrivbar ASCII har `+` eller `/` bare når tredje byte i en trippel er `>`,
|
||||
`?` eller `~` (sjekket for alle 857 375 tripler), så tokeniseringen splitter sjelden
|
||||
et angrepstoken.
|
||||
|
||||
**README-populasjonen** er 577 i dag, bygget på samme måte (`node_modules`-README-er
|
||||
og `dist-info/METADATA` under repo-mappa, deduplisert på sha256). 569 fra økt 1 ble
|
||||
ikke gjenskapt. Grunnlinjen er gjenskapt eksakt med `docs/gap-sweep.py`: 106/198 ·
|
||||
196/2918 · 108/389 · 0/78, og README 359/577 ikke-WARN.
|
||||
|
||||
- **TDD:** 26 nye tester: 7 angrep, 11 tvillinger, 1 med to begrensninger, 1
|
||||
kalibrering og 6 nye eksempler i URL-SHAPE (matrisesaken bytter bare status). De 7
|
||||
angrepene, kalibreringen og matrisesaken var røde av riktig grunn (LOW, manglende
|
||||
konstant). Tvillingene holdt fra start. URL-SHAPE-eksemplene ble skrevet etter koden.
|
||||
Identifikatorene ble høstet på nytt etter byggingen og var da 336 122 (336 112
|
||||
under kandidatmålingen, fordi andre repoer endret seg). Den bygde koden gir 9 på dem. Mutasjonssjekk 11 av 11
|
||||
røde (hver betingelse fjernet, gulv 7 og 9, andel 0,6 og 0,9, grenen fjernet). To
|
||||
overlevde først (ordtesten og alfanumerisk-testen), og fikk hver sin tvilling.
|
||||
- **Vaktregelen:** før og etter på samme trær (HEAD og arbeidstreet, frosset). Alle 4 160
|
||||
dokumenter (3 583 + 577) har samme disposisjon under begge forhåndsinnstillingene og
|
||||
samme etiketter, alvorlighetsgrader, `count` og offset: utdataene er identiske byte
|
||||
for byte. OKF-importen står på 47/31. Positiv kontroll: et rent README med
|
||||
angrepsbildet lagt til går fra WARN til FAIL_SECURE etter, og forblir WARN før.
|
||||
- **Ytelse:** maskinen hadde belastningssnitt rundt 43 (andre økter), så regelen om å
|
||||
måle uten annen last kunne ikke holdes. Relativt, vekselvis, tre runder:
|
||||
`is_ordinary_url` over de 22 725 URL-ene ×5 tok 2,46/2,21/2,36 s før og
|
||||
2,78/2,86/2,80 s etter (rundt 4 µs per URL). `scan_output` over de 389 svinger
|
||||
57–101 s og gir ingen lesbar forskjell. Verste tilfelle ved taket på 1 000 000 tegn
|
||||
(40 slike tokener per bilde): 6,57/6,46 s før, 6,27/6,22 s etter. Lineært fra 25 000
|
||||
til 100 000 tegn.
|
||||
- **ReDoS:** sveipet teller 173 mønstre (nytt: `_ALNUM_TOKEN_RE`, `_WORD_TOKEN_RE`,
|
||||
`_READABLE_TEXT_RE`, `_CASE_SEAM_RE`). To kjøringer ga 5 og 4 tidsflagg, alle på
|
||||
uendrede mønstre, og 0 på de nye. Exit 0.
|
||||
- **Vakten:** kjørt på nytt, 16 current, bare `lastRun` endret.
|
||||
- **Rad 2:** hull 1, 4 og 6 er lukket, og 2, 3, 5 og 7 står med målt begrunnelse.
|
||||
Alle sju er avgjort. Sluttmålingen (§ V.3) gjenstår: rad 1 venter på sju dager
|
||||
med ukentlige kjøringer hos llm-security.
|
||||
|
||||
## Forrige retning (godkjent av operatøren 28.10.2026, nådd 31.10)
|
||||
|
||||
> «llm-ingestion-guard bygger på nyeste utgave av hver trusselkatalog den viser til,
|
||||
|
|
|
|||
|
|
@ -48,16 +48,25 @@ hyphenated filename shatters into short tokens. Note also what is *not* in it:
|
|||
`%` is not a separator, so a percent-escaped path yields *longer* tokens than the
|
||||
same path with literal spaces.
|
||||
|
||||
A token is **opaque** if any of three branches fires — cheapest first:
|
||||
A token is **opaque** if any of four branches fires — cheapest first:
|
||||
|
||||
| Branch | Floor | Test |
|
||||
|---|---|---|
|
||||
| base64 | **≥ 20 chars** | matches `[A-Za-z0-9+/]{20,}={0,3}` **and** b64-decodes to ≥80% printable text |
|
||||
| hex | **≥ 32 chars** | matches `(?:0x)?[0-9a-fA-F]{32,}` |
|
||||
| entropy | **≥ 24 chars** | Shannon entropy ≥ **4.4** |
|
||||
| short base64 text (1.11.0) | **≥ 8 chars** | all of: alphanumeric, length not 1 mod 4, **not** a word (`[A-Z]?[a-z]+` or `[A-Z]+`), and the b64 plaintext is ASCII using only letters, digits, space and `. , : @ _ - + / ! ? ' =`, at least **80%** letters, digits or spaces, with **no** lowercase letter followed by an uppercase one |
|
||||
|
||||
Every branch has a length floor. Nothing shorter than 20 characters can ever be
|
||||
opaque by any branch.
|
||||
Every branch has a length floor. Nothing shorter than 8 characters can ever be
|
||||
opaque by any branch, and below 20 only the short-text branch can fire.
|
||||
|
||||
The short-text branch is strict on purpose: ordinary words decode to printable
|
||||
bytes by chance (56 of 176,875 dictionary words of 8 to 19 letters, and `Pygments`
|
||||
to `?(&z{l`). Each
|
||||
condition removes a benign twin measured on 2026-11-01: the word test removes
|
||||
`Pygments` and `aktuelle`, the readable alphabet removes a JSON size parameter
|
||||
(`eyJ3IjoyMDB9` to `{"w":200}`), the 80% share removes `PT00M01S` (`==43MR`), and
|
||||
the seam test removes `endsWith` (`zwlZ+a`).
|
||||
|
||||
## Worked examples
|
||||
|
||||
|
|
@ -72,7 +81,7 @@ means "names a document" (LOW); `carrying` keeps the carrier's full severity.
|
|||
| `https://www.bbc.com/news/articles/c8x9k2m1l0po` | ordinary | 12 chars, under every floor |
|
||||
| `https://example.com/a/550e8400-e29b-41d4-a716-446655440000/doc` | ordinary | UUID splits on `-`; longest token 12 |
|
||||
| `https://example.com/docs/CISPE-Buying-Cloud-Services-in-Public-Sector-Handbook-v2-FEB-2022_EN-Source_v2_Norwegian.pdf` | ordinary | 16 tokens, longest 9, worst H=3.17 |
|
||||
| `https://ai.meta.com/blog/` | ordinary | `blog` is 4 chars — below the base64 floor |
|
||||
| `https://ai.meta.com/blog/` | ordinary | `blog` is 4 chars — below every floor |
|
||||
| `https://www.youtube.com/watch?v=dQw4w9WgXcQ` | carrying | non-empty query |
|
||||
| `https://claude.com/pricing?utm_source=docs` | carrying | non-empty query |
|
||||
| `https://learn.microsoft.com/azure/ai/overview?view=azureml-api-2` | carrying | non-empty query |
|
||||
|
|
@ -82,6 +91,12 @@ means "names a document" (LOW); `carrying` keeps the carrier's full severity.
|
|||
| `https://example.com/d41d8cd98f00b204e9800998ecf8427e` | carrying | 32-char hex token |
|
||||
| `https://evil.test/c3RvbGVuIHNlc3Npb24gdG9rZW4gdmFsdWU/p.png` | carrying | base64 decoding to text |
|
||||
| `https://c3RvbGVuIHNlc3Npb24gdG9rZW4gdmFsdWU.evil.test/p.png` | carrying | opaque host label |
|
||||
| `https://evil.test/aGVsbG8gd29ybGQ` | carrying | 15 chars, base64 of `hello world` |
|
||||
| `https://evil.test/Zm9vYmFy/p.png` | carrying | 8 chars, base64 of `foobar` |
|
||||
| `https://pypi.org/project/Pygments/` | ordinary | a word, whatever it decodes to |
|
||||
| `https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p.png` | ordinary | decodes to `{"w":200}`, not readable text |
|
||||
| `https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith` | ordinary | decodes to `zwlZ+a`, a case seam |
|
||||
| `https://evil.test/aGk/p.png` | ordinary | `hi` in base64, 3 chars, under every floor |
|
||||
| `ftp://example.com/pub/file.txt` | carrying | scheme gate |
|
||||
| `javascript:alert(1)` | carrying | scheme gate |
|
||||
|
||||
|
|
@ -96,7 +111,9 @@ Each of these produced a real, wrong number on a real corpus.
|
|||
- **Omitting the base64 length floor.** Testing "b64-decodes to printable text"
|
||||
without `len ≥ 20` fires on ordinary path words — `blog`, `digi` and `1544`
|
||||
decode to printable bytes, while `news` and `docs` do not, so the reconstruction
|
||||
appears to discriminate on something meaningful and does not.
|
||||
appears to discriminate on something meaningful and does not. Below 20 chars
|
||||
only the short-text branch applies, with its 8-char floor and all of its
|
||||
conditions on the plaintext; "printable" alone fired on `Pygments`.
|
||||
- **Omitting step 5 entirely.** Applying only "query or percent-escape" is
|
||||
*strictly weaker* than the real rule, so it undercounts carrying URLs. It can
|
||||
never overcount: every URL it calls carrying really is.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue