Skip to content

MAX_FETCH_FILE_SIZE = 0 keeps a zip-bomb guard for list archives (#945) - #946

Open
chchatzop wants to merge 2 commits into
mainfrom
fix/945-zero-keeps-the-list-zip-bomb-guard
Open

chchatzop wants to merge 2 commits into
mainfrom
fix/945-zero-keeps-the-list-zip-bomb-guard

Conversation

@chchatzop

Copy link
Copy Markdown
Collaborator

Closes #945. This follows up my review on #940.

The problem: #940 resolved MAX_FETCH_FILE_SIZE = 0 to float("inf"). For a list archive, that value is the zip-bomb guard:

  • _validate_zip_members()'s sum of declared sizes is the only bound on extraction.
  • ZipExtFile truncates each member to its declared size, and that size is now unbounded.
  • max_list_text_size() is only checked after extraction.

So with the setting at 0, a small zip of zeros unpacked without limit. Reproduced on main: an 8001-byte member against MAX_LIST_TEXT_SIZE = 1000 was extracted in full and only refused afterwards. v1.13.1 is not affected, because it predates #940.

The fix: 0 still means "no limit" for files. For a list archive it now falls back to max_list_text_size() * MAX_LISTS_PER_ARCHIVE, which is 1 GB with the defaults. Any list over max_list_text_size() is refused after extraction anyway, so this refuses nothing that would have been kept. #940's live 482 MB SamothMetal case still passes the guard. The rejection message now names the ceiling that actually applied, instead of "MAX_FETCH_FILE_SIZE (0 bytes)".

Tests (tests/test_list_fetch.py):

I mutation-checked four ways: inf again, a fallback that ignores MAX_LIST_TEXT_SIZE, 0 read as a zero-byte ceiling (#939 again), and the old message. Each one fails a test.

Docs: both changelogs, the setting's help text, the defaults.py comment, and a regenerated settings.conf.sample.

Suite: full suite green on this branch, and also merged with #942 and #944.

🤖 Generated with Claude Code

https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW

#940 resolved 0 to float("inf"), and for a list archive that value is the
zip-bomb guard - the only bound on extraction. With the setting at 0 a
small zip of zeros unpacked without limit. 0 stays "no limit" for files;
a list archive falls back to max_list_text_size() * MAX_LISTS_PER_ARCHIVE
(1 GB by default), which refuses nothing that would have been kept. The
two assertions #940 dropped from the neighbouring test are back.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AP6LSxkr4n9dMFNSNMogmW
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.

MAX_FETCH_FILE_SIZE = 0 switches off the list zip-bomb guard (#940 follow-up)

1 participant