Skip to content

WW-5666 Apply input length limits consistently when reading request bodies - #1819

Open
lukaszlenart wants to merge 2 commits into
mainfrom
WW-5666-input-length-limits
Open

WW-5666 Apply input length limits consistently when reading request bodies#1819
lukaszlenart wants to merge 2 commits into
mainfrom
WW-5666-input-length-limits

Conversation

@lukaszlenart

Copy link
Copy Markdown
Member

Two request-body reading paths apply input limits less consistently than the rest of the framework. This makes the JSON input length limit apply uniformly while reading, and gives the CSP reporting path a configurable limit of its own.

JSON plugin

JSONUtil.deserializeInput(Reader, int) compared the accumulated length against struts.json.maxLength between lines, so the limit was applied after input had been accumulated rather than while it was being read. It is now evaluated as the input is read, in fixed-size chunks, so enforcement does not vary with the structure of the input.

CSP reporting

CspReportAction read the submitted report body with a single readLine() and had no limit of its own. The body is now read up to a limit defaulting to 8192 characters, exposed as a maxReportSize property so applications can tune it. A report above the limit is discarded with a warning rather than processed.

Compatibility notes

JSON plugin:

  • Line terminators are no longer stripped while reading. They are insignificant whitespace between tokens, so parsing is unaffected.
  • An unescaped control character inside a JSON string value is now preserved in the parsed value rather than silently removed. Such input is not valid JSON; applications relying on the previous silent removal may observe different values.

CSP reporting:

  • processReport now receives the whole body up to the limit rather than only its first line.
  • An empty body is passed as an empty string rather than null.

Testing

  • plugins/json: 166 tests pass
  • core: 3070 tests pass

Fixes WW-5666

🤖 Generated with Claude Code

The configured JSON input length limit was evaluated after accumulating each
line of input. It is now evaluated as the input is read, in fixed-size chunks,
so enforcement no longer varies with the structure of the input.

Line terminators are no longer stripped while reading. They are insignificant
whitespace between tokens, but an unescaped control character inside a string
value is now preserved rather than silently removed.
…configurable

The report body was read without an upper bound. It is now read up to a limit
defaulting to 8192 characters and configurable via setMaxReportSize. A body
above the limit is discarded with a warning instead of being processed.

The whole body up to the limit is now passed to processReport rather than only
its first line, and an empty body is passed as an empty string rather than null.
@lukaszlenart
lukaszlenart force-pushed the WW-5666-input-length-limits branch from b4e32db to 2c82436 Compare July 29, 2026 07:07
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant