astral-sh / astral-sh/tar-codec
Hard-link bodies are accepted without PAX linkdata
- Dominant language
- Rust
- Stars
- 9
- Forks
- 3
- Avg merge
- 9m
- Merged PRs (30d)
- 3
Description
## Summary
`TarReader` accepts a POSIX hard-link member with a nonzero declared body and
exposes those stored bytes as the member payload without establishing that the
body is authorized by a PAX `linkdata` record.
The [reproduction archive](https://gist.githubusercontent.com/zaniebot/88e6b0a9b7e9376324cd3357098e5e40/raw/hardlink-payload-513.tar)
contains a hard-link member named `hard`, targeting `target`, with a declared
513-byte body. Tar-codec, Rust `tar`, and Tokio TAR consume and hash the stored
body. CPython and JavaScript expose the hard-link metadata without a member
payload digest, while Go rejects the archive when it reaches the stored body.
Tested with tar-codec revision
`1ac1199559a1b96f0f953ac99520ccc296503808`.
## Observed behavior
Tar-codec returns an accepted hard-link member with size `513` and payload
SHA-256:
```text
2ac6d9e2b50bdd65511fb4dc0f24b7f6a0c1b2e92d1cf6901df565802e380234
```
The ordinary header alone is sufficient to make the body visible; the archive
does not contain a PAX `linkdata` record.
## Expected behavior
Choose and document one policy for nonzero POSIX hard-link bodies. Options
include rejecting a stored body unless effective PAX `linkdata` explicitly
authorizes replacement data, or deliberately treating every declared hard-link
body as replacement data.
If the latter behavior is retained, focused extraction tests should preserve
the distinction between hard-link target contents and stored replacement
contents.
## Impact
This is a semantic and extraction-policy ambiguity rather than a demonstrated
vulnerability. Readers disagree on whether the stored bytes are a member body,
ignored link metadata, or invalid framing, so the same archive can yield
different extracted contents across implementations.
Contributor guide
Research direction
Start by reproducing the behavior with the linked hard-link-payload-513.tar archive and inspect TarReader handling of the stored body and PAX linkdata. Compare the policy options in the issue, then document and test the chosen behavior, including the distinction between hard-link target contents and replacement contents.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100