i1235: enforce uncompressed source size for pc2submit zip submissions - #1290
Open
clevengr wants to merge 2 commits into
Open
i1235: enforce uncompressed source size for pc2submit zip submissions#1290clevengr wants to merge 2 commits into
clevengr wants to merge 2 commits into
Conversation
clevengr
requested review from
JoeTerlizzi,
SamanwaySadhu,
johnbrvc and
kkarakas
August 19, 2026 03:42
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.
Description of what the PR does
Previously,
pc2submitonly applied submission size limits based on the HTTPContent-Lengthof the compressed (zipped) POST. The result was that highly compressible source could exceed the contest limit on source code submission size (default 256 KiB) and still be accepted. (This happened in the NAC 2026 dress rehearsal, where submission 747 was 31 MB uncompressed, but only ~92 KB zipped.) This PR closes that loophole.Specifically, CLICS
POST /submissions(classSubmissionService) now checks claimed uncompressed zip entry sizes (ZipEntry.getSize()via the zip central directory) againstContestInformation.getMaxSourceSizeInBytes()before extracting (uncompressing) the zip file.In addition,
SubmissionServicenow utilizes new methods inEventFeedUtilitiesto monitor the actual in-memory unzipping process by keeping a running inflated-byte cap during extraction (uncompression) so a zip that understates sizes cannot expand without bound in memory. (Such a condition could happen if a zip file lied about the total payload size -- which would be easy for an attacker to spoof by creating a zip with bad headers).Oversized submits made via the
pc2submitcommand now return HTTP 413 with the same “Source file(s) are too large" error message as WTI.Additional notes:
pc2teamare unchanged (they usesubmitJudgeRun, which is unaffected by this PR).getIFiles(byte[])(see separate issue Shadow doesn't enforce max source size when fetching submission files from the Primary CCS #1291).Issue which the PR addresses
Fixes #1235
Environment in which the PR was developed
Windows 11, Eclipse 2020-12 (4.18.0), Java version "1.8.0_271", Cursor version 3.13.25
Precise steps for testing the PR
The important case is a source code file submitted using
pc2submitwhose uncompressed size > contest max, but where the zip + JSON is still small enough to pass the JettySubmitPostSizeLimitFilterused in a POST toSubmissionService. Note that random large files often get rejected by the POST-size filter first and do not exercise this PR.Setup
clics_sumithellocontest.feeder1.Startbutton on the EF GUI to start the Web Server running (note that the default port is 50443). Examine the console and confirm the webserver is running.machine localhost login team1 password team1. (If not, create such an entry.)In Windows, the .netrc file is located at
C:\USERS\<username>.This should return a message like
If you do not get a message like the above, stop and check your network setup; you need to be able to connect to the contest in order to run the following tests.
(Note: the "warning" is simply because you are submitting a PC2 sample source file that hasn't been changed in quite a while).
yto submit the program, then verify that you get a message on the console likeSubmission received: id = s1, time = 20:19:47.pc2submit.Primary Test: submisson of a compressible source file which is over the uncompressed limit
jeirr.cpp.jeirr.cppfile withpc2submitas above.yto the questionDo you want to continue?, a message like the following is returned:Optional additional tests: WTI / pc2team unchanged
Submit an oversized file via pc2team and/or WTI. Verify that such a file is still rejected (it should not be accepted because pc2team and WTI already contained code to prohibit such a submission, and no changes were made to either of these submission components).
Optional additional test: POST filter still works
Submit an incompressible file larger than the max (e.g. 300 KiB of random bytes). Such a file should still be rejected by the existing POST-size filter which is applied before the file is ever unzipped. That is how it should work; this PR does not replace that filter.