Skip to content

archive/tar: test tarinsecurepath behavior for link targets#79884

Closed
Abhinav-143x wants to merge 1 commit into
golang:masterfrom
Abhinav-143x:codex/tar-linkname-tarinsecurepath-test
Closed

archive/tar: test tarinsecurepath behavior for link targets#79884
Abhinav-143x wants to merge 1 commit into
golang:masterfrom
Abhinav-143x:codex/tar-linkname-tarinsecurepath-test

Conversation

@Abhinav-143x

Copy link
Copy Markdown

Clarify the Reader.Next documentation for tarinsecurepath=0 and add regression coverage for link targets.

The tarinsecurepath check reports ErrInsecurePath for non-local Header.Name values, but it does not validate Header.Linkname. That distinction is security-relevant for archive consumers that use archive/tar as part of extraction or policy enforcement: link targets need to be handled by the extractor's own filesystem policy.

This change preserves the current behavior. It makes the contract clearer by:

  • rewording the Reader.Next comment so the ErrInsecurePath behavior reads directly;
  • keeping the existing statement that only file names are validated, not link targets;
  • adding tests for TypeLink and TypeSymlink entries with non-local link targets while GODEBUG=tarinsecurepath=0.

The new test confirms that the tarinsecurepath check applies to the entry name and not to the link target. This should help prevent future regressions or ambiguous assumptions around link handling in archive/tar readers.

Tests:

  • go_bootstrap.exe test archive/tar
  • go_bootstrap.exe test archive/...

Review requested. Please let me know if this should be adjusted to emphasize the test coverage only, or if there is a preferred wording for the Reader.Next documentation.

@Abhinav-143x Abhinav-143x deleted the codex/tar-linkname-tarinsecurepath-test branch June 6, 2026 18:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant