#106888Header x-content-type-options nosniff added twice
Description
The header “x-content-type-options: nosniff” is added twice in the response.
First occurence seems to come from the framework, the other is added in .htaccess.
I checked this is the same in 12.4 and main. Should we set it with “replace” instead of “add” in htaccess maybe? Only adding it in the framework imho also feels wrong, since a static file (not delivered through TYPO3) wouldn’t have the header set.
Reviews 0
No change resolves or names this issue in its commit message, and no comment links one.
History 7
-
Garvin Hicking commented and changed status
NewNeeds Feedback 06/16/25, 08:23 -
Stefan Neufeind commented 06/16/25, 08:40
A customer received a “security-report” which usually would have triggered for a missing nosniff – but in this report (I don’t have details on vendor etc. of that report) it had the text like for wrong/missing headers with explanations but explicitly highlighted “multiple”. With other headers it might be problematic to have multiple (or at least conflicting) occurences, in this case I also don’t think realworld (browsers) have a problem with it.
We might use “replace” instead of “set” in htaccess maybe – it would override the value sent from TYPO3. And it seems this is the only header duplicated by the use of .htaccess, since of course it should refer to static files as well. And removing it from the TYPO3-generated headers would imho also not be ideal, since without the htaccess we’re missing an essential security-header. -
Garvin Hicking commented 06/16/25, 13:50
Thanks for the details, much appreciated.
Did you try the “replace” already, does that work for you? I’m not exactly sure whether apache could overwrite headers from the PHP side.
-
Oliver Hader changed category 08/29/25, 15:14
-
Oliver Hader commented 08/29/25, 15:27
Our default
.htaccesstemplate usesset, which seems to be fine:
https://github.com/TYPO3/typo3/blob/b6945c95a212bf2762ed0a3e67c9f1f911d247d3/typo3/sysext/install/Resources/Private/FolderStructureTemplateFiles/root-htaccess#L381According to the Apache docs at https://httpd.apache.org/docs/current/mod/mod_headers.html,
setresults in “The response header is set, replacing any previous header with this name.” -
Oliver Hader commented and changed status
Needs FeedbackClosed 08/29/25, 15:27Closing this issue. Please reopen, in case you think that the TYPO3 core configuration should be adjusted. Thx!
-
Oliver Hader changed category 08/29/25, 15:29
So, generally the duplicate header is a bit like duplicate slashes in a filesystem. It doesn’t look nice, but it doesn’t really break things.
To my understanding, since Apaches/NGinx HTTP headers are set outside of the PHP execution, the PHP process’s PSR response object itself doesn’t utilize/use the headers set outside of it, and thus cannot “prevent” the output of the header again.
The solution would be to conditionally alter your htaccess to only apply the headers to static files NOT being passed through the TYPO3 AdditionalResponseHeaders middleware, which can get quite obfuscated.
So, honestly… I would just “live” with the duplicate header, because it ensures that both static and dynamic response will receive the HTTP header here.
Do you face any “real-world” problem with the duplicate header?