Skip to content

mldistwatch: forbid tarbombs from being indexed - #392

Merged
rjbs merged 3 commits into
andk:masterfrom
rjbs:no-tarbombs
Oct 28, 2026
Merged

rjbs merged 3 commits into
andk:masterfrom
rjbs:no-tarbombs

Conversation

@rjbs

@rjbs rjbs commented Apr 28, 2023

Copy link
Copy Markdown
Collaborator

Previously, you could upload a tarball with "Foo.pm" in the root and we would index that. From now on, dists must have a top-level directory, and only that one directory.

@rjbs
rjbs requested a review from andk April 28, 2023 08:11
@haarg

haarg commented Apr 28, 2023

Copy link
Copy Markdown

Does this handle a tarball with a top level '.' directory properly?

@rjbs

rjbs commented Apr 29, 2023 •

Copy link
Copy Markdown
Collaborator Author

No! (concluded by thinking about it, not testing)

@andk

andk commented Apr 29, 2023

Copy link
Copy Markdown
Owner

@rjbs, could you review and resolve conflicts?

@rjbs
rjbs marked this pull request as draft April 30, 2023 07:52
@rjbs rjbs added the indexer How we index uploads label Apr 28, 2024
rjbs added a commit to rjbs/pause that referenced this pull request Oct 24, 2026
An archive holding a single file, like Foo.pm, had one "root" and so
passed the multiple-root check.  It was only rejected later, for lacking
META.  Now a single top-level entry must be a directory.

The error's wording now covers both cases: it no longer says "multiple
roots", and it lists the "top-level entries" instead of the "directory
entries".

This is the case the original version of PR andk#392 tested with its
Tarbomb-0.001 corpus file.  Master had since come to handle its other
cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rjbs
rjbs marked this pull request as ready for review October 24, 2026 17:59
rjbs and others added 3 commits October 28, 2026 09:45
Archives are extracted right into the indexer's work directory, so an
entry for "./" (as produced by "tar -czf x.tar.gz ."), is an entry for
the work directory itself.  GNU tar applies the "." entry's mode and
ownership to the real cwd.  An upload with a "./" entry of mode 0644
left the indexer unable to chdir back into its work directory, and the
resulting die ended the whole indexer run, not just that dist.  (Ugh.)

Running as root, as in production, the chdir would succeed, but the work
directory would still keep the archive's mode for the rest of the run,
which could stop the unprivileged version parser from reading the files
of every later dist.

--no-overwrite-dir tells tar to leave existing directories' metadata
alone.

Co-Authored-By: Claude <noreply@anthropic.com>
PAUSE already refused archives that don't unpack into a single
directory, but it looked for META first, and it looks for META inside
the expected top-level directory.  So a tarbomb, with its files at the
top level, was always reported as having no META file, even when one was
right there.

Checking the archive's layout first gets the author the real reason.

Co-Authored-By: Claude <noreply@anthropic.com>
An archive holding a single file, like Foo.pm, had one "root" and so
passed the multiple-root check.  It was only rejected later, for lacking
META.  Now a single top-level entry must be a directory.

The error's wording now covers both cases: it no longer says "multiple
roots", and it lists the "top-level entries" instead of the "directory
entries".

This is the case the original version of PR andk#392 tested with its
Tarbomb-0.001 corpus file.  Master had since come to handle its other
cases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rjbs
rjbs merged commit f90cad5 into andk:master Oct 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

indexer How we index uploads

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants