Repository navigation
Conversation
- Fetch skins over HTTPS, without following redirects. - Only request a bare alphanumeric texture ID; reject anything else instead of appending it to the texture host URL. - Cap the skin download at 1 MiB and check the PNG header size (64x32 to 1024x1024) before decoding. - Clamp upscale to 4x and downscale to 64x. - Share one Mojang API client with explicit timeouts instead of building two HTTP clients per generator. - Report a missing skin and malformed texture values as GeneratorException instead of NullPointerException and ClassCastException.
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). The player head generator fetched skins over plain HTTP with no size limit, let some caller text through into the request path, and built new HTTP clients on every use.
What changed
Skin fetch (
MinecraftPlayerHeadGenerator)https://textures.minecraft.netand redirects are not followed. Previously it washttp://, so anyone on the network path could substitute the image.../,?query, and so on); it is now rejected. Theurlinside a base64 texture value contributes only its last path segment.scaleis clamped: at most 4x up (the head render is already 1250 px square) and 64x down.Mojang client (
MojangApiClientFactory)sharedInstance(), used by the generator's builder.defaultInstance()built twojava.net.http.HttpClients on everyBuilder.build().Error handling
textures/SKIN/url, now fail withGeneratorExceptioninstead ofNullPointerExceptionorClassCastException.Behaviour changes to be aware of
withScaleabove 4 or below -64 is clamped silently.Heads.besideTooltipdocuments null as "the default head", but that path always threw; no default head asset exists in the repo.Testing
MinecraftPlayerHeadGeneratorTest, none needing the network: size limits, non-PNG content, path-changing texture IDs, missing skin, malformed texture values.MinecraftPlayerHeadGeneratorTest,ItemToolTestandDialogueToolTest: 29 tests pass.