C++ Runtime DLL's needed in application.. best way to grant security?

J

James Radke

Hello,

I have an asp.net application (using vb.net codebehind), that is calling
some older c++ dlls. These dlls require the use of the c++ Runtime which is
in the windows/System32 directories. What is the best way to get access to
these directories for the web application?

Add the security for IUSR_<system name> to the System32 directory?

Is there a better method?

Thanks!

Jim
 
S

Steven Cheng[MSFT]

Hi James,


Thank you for using MSDN Newsgroup! My name is Steven, and I'll be
assisting you on this issue.
From your description, you'd like to use some older c++ dlls in your
ASP.NET web application. Since these dlls may depend on C++Runtime. You are
wanting some infos on how to generate the access permission so as for those
unmanaged code to be executed properly.
If there is anything I misunderstood, please feel free to let me know.

Based on my research, generally in dotnet, when we need to use some unsafe
code in our application, but we don't want the caller application to have
such high permission. We'd like to use the "Wrapper Code":
here is the description on "Wrapper Code" in MSDN:
------------------------------
Wrapper code, especially where the wrapper has higher trust than code that
uses it, can open a unique set of security weaknesses. Anything done on
behalf of a caller, where the caller's limited permissions are not included
in the appropriate security check, is a potential weakness to be exploited.

Never enable something through the wrapper that the caller could not do
itself. This is a special danger when doing something that involves a
limited security check, as opposed to a full stack walk demand. When
single-level checks are involved, interposing the wrapper code between the
real caller and the API element in question can easily cause the security
check to succeed when it should not, thereby weakening security.
--------------------------------
For more detailed info on secure code in dotnet , you can visit the
following link in MSDN:
#Secure Coding Guidelines
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconsecurecodingguidel
ines.asp?frame=true

As for the situation you described, I think you may first write a wrapper
class to encapsulate those unamanged dlls's functions. This wrapper class
could be a C# or VB.NET assemblies or Managed C++ Asseblies. And then, call
this wrapper component in ASP.NET , thus can make the ASP.NET less strict
on code access security.

Also, as for the "Add the security for IUSR_<system name> to the System32
directory" you mentioned. This only add the permission for the IUSR_<system
name> to access the system32 directory. In fact, by default the ASP.NET's
worker process will run under the MACHINE\ASPNET account , and the code it
executed and resources accessed will use this account to check the
permission. For more information on the ASP.NET security model, you can
have a look at the following tech articles:
http://msdn.microsoft.com/library/en-us/dnbda/html/authaspdotnet.asp?frame=t
rue

http://msdn.microsoft.com/library/en-us/dnnetsec/html/SecNetch03.asp?frame=t
rue

So based on different condition, the account under which ASP.NET process is
executed will be different, you need to set the permission for the
appropriate account in different situations.


In addition, I've searched some problems which may occur when called
Managed or Unmanaged C++ components
in ASP.NET, you may also have a check to see whether it helps:

#BUG: AppDomainUnloaded Exception When You Use Managed Extensions for C++
Components
http://support.microsoft.com/default.aspx?scid=kb;en-us;309694


Please check out the above items. If you have need any assistance, please
feel free to let me know.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

Hi James,


Have you had a chance to check out my suggestion in last reply? If you have
any questions or need any help, please
feel free to post here.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top