Repository navigation
Commit 0c47f84
fix(check): reject symlinks whose target isn't SQL + test hygiene
Round 3 on the release/v0.9.6 hotfix — addresses 3 new bot findings on
PR #1131:
- coderabbit MAJOR (real leak surface): the extension filter and
statSync isFile check both see the SYMLINK target, not the link. So
`ln -s /etc/passwd passwd.sql` sailed through — link's .sql extension
passed, statSync followed the link, /etc/passwd IS a regular file,
readFileSync then read its content, and the safety renderer echoed
the first line. Exact leak class this PR exists to close.
Fix: `lstatSync` to detect symlinks; when one is present, `realpathSync`
to resolve the target and require ITS extension to also be SQL.
Preserves `link.sql -> real.sql` (both SQL); rejects `passwd.sql ->
/etc/passwd`. Two new handler-level regression tests:
• "handler rejects symlink whose target is NOT a SQL file"
• "handler ACCEPTS symlink whose target IS a SQL file"
Reproduced the attack locally with the built binary: pre-fix leaked
the file's first line; post-fix skips cleanly.
- coderabbit MAJOR (spy hygiene in check-e2e.test.ts): the spyOn calls
on process.stdout.write / process.stderr.write / console.error in
beforeEach were never restored. Bun doesn't auto-restore spyOn
across test files. Added `mock.restore()` in afterEach.
- coderabbit MAJOR (dispatcher singleton isolation): same class of
finding as the env-var one — the tests mutate module-wide
`nativeHandlers`/`_ensureRegistered`. Not fixable without an
instance-per-test refactor of the whole Dispatcher module. Documented
the concurrency contract in-file: safe under bun's default sequential
test-file execution; #1130 already tracks the broader parallel-safety
cleanup this class of finding calls for. Same disposition as the
release-adversarial file.
Verification:
- 103/103 tests pass (2 new symlink cases)
- rebuilt darwin-arm64 binary; symlink attack repro shows the warning
and no content leak
- typecheck clean; marker guard clean
Co-Authored-By: Claude Opus 4.7 <[email protected]>1 parent 5224705 commit 0c47f84
3 files changed
Lines changed: 84 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
513 | 513 | | |
514 | 514 | | |
515 | 515 | | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
516 | 548 | | |
517 | 549 | | |
518 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
9 | 21 | | |
10 | 22 | | |
11 | 23 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
153 | 153 | | |
154 | 154 | | |
155 | 155 | | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
156 | 161 | | |
157 | 162 | | |
158 | 163 | | |
| |||
1148 | 1153 | | |
1149 | 1154 | | |
1150 | 1155 | | |
| 1156 | + | |
| 1157 | + | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
1151 | 1189 | | |
1152 | 1190 | | |
1153 | 1191 | | |
| |||
0 commit comments