Sitecore Hardening - Limiting Access to .XML, .XSLT, and .MRT Files , Issues & how to fix it
There was a vulnerability reported related to robots.txt during
a pen test.
In this case, it has been detected that information is being
disclosed about the path of the sitemap.xml file which list all the endpoints
of the application.
In the same vein, sitemap.xml reveals information about the
features of the application's private section.
To resolve the solution was to limit access to .xml files,
which is suggested by Sitecore
https://doc.sitecore.com/xp/en/developers/93/platform-administration-and-architecture/limit-access-to-xml,-xslt,-and-mrt-files.html
But in spite of updating the web.config with the handlers mentioned
below the Sitecore website was ignoring the handlers and still continuing to
process the sitemap.xml like a normal request.
<add path="*.xml"
verb="*" type="System.Web.HttpForbiddenHandler"
name="xml (integrated)"
preCondition="integratedMode"/> <add
path="*.xslt" verb="*"
type="System.Web.HttpForbiddenHandler" name="xslt
(integrated)" preCondition="integratedMode"/> <add
path="*.config.xml" verb="*"
type="System.Web.HttpForbiddenHandler" name="config.xml
(integrated)" preCondition="integratedMode"/> <add
path="*.mrt" verb="*"
type="System.Web.HttpForbiddenHandler" name="mrt
(integrated)" preCondition="integratedMode"/> |
This was confirmed by looking at IIS Logs
2022-01-18 07:23:50 127.0.0.1 GET /portal/sitemap.xml - 80 -
127.0.0.1 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/97.0.4692.71+Safari/537.36
- 200 0 0 15
|
Deep dive analysis revealed that the static file handler was
overriding the . xml (integrated)handler
<add
name="StaticFile" path="*" verb="*"
modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"
resourceType="Either" requireAccess="Read" /> |
So, there were
two possible solutions to overcome this behavior
Option 1 - Remove
static file handler
But this
solution will impact on other static files served from the app service
<handlers> <remove name="StaticFile" /> |
Option 2 – File
Extension Filtering (Preferred)
<security> <add fileExtension=".xslt " allowed="false" /> |
Comments
Post a Comment