Commit 61cda3e
committed
test(types): remove reflected-XSS sink from type-test fixtures
CodeQL reported js/reflected-xss (CWE-79, high) against
tests/types/catchAsync.test-d.ts: two handler bodies passed
`req.params.id` directly to `res.json(...)`. Express serializes a bare
string as the entire response body without escaping `<`, which is the
risk its `json escape` setting exists to mitigate, so a user-controlled
string reaching that sink is a pattern worth removing rather than
suppressing.
The published package was never affected. The flow existed only in a
type-level fixture that is never executed, never registered on a server,
and never published, and dist/ is byte-identical before and after.
The object form `res.json({ id: ... })` used elsewhere in the same file
is not a sink, because reflected XSS requires a string to reach the
response body and the object wrapper breaks that flow.
Both bodies now assert the parameter typing directly instead of echoing
the request. That is a stronger test: the new params-shape assertions pin
the custom `Request<P>` type argument, which `res.json(req.params.id)`
never did, since a `ParamsDictionary` index signature also yields a
string for `.id`.1 parent 3e137ed commit 61cda3e
2 files changed
Lines changed: 24 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
165 | 165 | | |
166 | 166 | | |
167 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
168 | 173 | | |
169 | 174 | | |
170 | | - | |
| 175 | + | |
| 176 | + | |
171 | 177 | | |
172 | 178 | | |
173 | 179 | | |
174 | 180 | | |
175 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
176 | 188 | | |
177 | 189 | | |
178 | 190 | | |
| |||
182 | 194 | | |
183 | 195 | | |
184 | 196 | | |
185 | | - | |
| 197 | + | |
| 198 | + | |
186 | 199 | | |
187 | 200 | | |
188 | 201 | | |
189 | 202 | | |
190 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
191 | 207 | | |
192 | 208 | | |
193 | 209 | | |
| |||
464 | 480 | | |
465 | 481 | | |
466 | 482 | | |
| 483 | + | |
467 | 484 | | |
| 485 | + | |
468 | 486 | | |
469 | 487 | | |
470 | 488 | | |
| |||
0 commit comments