fix(llm-security): v8.x-A - close <script> recall hole, add whole-table ReDoS gate
Two of the three confirmed v8.x-A evasions are closed; the third (attribute padding) stays open by operator decision and is documented, not silently left. Recall fix. hybrid-xss required a closing </script>, so `<script>alert(1)` and `<script src=x.js>` both passed scanForInjection() with found: false, while the closed form returned high. A src= tag has no body to close in the first place. The opening tag alone is the signal, and matching it is strictly linear: one negated-class run whose excluded character is its own terminator, so there is no backtracking surface that could re-introduce v7.8.3 #24. ReDoS gate. The #24 test covered six html-obfuscation patterns against the two shapes that defect was found on. A catastrophically backtracking regex added anywhere else in the four tables would have failed no test at all - which is why #24 had to be found by hand. The new gate times every exported pattern and asserts its own coverage, so it cannot be narrowed silently. It has two classes because the blowup shapes need opposite inputs, and because a synchronous RegExp.test() cannot be interrupted: an exponential pattern met with a 512KB input would HANG the run rather than fail it. Class 1 uses a 28-char ambiguous-run ladder, where exponential costs ~1s and anything sane costs microseconds; on a hit the 512KB sweeps refuse to run. Class 2 uses the hook's real read cap to catch the polynomial #24 class. Proven to fire: an injected exponential regex was named by label and the hang guard held. Measured clean: worst single pattern 17ms, full large sweep 218ms. Golden gate went red as expected and was re-blessed - diff is exactly two lines, the regex source and the source-file digest. The 61-payload reference run is byte-identical, so no showcase behaviour moved. Suite 2073/2073 (was 2063; +5 recall tests, +5 gate tests). Still open, unchanged: all 7 bounded HTML patterns evade on >256 chars of padding, in two positions - before the attribute and inside the style value. Wider than STATE recorded, which named only aria-label.
This commit is contained in:
parent
b0de0ca6d8
commit
90f576f056
3 changed files with 203 additions and 3 deletions
|
|
@ -352,7 +352,7 @@
|
|||
{
|
||||
"kind": "regex",
|
||||
"key": "injection-patterns:HYBRID_PATTERNS[4].pattern",
|
||||
"source": "<script\\b[^>]*>[\\s\\S]*?<\\/script>",
|
||||
"source": "<script\\b[^>]*>",
|
||||
"flags": "i"
|
||||
},
|
||||
{
|
||||
|
|
@ -560,7 +560,7 @@
|
|||
{
|
||||
"kind": "file",
|
||||
"key": "scanners/lib/injection-patterns.mjs",
|
||||
"sha256": "0dda47e385e5a0bc33b83f7e33bb546544302907bc830afb0421680a2daff4ef"
|
||||
"sha256": "9965d51aca86b4837181920064ce3af23e9baaf958979eef51ed2ee8f8f9d078"
|
||||
},
|
||||
{
|
||||
"kind": "file",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue