Commit ade6fdc
committed
fix(security): skip symlinks in all filepath.Walk callbacks (M1)
filepath.Walk uses Lstat internally and does NOT descend into
symlinked directories. However, symlink entries are still passed
to the walk callback — appearing as files in results. Since H1
fixed all file opens to use O_NOFOLLOW, these symlink paths are
unreadable dead ends that leak path information.
Fix: add info.Mode()&os.ModeSymlink check at the top of every
walk callback across the codebase:
file_tool.go — searchContent, searchFiles name match,
glob with path separators
perf_tools.go — multiGrep
resource.go — FileResolver.walkAndMatch
All five walks now silently skip symlink entries. This is
defense-in-depth: O_NOFOLLOW on opens was the primary fix,
skipping symlinks at the walk level prevents path disclosure
and eliminates any TOCTOU concern entirely.
Fixes M1 from security audit.1 parent 1a5099b commit ade6fdc
3 files changed
Lines changed: 23 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
| |||
474 | 479 | | |
475 | 480 | | |
476 | 481 | | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
477 | 486 | | |
478 | 487 | | |
479 | 488 | | |
| |||
1034 | 1043 | | |
1035 | 1044 | | |
1036 | 1045 | | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
1037 | 1051 | | |
1038 | 1052 | | |
1039 | 1053 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1091 | 1091 | | |
1092 | 1092 | | |
1093 | 1093 | | |
| 1094 | + | |
| 1095 | + | |
| 1096 | + | |
| 1097 | + | |
1094 | 1098 | | |
1095 | 1099 | | |
1096 | 1100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
292 | 297 | | |
293 | 298 | | |
294 | 299 | | |
| |||
0 commit comments