Repository navigation
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>
|
Thanks, Jakub, this was a real hole: It's going into master in a narrower form, with you as the author, and that commit will close this PR. The check applies only to |
|
Thanks. Feel free to update the docs according to the final state. |
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