Conversation
A reference in HTML that comes from untrusted content, e.g. [[../config.neon]] in a user's message, embedded any readable file into the email. A reference to a file that is missing, is not an image or is outside the base path now throws Nette\InvalidArgumentException (a missing file threw Nette\IOException before). [[...]] may be just a text, so it is left untouched in such a case. Co-Authored-By: Claude Opus 5.5 <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.
This was an excellent gun how to shoot yourself in the foot. An innocent code like
$message->setHtmlBody('<img src="assets/logo.png">' . htmlspecialchars($userText), 'assets')allowed embedding any server file in the message. A text like[[spoiler]]used in the message threw an exception.setHtmlBody($html, $basePath)embedded any file that a reference in the HTML pointed to, including../paths. The[[...]]placeholder is matched anywhere in the text and HTML escaping doesn't touch it, so when the HTML contains text from users (e.g. a notification about a private message), a user writing[[../../config/local.neon]]got that file attached to the email.Now only images inside the base path are embedded:
<img src>,<body background>,url(...): a reference to a file that is missing, is not an image or is outside the base path throwsNette\InvalidArgumentException.[[...]]: left untouched in such a case, because it may be just text, so text from users cannot make building the email fail either.BC breaks:
<img src="../images/x.png">) or to a non-image (e.g. a font inurl(...)) throws instead of being embedded.Nette\InvalidArgumentExceptioninstead ofNette\IOException.🤖 Generated with Claude Code