Commit b11f777
authored
Merge commit from fork
ensureLinkPath validated TypeLink targets by resolving relative paths
against the link file's directory, but returned the original (unresolved)
target string. The caller passed this to os.Link, which resolves relative
paths against the process CWD via link(2), not the link file's directory.
A crafted OCI artifact could exploit this to hardlink a CWD file into the
extract tree (GHSA-fxhp-mv3v-67qp).
Fix: explicitly resolve relative hardlink targets against filepath.Dir of
the link file before calling os.Link. Symlink handling is unaffected since
os.Symlink stores the path verbatim and resolves at access time.
Add a regression test that sets the process CWD to a directory containing
a sentinel file and verifies that a tar TypeLink entry with a relative
Linkname cannot hardlink that file into the extract tree.
Signed-off-by: Terry Howe <terrylhowe@gmail.com>1 parent 9fc3dfb commit b11f777
2 files changed
Lines changed: 60 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
188 | 188 | | |
189 | 189 | | |
190 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
191 | 196 | | |
192 | 197 | | |
193 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
376 | 376 | | |
377 | 377 | | |
378 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
379 | 434 | | |
380 | 435 | | |
381 | 436 | | |
| |||
0 commit comments