Skip to content

fix: TAR quota bypass via PAX-overridden size (issue #82)#85

Merged
bug-ops merged 1 commit intomainfrom
security-tar-quota-bypass-via
Mar 14, 2026
Merged

fix: TAR quota bypass via PAX-overridden size (issue #82)#85
bug-ops merged 1 commit intomainfrom
security-tar-quota-bypass-via

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Summary

  • Replace entry.header().size() (raw ustar value) with entry.size() (PAX-aware) in quota enforcement
  • Fix two sites in TarEntryAdapter: extract_file and get_uncompressed_size
  • Add two regression tests crafting a raw PAX TAR archive with ustar size=0

Root cause

header().size() returns the raw octal ustar field, which is 0 when the actual size is stored in a PAX extended header. entry.size() returns fields.size, which tar-rs sets to the PAX value before constructing the entry. A crafted TAR with PAX size=N and ustar size=0 bypassed both max_file_size and max_total_size checks while writing N bytes to disk.

Security impact

With default config (max_file_size=50MB, max_total_size=10GB) an attacker could cause disk exhaustion via a TAR archive using PAX extended headers for file size.

Test plan

  • test_pax_size_override_bypasses_max_file_size_quota — PAX 2MB file, limit 1MB
  • test_pax_size_override_bypasses_max_total_size_quota — PAX 600KB file, total limit 500KB
  • All 511 existing tests pass
  • cargo deny check clean
  • fmt, clippy, docs clean

Closes #82

…ypass

header().size() returns the raw ustar value, which is 0 when the actual
size is carried in a PAX extended header. entry.size() returns fields.size,
which tar-rs sets to the PAX-overridden value before constructing the entry.

Using header().size() allowed a crafted TAR (PAX size=N, ustar size=0) to
bypass both max_file_size and max_total_size quota checks while writing N
bytes to disk.

Fix both affected sites in TarEntryAdapter:
- extract_file: Some(entry.size()) instead of entry.header().size().ok()
- get_uncompressed_size: return u64 directly via entry.size()

Adds two regression tests that craft a raw PAX TAR archive and assert
extraction is rejected under quota limits.

Closes #82
@github-actions github-actions bot added core Changes to exarch-core docs Documentation labels Mar 14, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 23:51
@bug-ops bug-ops merged commit 27ce089 into main Mar 14, 2026
20 checks passed
@bug-ops bug-ops deleted the security-tar-quota-bypass-via branch March 14, 2026 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Changes to exarch-core docs Documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: TAR quota bypass via PAX-overridden size (header().size() vs entry.size())

1 participant