Commit 61189bc
fix(extensions): rollback atomically moves the backup dir instead of copytree
The rollback recreated dest_dir then copytree(..., dirs_exist_ok=True)'d the
backup into it. copytree uses copy2, which follows a symlink at a config leaf —
so a leaf raced into the recreated dest_dir could redirect a preserved secret to
an external target (validating only the ancestor directory does not protect
leaf paths).
Instead, after _reset_dir(dest_dir) removes any occupant and the ancestor chain
is verified non-symlink, os.replace() atomically MOVES the whole backup directory
(which already holds real files written via _atomic_restore_config) into place.
There is no per-leaf copy step and no window where dest_dir exists with a raced
leaf, so rollback can no longer follow a leaf symlink. The consumed backup is
set to None so cleanup skips it.
Existing reinstall/rollback tests (copytree-failure, failed-restore, symlinked
dest_dir, file-at-dest) all pass (361).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent df6441b commit 61189bc
1 file changed
Lines changed: 15 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1577 | 1577 | | |
1578 | 1578 | | |
1579 | 1579 | | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
1586 | | - | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1587 | 1589 | | |
1588 | 1590 | | |
1589 | 1591 | | |
1590 | 1592 | | |
1591 | 1593 | | |
1592 | 1594 | | |
1593 | | - | |
1594 | | - | |
| 1595 | + | |
| 1596 | + | |
1595 | 1597 | | |
1596 | 1598 | | |
1597 | | - | |
| 1599 | + | |
| 1600 | + | |
1598 | 1601 | | |
1599 | 1602 | | |
1600 | 1603 | | |
1601 | 1604 | | |
1602 | 1605 | | |
1603 | 1606 | | |
1604 | 1607 | | |
1605 | | - | |
| 1608 | + | |
| 1609 | + | |
1606 | 1610 | | |
1607 | 1611 | | |
1608 | 1612 | | |
| |||
0 commit comments