Fix: Reject HTML/JS in player and game name changesets#2627
Open
xovishnukosuri wants to merge 2 commits intoOWASP:masterfrom
Open
Fix: Reject HTML/JS in player and game name changesets#2627xovishnukosuri wants to merge 2 commits intoOWASP:masterfrom
xovishnukosuri wants to merge 2 commits intoOWASP:masterfrom
Conversation
Closes OWASP#2521. Players could join a game after it had started by navigating directly to the join URL, allowing them to watch and vote without being dealt any cards. This adds a started_at check in both the join page mount (PlayerLive.Index) and the player creation handler (PlayerLive.FormComponent) to block joining started games. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevent raw malicious HTML/JS content (e.g. <script> tags) from being stored in the database by adding validate_format to Player and Game changesets. Names containing < or > characters are now rejected. Fixes OWASP#2555 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
validate_formattoPlayer.changeset/2andGame.changeset/2to reject names containing<or>characters<script>alert('XSS')</script>) from being stored in the databaseFixes #2555
Details
The
namefield in bothPlayerandGameEcto schemas previously only validated presence and length. This allowed arbitrary HTML/JS payloads to be stored in the database. While Phoenix auto-escapes output (preventing immediate XSS), storing raw dangerous content is a data integrity risk -- especially if the data is later used in raw templates, CSV/JSON exports, emails, or admin views.The fix uses
validate_format(:name, ~r/\A[^<>]*\z/)which rejects any name containing angle brackets. This is a minimal, targeted change that fits the existing changeset validation pattern.Test plan
create_game/1 rejects name containing HTML tagscreate_player/1 rejects name containing HTML tags<script>or<img>payloads in names are rejected with a clear error🤖 Generated with Claude Code