Fix stored XSS via BBCode attribute injection#58
Open
az10b wants to merge 1 commit intom1k1o:masterfrom
Open
Conversation
BBCode option values were substituted into HTML templates without escaping. A malformed option like [goal=x" onclick="alert(1)] triggered a ParserException fallback that preserved raw quotes, allowing attribute breakout and arbitrary event handler injection. Apply htmlspecialchars(ENT_QUOTES, UTF-8) to all option values before HTML substitution in CodeDefinition::asHtml(), and to the custom [code] tag's class attribute in Post::parse_content(). 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
[goal=OPTION],[code=OPTION],[img=OPTION]) were inserted into HTML templates without escaping[goal=x" onclick="alert(1)]triggers aParserExceptionfallback in the option parser that preserves raw quotes, allowing HTML attribute breakout and arbitrary event handler injectionhtmlspecialchars(ENT_QUOTES, UTF-8)to all option values before HTML substitution inCodeDefinition::asHtml(), and to the custom[code]tag's class attribute inPost::parse_content()Affected tags
[goal=OPT]<div class="b_goal {option}">{option}— no validator[code=OPT]<code class="OPT">asHtml— no escaping[img=OPT]<img alt="{option}">{option}— no validatorTest plan
[goal=x" onclick="alert(1)]test[/goal]— verify alert does NOT fire on click[code=x" onmouseover="alert(1)]test[/code]— verify alert does NOT fire on hover[img=x" onerror="alert(1)]https://example.com/img.jpg[/img]— verify alert does NOT fire[goal=star]test[/goal]— verify normal usage still works[code=php]echo "hi";[/code]— verify code highlighting still works🤖 Generated with Claude Code