Skip to content

Validate lengths and values when reading - #3

Merged
Axionyxx merged 2 commits into
space-wizards:masterfrom
Axionyxx:hardening-2-the-harder
Nov 6, 2026
Merged

Axionyxx merged 2 commits into
space-wizards:masterfrom
Axionyxx:hardening-2-the-harder

Conversation

@Axionyxx

@Axionyxx Axionyxx commented Nov 5, 2026

Copy link
Copy Markdown
Member
  • Check declared array, list and string lengths against the stream before allocating.
  • Add MaxCollectionLength and MaxCollectionBytes settings.
  • Throw InvalidDataException for malformed values and mismatched types.
  • Add IMinimumSerializedSize so custom serializers can opt in to the length check.
  • Fix reading multi-byte strings from streams that return short reads.
  • Remove unused code for old targets.

Reads over the new limits will throw and explode the client connection probably.

Tested with (new) unit files, as well as against SS14 master with a single player in a release build. I'd really prefer to be able to test this before it hits robust toolbox master though, but that can be done after its merged here so I can make a RC or something

* Let custom serializers declare a minimum value size
* Update docs to match new crap
* More null stuff
* Throw for malformed values and mismatched types
* oops
* Count string memory toward the per-call allocation budget
* To the best of my knowledge nothing in Robust uses this, but it's still an issue...
* Count collection memory across the whole deserialize call
* Add tests for truncated byte-sized reads
* Limit memory used by collection elements
* Dump unmaintained code
* We don't use this for Robust, and we have no good way of ensuring it meets standards. As such, it's better and simpler to drop maintaining all of this...
* Reject string character counts that don't match the decoded text
* Harden against oveallocation
@Axionyxx

Axionyxx commented Nov 5, 2026

Copy link
Copy Markdown
Member Author

Welp this won't ever get reviewed

@Axionyxx Axionyxx closed this Nov 5, 2026
@Axionyxx Axionyxx reopened this Nov 6, 2026
@Axionyxx
Axionyxx merged commit 1eb828a into space-wizards:master Nov 6, 2026
4 of 8 checks passed
Axionyxx added a commit that referenced this pull request Nov 6, 2026
* Squash commits

* Let custom serializers declare a minimum value size
* Update docs to match new crap
* More null stuff
* Throw for malformed values and mismatched types
* oops
* Count string memory toward the per-call allocation budget
* To the best of my knowledge nothing in Robust uses this, but it's still an issue...
* Count collection memory across the whole deserialize call
* Add tests for truncated byte-sized reads
* Limit memory used by collection elements
* Dump unmaintained code
* We don't use this for Robust, and we have no good way of ensuring it meets standards. As such, it's better and simpler to drop maintaining all of this...
* Reject string character counts that don't match the decoded text
* Harden against oveallocation

* Shut up tests

(cherry picked from commit 1eb828a)
Axionyxx added a commit that referenced this pull request Nov 6, 2026
* Squash commits

* Let custom serializers declare a minimum value size
* Update docs to match new crap
* More null stuff
* Throw for malformed values and mismatched types
* oops
* Count string memory toward the per-call allocation budget
* To the best of my knowledge nothing in Robust uses this, but it's still an issue...
* Count collection memory across the whole deserialize call
* Add tests for truncated byte-sized reads
* Limit memory used by collection elements
* Dump unmaintained code
* We don't use this for Robust, and we have no good way of ensuring it meets standards. As such, it's better and simpler to drop maintaining all of this...
* Reject string character counts that don't match the decoded text
* Harden against oveallocation

* Shut up tests

(cherry picked from commit 1eb828a)
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.

2 participants