72566

asp.net site throwing a System.Security.SecurityException

Question:

I have an ASP.NET application that was working fine on my server up until last night when I installed a bunch of windows updates, now it's throwing this exception :

System.Security.SecurityException: Requested registry access is not allowed.

Unfortunately there is some things that makes this hard to debug. I added the debug="true" attribute to the web.config file to get the line where the exception is lauched. The line identified in my code is an End If and the code just before seems benign :

<body id="body" runat="server"> <div class="conteneur-confirmation"> <% If Not Session("confirmation") Is Nothing Then Response.Write("<ul><li>" & Session("confirmation") & "</li></ul>") Session.Remove("confirmation") End If %> </div> <div class="conteneur-alerte"> <% If Not Session("Alerte") Is Nothing Then Response.Write("<ul><li>" & Session("Alerte") & "</li></ul>") Session.Remove("Alerte") End If <!-- The exception is supposedly launch from here --> %> <!-- more code -->

The next thing I tough could help me is the stack trace. Here it is :

[SecurityException: Accès au registre demandé non autorisé.] System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) +52 Microsoft.Win32.RegistryKey.InternalOpenSubKey(String name, RegistryKeyPermissionCheck permissionCheck, Int32 rights) +9434757 Microsoft.Win32.RegistryKey.OpenSubKey(String name, RegistryKeyPermissionCheck permissionCheck, RegistryRights rights) +15 System.TimeZoneInfo.TryCompareTimeZoneInformationToRegistry(TimeZoneInformation timeZone, String id, Boolean& dstDisabled) +234 System.TimeZoneInfo.FindIdFromTimeZoneInformation(TimeZoneInformation timeZone, Boolean& dstDisabled) +258 System.TimeZoneInfo.GetLocalTimeZone() +307 System.TimeZoneInfo.get_Local() +116 System.DateTime.ToLocalTime() +60 System.IO.File.GetLastWriteTime(String path) +34 System.Web.Handlers.AssemblyResourceLoader.GetAssemblyInfoWithAssertInternal(Assembly assembly) +93 System.Web.Handlers.AssemblyResourceLoader.GetAssemblyInfo(Assembly assembly) +67 System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrlInternal(Assembly assembly, String resourceName, Boolean htmlEncoded, Boolean forSubstitution, IScriptManager scriptManager) +1159 System.Web.Handlers.AssemblyResourceLoader.GetWebResourceUrl(Type type, String resourceName, Boolean htmlEncoded, IScriptManager scriptManager) +722 System.Web.UI.ClientScriptManager.GetWebResourceUrl(Page owner, Type type, String resourceName, Boolean htmlEncoded, IScriptManager scriptManager) +167 System.Web.UI.ClientScriptManager.RenderWebFormsScript(HtmlTextWriter writer) +158 System.Web.UI.Page.RenderWebFormsScript(HtmlTextWriter writer) +58 System.Web.UI.Page.BeginFormRender(HtmlTextWriter writer, String formUniqueID) +8910479 System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +57 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31 System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +53 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40 ASP.masters_sigiweb2_master.__Renderbody(HtmlTextWriter __w, Control parameterContainer) in C:\Inetpub\v3\Masters\sigiweb2.master:96 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +109 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +31 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Control.Render(HtmlTextWriter writer) +10 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +208 System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +8 System.Web.UI.Page.Render(HtmlTextWriter writer) +29 System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27 System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +100 System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8431 System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +253 System.Web.UI.Page.ProcessRequest() +78 System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +21 System.Web.UI.Page.ProcessRequest(HttpContext context) +49 ASP.default_aspx.ProcessRequest(HttpContext context) +37 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +100 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

It looks like the exception is launch when System.TimeZoneInfo.TryCompareTimeZoneInformationToRegistry try to access the registry and the asp.net identity, IWAM_MACHINENAME, doesn't have the rights. I suppose, one of the Windows update changed the right to some registry keys or the behavior of this function. I did a search on the web for "TryCompareTimeZoneInformationToRegistry" thinking I would find someone else who would have had the same error as me. However Google only return two pages with reference to this function and they're both in Italian.

I guess the solution will be to simply change the access rights to some part of the registry, but I don't know which and it seems there is virtually no informations about this function on the web (weird, no?).

I'd like to add that my server is French version of Windows Server 2003. That and the fact that the only other information I found about it on the Internet is in Italian let me think it may be a problem that would not occur on the English version of Windows, but I can't confirm this.

Thanks for your help.

Answer1:

The registry key HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\TimeZones\Bangladesh Standard Time had their permissions set wrong (probably a problem cause by the <a href="http://en.wikipedia.org/wiki/Windows_Update" rel="nofollow">Windows Update</a> I had just done). I simply copied the permission from another Time Zone Key, that is all right to everyone, and the problem went away.

Now, I hope Google will send people with this problem over here. It was kind of weird to find almost no information about the TryCompareTimeZoneInformationToRegistry function on the web.

Answer2:

The page says that the problem is caused by antivirus software blocking access to the registry. That sounds like a reasonable place to start.

Recommend

  • Adding new Registry entry throws permission error
  • finding daylight saving indication based on offset and suffix of time zone
  • Get events of a specific time range
  • Disable Clock App in Windows 6.5
  • In ASP.NET MVC2, convert time user's timezone. How to get timezone info? [closed]
  • How to take care of DST while comparing time values in C#
  • How to check window's firewall is enabled or not using commands
  • c# add program to windows startup (windows 7)
  • C# get Office ClickToRun Registry Key returns null
  • Hide the Form View in OpenErp (formally as Odoo)
  • SQL Agent Job failes when trying to execute SSIS package due to some permission issues
  • Encapsulation issue with delegates?
  • Angularjs: How to intercept errors in external url $resource or $http service?
  • IIS7.5 WCF Service - HTTP Error 401.3 (Even after adding IIS_IUSRS)
  • “icudtl.dat not found in bundle” when launching custom branded Chromium build on Mac?
  • Importing matplotlib.pyplot fails in PyCharm due to AttributeError: module 'PyQt5.QtGui' h
  • svn checkout challenges for a password when running unattended in TeamCity
  • NSFileManager.defaultManager().createFileAtPath() returning false
  • Add a service in Mac Finder using CLI
  • Convert a statement with adjective in RDF triple
  • Gerrit branch access modification through command line
  • Restrict Jenkins Job To Linux Slaves
  • Automating Download of Site Dynamically generated http file
  • UWP App Installation without admin rights, powershell interaction and without Windows Store?
  • Maven RPM Plugin does not generate the scriptlets specified
  • iOS memory constantly increasing in app seemingly for no reason
  • Typing the command “cake” in console shows no output
  • How can you examine lib files?
  • Editing templates in Adobe Business Catalyst
  • How to build latest Qt from Git repository on windows?
  • Unexpected characters returned when reading email using ImapX
  • Context is Missing when using Unobtrusive ajax in asp.net mvc-3
  • CDATA getting stripped in lxml even after using strip_cdata=False
  • SWIFT uiviewcontroller init
  • Replacing elements in a list of lists
  • Some confusions about Command Line Compiler and MSBuild
  • Programmatically getting SQL Cluster Virtual Name
  • activity diagram - call operation example with parameters?
  • How to implement HTTPS in laravel 5.4
  • DateTime.Today for a specific time zone