Commit c1a4271
committed
security: close 2 new CodeQL alerts (ReDoS + HTTP response splitting)
py/polynomial-redos (wiki_export.py:142)
The frontmatter key:value matcher
r"^([A-Za-z_][\w-]*)\s*:\s*(.*)$"
has two repetition steps whose ranges overlap on adversarial
input like "A:" followed by N tabs, producing O(n²) backtracking.
Replaced with str.partition(":") + a tight bounded key validator
r"^[A-Za-z_][\w-]{0,62}$". No quantifier overlap, no backtracking
hazard. 100 000-tab input now processes in sub-millisecond time.
Added a 1000-char per-line sanity cap as defence in depth.
py/http-response-splitting (http_viz_server.py:352 + http_standalone mirror)
The Content-Disposition filename was built by literal f-string
interpolation of a user-controlled path component. CRLF in the
filename would enable header injection (Set-Cookie, cache
poisoning, etc.).
Sanitized to [A-Za-z0-9._-] only (re.sub r"[^\w.-]", "_") and
capped at 200 chars before the header. The format suffix gets the
same treatment (guard on our own constant map, but belt-and-braces
against future changes).1 parent efa501c commit c1a4271
3 files changed
Lines changed: 38 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
121 | 131 | | |
122 | 132 | | |
123 | 133 | | |
| |||
137 | 147 | | |
138 | 148 | | |
139 | 149 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
144 | 156 | | |
145 | | - | |
146 | 157 | | |
147 | | - | |
148 | | - | |
149 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
150 | 161 | | |
151 | 162 | | |
152 | 163 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
450 | 457 | | |
451 | 458 | | |
452 | 459 | | |
453 | 460 | | |
454 | | - | |
| 461 | + | |
455 | 462 | | |
456 | 463 | | |
457 | 464 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
347 | | - | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
348 | 356 | | |
349 | 357 | | |
350 | 358 | | |
351 | 359 | | |
352 | | - | |
| 360 | + | |
353 | 361 | | |
354 | 362 | | |
355 | 363 | | |
| |||
0 commit comments