Repository navigation
Bound size values inside resource packs - #120
Merged
Merged
Conversation
PackLimits capped entry counts, entry bytes and texture sides, but several values inside a pack act as sizes and were not covered, so a small pack could ask for gigabytes when rendered or registered. - GUI sprite scaling: cap the normalized copy at 4M pixels. - Bitmap fonts: height at most 2048, ascent at least -2048, and a 16M pixel cap on one scaled glyph. - TTF fonts: size at most 256, oversample 1 to 16, product at most 512, a 4M pixel cap per glyph cell, one parsed font per file per pack and at most 64 TTF files per pack. - Animations: stop at the 1200 frames that can ever play. - Item models: at most 64 models per composite item; enforce the 4096-element cap when a model is parsed. - Registration: PackLimits.maxIndexBytes (default 256 MiB) bounds the item and model JSON read while indexing. - Textures: PNG only, and at most 16M pixels whatever the per-side cap. - Stop listing registered packs in the unknown-pack error, keep full filesystem paths out of pack-open errors, reject a dot-only namespace, and apply the real-path check in DirectoryPackSource.exists.
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.
Why
Follow-up to the security review (see #116).
PackLimitscapped entry count, entry bytes and texture side length, but several values inside a pack act as sizes and were not covered. A small pack could ask for gigabytes when one of its sprites, fonts or items was rendered, or when it was registered. This matters most for packs the host did not author.Path handling was reviewed and found sound (zip slip,
.., symlink escape, reference validation); this PR does not change it beyond two small tightenings listed at the end.What changed
tile/nine_slicesizeheightascentat least -2048; one scaled glyph capped at 16M pixelssize/oversamplePackLimits.maxIndexBytes(default 256 MiB) bounds item and model JSON read while indexingAlso:
DirectoryPackSource.existsapplies the same real-path containment check asread.Compatibility
PackLimitsgains a sixth record component,maxIndexBytes. The existing four- and five-argument constructors still work and use the default;fromSystemPropertiesreadsgenerator.pack.maxIndexBytes. Code that deconstructs the record by pattern would need updating.Not in this PR
RuntimeExceptionfrom pack JSON intoPackResolveException.Testing
PackSizeLimitsTest(11 tests), one per row above plus the namespace, limits-default and error-message changes.pack/**,tools/pack/**and the pack-facing generator tests pass. The full suite was not run locally.