fix(tar-extract): bound pax parsing and enforce strict tar framing (PHARN-18) - #212
Merged
Merged
Conversation
…HARN-18) A 192 KB archive whose pax global header inflated to ~128 MB cost ~13 s CPU and >1 GB RSS to parse (OOM under a 512 MB heap, leaving the temp clone). Framing was lenient: a zero block mid-archive silently dropped the rest, a missing end marker, trailing garbage and a missing ustar magic were accepted, and `a//b` / `a/./b` segments were left to safeJoin. The extractor now refuses a g/x payload over 64 KiB before parsing it, requires only zeros after the end marker, refuses a missing marker and a non-ustar header, and refuses empty/"." segments below the root. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TvcuVhk8hTeDskp5pAJhnc
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
readPaxKeywordsparsedg/xpayloads of any size. A 192 KB archive whose payload expands to about 128 MB took ~13 s of CPU and ~1.1 GB of memory. Under a 512 MB heap the process crashed and left the temp clone behind.ustarmagic were all accepted;a//banda/./bsegments were caught only bysafeJoin.Fix
g/xpayload over 64 KiB is refused on its size field alone, before any parsing. The codeload header is about 52 bytes.ustar(both POSIXustar\0and old GNUustarare accepted)..path segments below the root are refused.Tests
.dev/features/tar-strict-framing/.Advisory
THREAT-MODEL.md§2 (the list of extractor refusals) should gain these rules. That file is write-protected, so a maintainer has to add them.🤖 Generated with Claude Code
https://claude.ai/code/session_01TvcuVhk8hTeDskp5pAJhnc
Generated by Claude Code