Skip to content

i1235: enforce uncompressed source size for pc2submit zip submissions - #1290

Open
clevengr wants to merge 2 commits into
pc2ccs:developfrom
clevengr:i1235_pc2submit_source_size_limit
Open

i1235: enforce uncompressed source size for pc2submit zip submissions#1290
clevengr wants to merge 2 commits into
pc2ccs:developfrom
clevengr:i1235_pc2submit_source_size_limit

Conversation

@clevengr

@clevengr clevengr commented Aug 19, 2026

Copy link
Copy Markdown

Description of what the PR does

Previously, pc2submit only applied submission size limits based on the HTTP Content-Length of 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 (class SubmissionService) now checks claimed uncompressed zip entry sizes (ZipEntry.getSize() via the zip central directory) against ContestInformation.getMaxSourceSizeInBytes() before extracting (uncompressing) the zip file.

In addition, SubmissionService now utilizes new methods in EventFeedUtilities to 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 pc2submit command now return HTTP 413 with the same “Source file(s) are too large" error message as WTI.

Additional notes:

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 pc2submit whose uncompressed size > contest max, but where the zip + JSON is still small enough to pass the Jetty SubmitPostSizeLimitFilter used in a POST to SubmissionService. Note that random large files often get rejected by the POST-size filter first and do not exercise this PR.

Setup

  1. Ensure you have Python3 on your machine.
  2. Start a PC2 Server loading the clics_sumithello contest.
  3. Start a PC2 Admin.
  4. On the Admin Configure Contest->Times tab, start the contest clock running.
  5. Start a PC2 Event Feeder client and login as feeder1.
  6. Click the Start button 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.
  7. Verify that your .netrc file contains an entry like
    machine localhost login team1 password team1. (If not, create such an entry.)
    In Windows, the .netrc file is located at C:\USERS\<username>.
  8. Open a terminal window in the PC2 distribution and enter the command
python ./bin/pc2submit --url https://localhost:50443 --problem A ./samps/src/hello.cpp`

This should return a message like

Warning: `./samps/src/hello.cpp' has not been modified for 482857 minutes!
Submission information:
  filename:    ./samps/src/hello.cpp
  contest:     SumH
  problem:     A
  language:    GNU C++
  url:         https://localhost:50443/
There are warnings for this submission!
Do you want to continue? (y/n)

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).

  1. Enter y to submit the program, then verify that you get a message on the console like Submission received: id = s1, time = 20:19:47.
  2. On the PC2 Admin Run Contest->Runs tab, verify that you see a newly-submitted run. This proves that you can submit a run using pc2submit.

Primary Test: submisson of a compressible source file which is over the uncompressed limit

  1. Download the file https://github.com/icpcsysops/NAC2026/blob/main/contests/dress/results/primary/replay/747.zip from the NAC2026 Dress Rehearsal. This is a zip file of about 91K (so, much less than the default source size limit of 256K) but which contains a (compressed) source file that is over 30MB when uncompressed.
  2. Unzip the downloaded zip file. This should produce a 30MB file named jeirr.cpp.
  3. Submit the jeirr.cpp file with pc2submit as above.
  4. Verify that when you answer y to the question Do you want to continue?, a message like the following is returned:
Submission failed (code 413 - Unable to submit run: Source file(s) are too large (31610880 bytes) - maximum is 262144 bytes.)
  1. Check the PC2 Admin RUNS grid; verify that no new submission was accepted.

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.

@clevengr clevengr added this to the 9.11.0 milestone Aug 19, 2026
@clevengr clevengr changed the title **i1235: enforce uncompressed source size for pc2submit zip submissions** i1235: enforce uncompressed source size for pc2submit zip submissions Aug 19, 2026
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.

Teams can submit super big files as a problem submission.

1 participant