Repository navigation
Commit 51ddb4e
authored
don't follow symlinks in the debugger tmp directory (#1575)
Debugger.start only creates its scratch directory when
Path(tmp_dir).exists() is false, and get_tmp_directory returns the
completely predictable <tempdir>/ipykernel_<pid>. Path.exists follows
symlinks, so on a host with a shared temp directory another local user
can reach that name first and point it at a directory they own; the
kernel then skips the mkdir, the 0o700 mode from #1530 never applies,
and dumpCell writes the cell source straight through the link. I went
back to start after that permissions change and noticed the mkdir is
reachable only when the path does not already exist, which is the one
case someone else gets to control. Planting the predictable name as a
symlink locally confirmed it: start carried on, dumpCell dropped the
cell text into the other directory, and a symlink planted under the
Murmur2 cell name turned the same write into an overwrite of a file
outside the temp tree. Creating the directory first and only accepting
an existing one when lstat says it is a real directory owned by this
user closes that, and opening the dumped cell with O_NOFOLLOW keeps the
file write itself from being redirected; the cell file now lands at
0o600 instead of whatever the umask gives, matching the directory around
it. Added two regressions beside the existing debugger tests, both
skipped when debugpy is absent and on Windows where symlinks need
privileges and O_NOFOLLOW does not exist.2 files changed
Lines changed: 61 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
305 | 306 | | |
306 | 307 | | |
307 | 308 | | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
308 | 321 | | |
309 | 322 | | |
310 | 323 | | |
| |||
428 | 441 | | |
429 | 442 | | |
430 | 443 | | |
431 | | - | |
| 444 | + | |
432 | 445 | | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
433 | 454 | | |
434 | 455 | | |
435 | 456 | | |
| |||
471 | 492 | | |
472 | 493 | | |
473 | 494 | | |
474 | | - | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
475 | 498 | | |
476 | 499 | | |
477 | 500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
1 | 2 | | |
2 | 3 | | |
3 | 4 | | |
| |||
431 | 432 | | |
432 | 433 | | |
433 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
434 | 470 | | |
435 | 471 | | |
436 | 472 | | |
| |||
0 commit comments