Web Server Misconfiguration: Insecure Content-Type Setting
Summary
Almost all browsers are designed to use a mime sniffing technique to guess the content type of the HTTP response instead of adhering to the Content-Type specified by the application in specific cases or ignoring the content when no mime type is specified. Inconsistencies introduced by the mime sniffing techniques could allow attackers to conduct Cross-Site Scripting attacks or steal sensitive user data. WebInspect has determined that the application fails to instruct the browser to strictly enforce the Content-Type specification supplied in the response.
Web server misconfiguration can cause an application to send HTTP responses with the missing Content-Type header or specify a mime type that does not match up accurately with the response content. When a browser receives such a response, it attempts to programmatically determine the mime type based on the content returned in the response. The mime type derived by the browser,however, might not accurately match the one intended by the application developer. Such inconsistencies have historically allowed attackers to conduct Cross-Site Scripting or data theft using Cascading Style Sheets (CSS) by letting them bypass server-side filters using mime type checking and yet have the malicious payload with misleading mime type specification executed on the clientside due to the browser mime sniffing policies.
Microsoft Internet Explorer (IE) introduced the X-Content-Type-Options: nosniff specification that application developers can include in all responses to ensure that mime sniffing does not occur on the client-side. This protection mechanism is limited to Microsoft Internet Explorer versions 9 and above.
Explanation
By failing to dictate the suitable browser interpretation of the response content, application developers can expose their users to Cross-Site Scripting or information stealing attacks.
Execution
1. Build a test page that includes a reference to an external JavaScript or CSS resource
2. Configure the server to return the external resource with an incorrect mime type specification
3. Visit the test page using an old version of Microsoft’s Internet Explorer (version IE 8) browser
4. Interpretation of the external content as JavaScript or CSS by the browser despite the misleading mime type specification indicates a potential for compromise.
Recommendation
Configure the web server to always send the X-Content-Type-Options: nosniff specification in the response headers. In addition, ensure that following safety precautions are also put in place:
1. Verify that the web server configuration will send the accurate mime type information in the Content-Type header of each HTTPresponse.
2. Configure the server to send a default Content-Type of text-plain or application / octetstream to tackle failure scenarios.
3. Ensure that appropriate Character Set is specified in the Content-Type header.
4. Configure the server to send Content-Disposition: attachment; filename = name; for content without an explicit content type specification.
Example
In this example shows a header request the value "X-Content-Type-Options" is "nosniff", this value indicate that this protection is enable.
References
Microsoft Internet Explorer:
MIME-Handling Change: X-Content-Type-Options: nosniff
https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/compatibility/gg622941(v=vs.85)?redirectedfrom=MSDN
MIME-Handling Changes in Internet Explorer
https://docs.microsoft.com/en-us/archive/blogs/ie/mime-handling-changes-in-internet-explorer
https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2010-0654

Comments
Post a Comment