In a recent entry, I outlined the steps to access a secure network resource using a specific Windows account. My technique relies on the COM+ infrastructure to run the code that accesses the secure network resource using a different security context than ASP.NET.
I’m using this rather complex workaround because I want to avoid calling the Win32 LogonUser() API. This API requires (at least under Windows 2000) the presence of the SE_TCB_NAME privilege on the account that is calling LogonUser(). This dramatically elevates the privileges of the ASPNET account, which is an unacceptable risk should your server application become compromised. Microsoft has a KB article on this issue: Q306158. Their workaround involves either running the aspnet_wp.exe worker process as SYSTEM or adding the SE_TCB_NAME privilege to the ASPNET account. Clearly, neither of these are acceptable alternatives.
Instead, if you use the COM+ infrastructure to run your data access code, you are effectively letting Microsoft call LogonUser() for you. You have the added benefit of never exposing user names and passwords to your code; instead these are all managed using by COM+ via the Data Protection API (DPAPI).
However, simply running your data access code as a COM+ application is not sufficient, since that code could be subjected to luring attacks. If your ASP.NET application can call your data access code, why can’t a rogue application?
I use a two-pronged approach to prevent luring attacks. The first restricts the call based on the identity of the user who is running the code that makes the call. I use COM+ role-based security to assert that the user is a member of the TrustedCallers role. An administrator assigns the appropriate account (typically the ASPNET account) to this role at deployment-time.
The second restricts the call based on the identity of the assembly who makes the call. Here, I use Code Access Security to perform a Link demand that the immediate caller on the call stack is indeed a trusted assembly (typically this is the assembly that contains the application logic for the application).
By using these techniques, I avoid the need to use the LogonUser() API as well as preventing luring attacks. I’ll post a simple sample application in the next few days that illustrates the technique. Comments on this technique are, as usual, always welcome.
2 archived reader comments
Robert Hurlbut (2003-09-05)
I was just thinking about this very thing on my way into work this morning! I remember implementing a specific COM+ solution for a client much like this about 8 months ago in order to avoid calling the LoginUser() API. I used it to further secure an ASP folder location (that was already using SSL) to allow access and maintenance using NT Groups. I was thinking this morning this could be further extended into the ASP.Net world much like what you posted here. Thanks for the timely info.
Tor (2003-09-07)
On Windows Server 2003, elevated privileges are no longer required for using LogonUser, according to the article at http://msdn.microsoft.com/library/en-us/dnwebsrv/html/programwse2.asp.