Code: Select all
#
#--[ FIND (in download.php, in function send_file_to_browser) ]--
#
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
header('Content-Type: ' . $attachment['mimetype']);
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie') !== false))
{
header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false))
{
header('expires: -1');
}
}
else
{
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
}
#
#-----[ REPLACE WITH ]------------------------------------------
#
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
if (substr($attachment['real_filename'], -4) == ".mp3")
{
header('Content-Type: audio/mpeg');
}
else
if (substr($attachment['real_filename'], -4) == ".pdf")
{
header('Content-Type: application/pdf');
}
else
{
header('Content-Type: ' . $attachment['mimetype']);
}
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie') !== false))
{
//header('Content-Disposition: attachment; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
if (empty($user->browser) || (strpos(strtolower($user->browser), 'msie 6.0') !== false))
{
header('expires: -1');
}
}
else
{
//header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename(htmlspecialchars_decode($attachment['real_filename'])));
}
Congratulations. You have just introduced an persistent XSS vulnerability into your board.Mårten Berglund wrote: Here comes the fix:
I may not have done the fix in the best manner. Please tell me how to do it better, keeping security and still keeping the feature that pdf's and mp3's will open in the browser window.christhatsme wrote:it was written like that for a reason, I'm not sure if its entirely wise changing that...
Please tell me how to do it better if it's possible.Kellanved wrote:Congratulations. You have just introduced an persistent XSS vulnerability into your board.Mårten Berglund wrote: Here comes the fix:
The vast majority of boards are very much public, rather than private. If we were to go the majority route, the default would be the way they are right now. If we were to go the most secure route (don't let marketing talk fool you, you can never be 100% secure), it would be the way things are right now. If you feel the benefit outweighs the risk for you, feel free to go for it, but I don't think it wise for us to implement an on/off switch as people will probably get the "feature fever" and turn it on (as they do with HTML on phpBB2) without realizing its implications.Mårten Berglund wrote:It can't be that unusual that forums are internal. Therefore, phpBB3 should have a radio button option that by default disables this feature, but, with care, could be enabled by the forumadmin. Don't you think?