Repository navigation
FIX: Bound backend request sizes and field lengths - #2960
Merged
varunj-msft merged 4 commits intoOct 6, 2026
Merged
varunj-msft merged 4 commits into
varunj-msft merged 4 commits into
Conversation
The backend accepted request bodies, strings, lists, and maps of any size, silently dropped label filters without a key:value separator, and returned 500 for turn filters too large for the database. Request bodies over 100 MiB now receive 413 with the same problem response whether the size comes from Content-Length or is reached while the body streams, and URLs over 8 KiB receive 414. Identifiers, names, labels, filters, cursors, configuration files, and initializer scripts have length or item limits shared from the backend common models, and the scenario run requests get the same limits inline (technique tokens allow converter modifiers). Values over a limit, label filters without a separator or with a key or value over the label limits, negative cutoff indexes, and turn filters above 10,000 receive 422. Prompt content (message pieces, system prompts, and converter preview input) and free-form values (prompt metadata and parameter values) are limited only by the body size, so long prompts and base64 media keep working.
The scenario request models duplicated the backend's identifier, list, and label limits because pyrit.models cannot import from the backend, and a test kept the two copies equal. The shared limits now live in pyrit.models.request_limits; the scenario models and the backend import them. HTTP body and URL limits stay in the backend.
Richard Lundeen (richlundeen)
approved these changes
Oct 5, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Oct 5, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Oct 5, 2026
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
The backend accepted request bodies, strings, lists, and maps of any size, silently dropped label filters without a
key:valueseparator, and returned 500 for turn filters too large for the database.middleware/request_size.py: the backend reads at most 100 MiB of a request body (413, fromContent-Lengthor while streaming) and rejects URLs over 8 KiB (414). Both 413 paths return the same RFC 7807 problem response (RequestTooLargeErrorplus a handler inregister_error_handlers). The middleware is registered innermost so the streamed 413 reaches the route as anHTTPException; CORS stays outside it so browsers can read 413/414.models/common.py: limits applied to request models and route path/query parameters (identifiers 256, cursors 1024, free text such as objectives 100,000, labels up to 100 entries with keys 128 and values 1024, lists 100, configuration and initializer file contents 1,048,576 characters). Prompt content (message pieces, system prompts, converter preview input) and free-form values (metadata and parameter values) are limited only by the body size so long prompts and base64 media keep working.pyrit/models/request_limits.py(per review).pyrit/models/catalog/scenario.pyuses them for run and estimate requests, andbackend/models/common.pyimports them; body, URL, cursor, and text limits stay in the backend. Technique tokens allow converter modifiers (technique:converter.<name>:...) up to 4,096 characters.validate_label_filter: a:separator is required and the stripped key and value must fit the label limits (422 with a readable message);parse_label_query_paramsreuses it instead of dropping malformed filters.min_turns/max_turnsget an upper bound of 10,000 andcutoff_indexmust be non-negative.Coordination:
main.py, README) and [BREAKING] MAINT: Make backend scenario reads async-only #2953 (scenario route bodies) currently merge cleanly with this PR.pyrit/models/catalog/scenario.py: [BREAKING] FEAT: Make scenario dataset sources and limits explicit #2956 changesmax_dataset_sizenext to fields bounded here and adds tests totests/unit/models/test_scenario_request.py, and FEAT: Add ScenarioPreset #2931 changes the adjacentmax_dataset_sizedescription. Whichever lands second resolves a few field-line conflicts (keep [BREAKING] FEAT: Make scenario dataset sources and limits explicit #2956's dataset-limit type next to this PR's bounded types).pyrit/backend/models/attacks.py.Tests and Documentation
tests/unit/backend/test_request_size.py(declared and streamed 413 through the real app with identical bodies),test_common_models.py,test_api_routes.py,tests/unit/models/test_scenario_request.py.python -m pytest tests/unit/backend tests/unit/models -n 4— 3562 passed, 4 skipped.ruff format/ruff check— passed;ty check pyrit/— no new diagnostics; pre-commit hooks pass.build_and_testworkflow run on the fork at 7c7afc8: pre-commit on ubuntu/windows/macOS andmake unit-test-juniton ubuntu/windows/macOS x Python 3.11-3.14 x dev/dev_all — all 35 jobs passed.