Commit a27ec9b
committed
fix: validate file paths in saveFile to prevent path traversal
The saveFile() method accepts user-provided filenames and resolves them
with path.resolve(), but does not validate the resulting path. This
allows writing files to arbitrary locations via absolute paths or ../
sequences.
Add validation to ensure the resolved file path stays within the current
working directory before writing.1 parent 8d765c0 commit a27ec9b
1 file changed
Lines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
701 | 701 | | |
702 | 702 | | |
703 | 703 | | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
704 | 710 | | |
705 | 711 | | |
706 | 712 | | |
707 | 713 | | |
708 | | - | |
| 714 | + | |
709 | 715 | | |
710 | 716 | | |
711 | 717 | | |
| |||
0 commit comments