add server side validation of image URLs - #13432
Open
rbentcw wants to merge 2 commits into
Open
Conversation
rbentcw
marked this pull request as ready for review
February 20, 2026 22:18
rbentcw
requested review from
Rotorsoft,
kurtassad and
timolegros
as code owners
February 20, 2026 22:18
kurtassad
approved these changes
Mar 19, 2026
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.
Link to Issue
Closes: Internal
Title: Add server-side image URL validation to command schemas
Summary
ImageUrlZod schema that validates image URLs using the existingisValidImageUrl()utility (HTTPS + image extension,data:image/, oripfs://)ImageUrlvalidation to all 15 image URL fields across command schemas(communities, users, contests, quests, tokens, bot-contest, magic login)
checkIconSize()so it only fetches fromassets.commonwealth.imands3.us-east-1.amazonaws.comDetails
Previously, most image URL fields in command schemas accepted bare
z.string()with no formatvalidation. The client already used
isValidImageUrl()for rendering guards, but the serveraccepted anything. This brings server-side validation in line with the client.
Only command schemas (write path) are changed. Entity and query schemas (read path) are
untouched to avoid breaking reads of existing data.
Test plan
pnpm -F @hicommonwealth/schemas check-typespassesimage)
data:image/andipfs://URLs are accepted