Skip to content

Restrict links and implement zip bomb detection - #211

Merged
thelovekesh merged 10 commits into
mainfrom
archive/restrict-links
May 4, 2026
Merged

Restrict links and implement zip bomb detection#211
thelovekesh merged 10 commits into
mainfrom
archive/restrict-links

Conversation

@thelovekesh

Copy link
Copy Markdown
Collaborator

This update restricts the ability to pack tarballs with symlinks and hardlinks, and ensures these links are skipped while unpacking a tarball.

This decision was made after careful consideration regarding security, cross-platform distribution, and how the WordPress Zip API handles symlinks during extraction. Archive APIs and packages frequently receive security advisories related to how tarball contents can be exploited (such as directory traversal attacks). Properly mitigating these risks requires significant, ongoing maintenance and prevention.

Furthermore, there are virtually no legitimate use cases for hardlinks or symlinks within WordPress plugin or theme codebases. By completely restricting their packing and extraction, we proactively eliminate a potential attack vector and simplify the package manager's architecture.

On the security front, we’re also introducing automatic detection for zip bombs. To protect server resources from malicious archives designed to expand infinitely and crash the system, we’ve established strict new extraction limits.

From now on, a plugin or theme will be flagged as a zip bomb if its uncompressed size tops 512 MB, or if it has a wildly high compression ratio of 250:1 (99.6%). If you're wondering where that number comes from, we are following industry best practices. For example, Composer also marks packages as zip bombs if they exceed 99% compression.

@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown

📦 wpm cli builds 📦

@thelovekesh thelovekesh changed the title Restrict hardlinks and symlinks in archive API Restrict links and implement zip bomb detection May 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request strengthens archive security in the package manager by (1) disallowing symlinks/hardlinks during packing, (2) skipping link entries during extraction, and (3) adding zip-bomb style extraction limits (max decompressed size and max compression ratio).

Changes:

  • Reject symlinks and hardlinks when creating archives; skip link entries when extracting.
  • Add zip bomb detection during extraction (512MB decompressed cap; compression ratio guard).
  • Thread a logger callback through installer/extraction so link-skips can be reported to stderr.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/pm/installer/installer.go Adds a logger hook and passes it into archive extraction options.
pkg/archive/archive.go Implements link restrictions, extraction-time skipping, and zip bomb detection/limits.
pkg/archive/time_windows.go Removes unused link-specific time-setting helper.
pkg/archive/time_nonwindows.go Removes link-specific time-setting implementation and unix dependency.
pkg/archive/archive_windows.go Removes unused inode helper.
pkg/archive/archive_unix.go Removes unused inode helper and syscall import.
cli/command/publish/publish.go Adds logger wiring via TarOptions (stderr output).
cli/command/install/run.go Updates installer construction to provide a logger function.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/archive/archive.go
Comment thread pkg/archive/archive.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/archive/archive.go
Comment thread pkg/archive/archive.go
@thelovekesh
thelovekesh merged commit 5b83702 into main May 4, 2026
21 checks passed
@thelovekesh
thelovekesh deleted the archive/restrict-links branch May 4, 2026 21:18
@thelovekesh thelovekesh added enhancement New feature or request core changes made in cli core api labels May 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core changes made in cli core api enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants