|
SecuringErrorLogPages
Securing Error Log PagesYou can secure ELMAH's display or feeds in two ways:
Both of these are discussed in the sub-sections that follow. Why is this so important? See ASP.NET session hijacking with Google and ELMAH. Enabling or Disabling Remote AccessELMAH provides a configuration section and a setting to enable or disable remote access to the error log display and feeds. When disabled (the default), only local access to the error log display and feeds is allowed. The snippet below shows how to enable remote access: <elmah>
<security allowRemoteAccess="1" />
</elmah> Remote access is enabled when the value of the allowRemoteAccess attribute is either 1, yes, true or on. Otherwise it is disabled. Local access is always available. Note: Make sure you have declared the expected configuration sections in order to apply the above configuration. See Declaring configuration sections for more. Granting or Denying Access via ASP.NET AuthorizationIf you must enable remote access, it is paramount that you also secure access to only authorized users. You can do this using ASP.NET's built-in authorization mechanism. Different locations in a web site can be secured with different authorization rules. Suppose your web application is deployed at http://www.example.com/ and ELMAH is configured to respond to elmah.axd. You can secure http://www.example.com/elmah.axd from unauthorized users by adding a location element to your configuration as follows: <location path="elmah.axd">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
<authorization>
<deny users="*" />
</authorization>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH"
verb="POST,GET,HEAD"
path="elmah.axd"
type="Elmah.ErrorLogPageFactory, Elmah"
preCondition="integratedMode" />
</handlers>
</system.webServer>
</location> There are three important things to note here:
The configuration example above denies access to all users, but that is a good starting point. You will probably want to add rules that allow access to only specific users and/or roles. For example, you might have a role for administrators and developers called admin and dev, respectively. To allow users that are members of either role, you could configure the authorization section above as follows: <authorization>
<allow roles="admin" />
<allow roles="dev" />
<deny users="*" />
</authorization> Further InformationFor more information, see also:
|
I also found this to be useful: http://stackoverflow.com/questions/1245364/securing-elmah-in-asp-net-website
This also assumes you have <authentication mode="Windows" /> Using "None" won't work.
The stackoverflow link is a good one, I came here with the same question.
I still don't see how to secure the rss feed though. Isn't denying access via .NET Authrization moot if someone can guess your rss URL and subscribe to it?
Hi azizatif,
The <location path="elmah.axd"> is not safe at all. Anyone who can bypass the location restriction by prepend path before the almah.axd.
For example, Anyone can request elmah.axd by http://xxxx.xxx/a/b/c/d/elmah.axd that can by pass the <location path="elmah.axd"> limitiations!!
-Will
I think a better way of implementing this would be to set up elmah as : <add verb="POST,GET,HEAD" path="/admin/elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
This ensures that elmah.axd is available only under the 'admin' folder and nowhere else. After that it simply becomes a case of securing a resource which can be done using roles or user accounts. A sample of what we did is given below:
<location path="admin/elmah.axd">
@rahul's idea is awesome. I changed my implementation to only handle it under the admin folder too. Thanks!
@rahul's idea is very bad! Call the "url"/"anything"/admin/elmah.axd ...
Take a look at this: http://www.troyhunt.com/2012/01/aspnet-session-hijacking-with-google.html
Here is an example using a utility
http://www.perficient.com/Solutions-and-Services/Business-Integration-SOA/Reusable-Utility-Services
Best way we've implemented this is, create a second website, point Elmah to the same database wher e you log errors from the first site, and IPSEC protect the second website to only allow certain Ipaddresses to access. Turn off remoteaccess to Elmah on the first website.
Summary:
Not to nit-pick, but the use of grammar here is in need of some improvement. A better way to say what you are trying to say would be:
Where do we place the Authorize config section ?
This also assumes you have <authentication mode="Windows" /> Using "None" won't work. http://wdfshare.blogspot.com