fix(batch): byte-safe percent-decode + bound array job size#1992
Merged
Conversation
Two request-path input-safety bugs in the new Batch service: - percent_decode sliced the &str at byte offsets (&s[i+1..i+3]); a % next to a multi-byte UTF-8 char (e.g. a tag ARN path /v1/tags/%<euro>) landed on a non-char boundary and panicked, killing the request task and dropping the client connection (the #1539 Bug-2 failure mode). Decode on raw bytes and reassemble via from_utf8_lossy; also fixes the latin-1 corruption of legitimately-decoded multi-byte sequences. - SubmitJob accepted any arrayProperties.size > 1 and synchronously spawned that many container launches; a huge size is a single-request resource- exhaustion vector. Validate 2..=10000 (the AWS range) and 400 otherwise.
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.
Two request-path input-safety bugs in the new AWS Batch service, found by the 2026-06-27 bug-hunt (Tier 2 + Tier 3).
1. CRITICAL — percent_decode panic drops the connection
percent_decode(crates/fakecloud-batch/src/service.rs) sliced the&strat byte offsets (&s[i+1..i+3]). A%adjacent to a multi-byte UTF-8 char — e.g. a tag requestGET /v1/tags/%€— landsi+3inside the char, panicking with "byte index is not a char boundary". There is nocatch_unwindin core/server, so the request task dies and the client sees a dropped connection (the #1539 Bug-2 failure mode), not a clean response. It was also latin-1-corrupting legitimately decoded multi-byte sequences (b as char).Fix: decode
%XXon the raw bytes (always char-safe) and reassemble viafrom_utf8_lossy.caf%C3%A9->cafénow round-trips.2. MEDIUM — unbounded array job size
SubmitJobaccepted anyarrayProperties.size > 1and synchronously looped that many container launches (each taking the state write lock + a real ECS RunTask) — a single-request resource-exhaustion vector. Validate2..=10000(the AWS range) and returnClientExceptionotherwise.Tests
3 new unit tests: multi-byte percent-decode doesn't panic + round-trips; ListTagsForResource with a raw multi-byte ARN returns normally; SubmitJob rejects out-of-range array sizes (0/1/-3/10001/2e9).
cargo test -p fakecloud-batch17 pass.Summary by cubic
Make request parsing in
fakecloud-batchsafe by decoding percent-escapes on bytes and enforcing array job size limits. Prevents dropped connections and single-request resource exhaustion.percent_decodenow decodes%XXon raw bytes and rebuilds withfrom_utf8_lossy, handling multi-byte UTF-8 safely (e.g.,caf%C3%A9->café) and avoiding panics when%is next to a multi-byte char.SubmitJobvalidatesarrayProperties.sizein2..=10000(AWS range). Out-of-range returnsClientExceptioninstead of launching unbounded containers.Written for commit 75999c8. Summary will update on new commits.