Commit ccbf0d2
committed
fix(github): reject a backslash in safeEncodedUrlPathSegment
It was the only one of the three guards that encoded a backslash to %5C
instead of refusing it.
Encoding is safe on the wire — a raw backslash IS a path separator to the
WHATWG parser for a special scheme, so https://x/a/b/..\..\etc resolves to
/etc, but the encoded form does not move:
new URL('https://x/a/b/..%5C..%5Cetc').pathname => /a/b/..%5C..%5Cetc
So this is not a live traversal hole. It is refused anyway for the reason the
module already gives for safeUrlPath: a value carrying a backslash is a
Windows-shaped path the caller did not mean to address literally, and letting
one through leaves a segment that reads as traversal to anything downstream
that normalizes it. Neither caller — a GitHub label name, a git ref — can
legitimately contain one, so the consistency costs nothing.
Pinned, including an assertion that all three guards agree.1 parent 0c5108e commit ccbf0d2
2 files changed
Lines changed: 48 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
457 | 458 | | |
458 | 459 | | |
459 | 460 | | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
460 | 486 | | |
461 | 487 | | |
462 | 488 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
347 | 347 | | |
348 | 348 | | |
349 | 349 | | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
350 | 367 | | |
351 | 368 | | |
352 | 369 | | |
| |||
355 | 372 | | |
356 | 373 | | |
357 | 374 | | |
358 | | - | |
| 375 | + | |
359 | 376 | | |
360 | 377 | | |
361 | 378 | | |
| |||
371 | 388 | | |
372 | 389 | | |
373 | 390 | | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
374 | 395 | | |
375 | 396 | | |
376 | 397 | | |
| |||
0 commit comments