WW-5618 feat(json): add configurable limits for DoS prevention#1626
Open
lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
Open
WW-5618 feat(json): add configurable limits for DoS prevention#1626lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
lukaszlenart wants to merge 1 commit intorelease/struts-6-8-xfrom
Conversation
…evention Add configurable limits to the JSON plugin to prevent denial-of-service attacks via malicious JSON payloads. Limits are enforced directly in the existing JSONReader class without breaking backward compatibility (no interface extraction or class renames). New configurable constants (struts-plugin.xml defaults): - struts.json.maxElements (10000) - per-container element count - struts.json.maxDepth (64) - maximum nesting depth - struts.json.maxLength (2097152) - maximum input length in chars - struts.json.maxStringLength (262144) - maximum string value length - struts.json.maxKeyLength (512) - maximum object key length Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
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.




Summary
JSONReaderclass — no interface extraction, no class renames, preserving full backward compatibility with Struts 6.xNew configurable constants (with defaults in
struts-plugin.xml):struts.json.maxElementsstruts.json.maxDepthstruts.json.maxLengthstruts.json.maxStringLengthstruts.json.maxKeyLengthFiles changed
JSONConstants.javaJSONReader.javaobject()/array()/string()JSONUtil.javadeserializeInput()instance method with length checkingJSONInterceptor.java@Injectsetters, usesdeserializeInput()struts-plugin.xmlJSONReaderLimitsTest.javaJSONUtilTest.javadeserializeInput()andmaxLengthTest plan
./mvnw -pl plugins/json clean test— all 125 tests pass (0 failures, 0 errors)./mvnw -pl plugins/json clean prepare-package -DskipTests— RAT license headers passjakarta.servletimports (verifiedjavax.servletnamespace)com.opensymphony.xwork2.injectimports (notorg.apache.struts2.inject)🤖 Generated with Claude Code