Repository navigation
Commit 5efde13
lane-u5a-2359
fix(file-safety): refuse a mode copy onto a file the staging check never validated
The staging check lstats the caller-supplied path and rejects a link. The open
that follows uses openSync with r+, which follows a link, and the only thing
checked after the open is that the opened file is regular and carries one name.
A writer of that directory can name the staging path for a symlink to a
single-link regular file between the lstat and the open. The open follows it,
fstat reports a plain single-name file so the guard passes, and the mode copy
below then changes the mode of a file this write never staged. The pre-commit
name check refuses the publish later but cannot undo a mode already changed.
Carry the identity the check validated and compare it against the opened
descriptor before the mode copy, refusing with StagingPathError when they differ.
Tested by a control row in the spec that gives the open a different identity from
the validated one: with this change the write refuses before the chmod, with the
change taken away the same row fails because the mode copy is issued. The
committed change ships without that row.
Answers review comment 4533489470 on pull 1912.1 parent 2b39a88 commit 5efde13
1 file changed
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
482 | 486 | | |
483 | 487 | | |
484 | 488 | | |
| |||
572 | 576 | | |
573 | 577 | | |
574 | 578 | | |
| 579 | + | |
575 | 580 | | |
576 | 581 | | |
577 | 582 | | |
| |||
691 | 696 | | |
692 | 697 | | |
693 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
694 | 716 | | |
695 | 717 | | |
696 | 718 | | |
| |||
0 commit comments