You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fory.apache.org by "SURYAS1306 (via GitHub)" <gi...@apache.org> on 2026/02/28 21:32:58 UTC
[PR] feat(java): add configurable deserialization size guardrails (#3411) [fory]
SURYAS1306 opened a new pull request, #3438:
URL: https://github.com/apache/fory/pull/3438
## Why?
Currently there are no configurable limits for payload-driven lengths in Java deserialization.
Untrusted binary/map/list lengths can trigger large allocations and memory pressure.
This PR introduces configurable guardrails to prevent excessive memory allocation during deserialization.
---
## What does this PR do?
- Adds two runtime configuration options:
- `maxBinarySize`
- `maxCollectionSize`
- Enforces:
- `maxCollectionSize` for:
- Collection reads
- Map reads (entry count)
- Primitive numeric list reads
- `maxBinarySize` for:
- Raw byte list reads (`Int8List`, `Uint8List`)
- String reads are intentionally excluded as specified in issue #3411.
- Throws `IllegalArgumentException` when configured limits are exceeded.
- No behavior change when limits are unset or set to `0`.
All existing tests pass.
---
## Related issues
Fixes #3411
---
## Does this PR introduce any user-facing change?
- [x] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?
This introduces new configuration options but does not modify the binary protocol.
---
## Benchmark
Not applicable. This change does not modify serialization logic or performance-critical paths beyond adding guard checks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] feat(java): add configurable deserialization size guardrails [fory]
Posted by "SURYAS1306 (via GitHub)" <gi...@apache.org>.
SURYAS1306 commented on PR #3438:
URL: https://github.com/apache/fory/pull/3438#issuecomment-4008003238
Hi @chaokunyang,
Thanks for the suggestion
You're right - I initially focused on the collection/map serializers and primitive list serializers that directly allocate based on payload length.
I’ll go through the other serializers (such as ArraySerializers and StringSerializer) and add the same guard checks where preallocation depends on input size.
I’ll update the PR accordingly.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] feat(java): add configurable deserialization size guardrails [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang commented on PR #3438:
URL: https://github.com/apache/fory/pull/3438#issuecomment-4005784090
Thanks for your contribution, please deep read fory-core code, there are still many Serializers needs updates. For example, java/fory-core/src/main/java/org/apache/fory/serializer/ArraySerializers.java and java/fory-core/src/main/java/org/apache/fory/serializer/StringSerializer.java. I didn't scan all files, but it should have more files need updates
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] feat(java): add configurable deserialization size guardrails [fory]
Posted by "shivendra-dev54 (via GitHub)" <gi...@apache.org>.
shivendra-dev54 commented on PR #3438:
URL: https://github.com/apache/fory/pull/3438#issuecomment-4116974586
@SURYAS1306 are you working on this ??
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org
Re: [PR] feat(java): add configurable deserialization size guardrails [fory]
Posted by "chaokunyang (via GitHub)" <gi...@apache.org>.
chaokunyang closed pull request #3438: feat(java): add configurable deserialization size guardrails
URL: https://github.com/apache/fory/pull/3438
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@fory.apache.org
For additional commands, e-mail: commits-help@fory.apache.org