Re: limited account permission and writing to system areas?



you shouldn't write to Program Files or HKLM in components that are run by normal users...Use their profile and HKCU instead.


-----
Dominick Baier (http://www.leastprivilege.com)

Developing More Secure Microsoft ASP.NET 2.0 Applications (http://www.microsoft.com/mspress/books/9989.asp)

I'm dealing with a security problem in a global assembly that I've
created and need some guidance.

The assembly is used by many different client programs, so the
installer of each one installs it in the Global Assembly Cache (which
may end up with multiple versions in a side-by-side fashion).

The assembly reads and writes to a file in the C:\Program Files\Common
Files\<CompanyName> sub-folder.

It also writes to a registry key in HKLM\Software\<CompanyName\...
sub-key.

Both of these happen during both installation and run-time operation.

In terms of reducing my dependency on priviledged operations... I
could theoretically get rid of the latter (i.e. the reg key write),
because it only writes the name of the file that I created with the
former (i.e. in the <CommonFilesFolder>\<CompanyName\... subfolder).
That is, I could fix the filename to one specific filename and always
assume that one filename, so I wouldn't need to update the registry
key. However, since the assembly is used by different users, I don't
know where else to put it besides somewhere that is non-user-specific.
I suppose that putting it in <AppDataFolder> would be more appropriate
than <CommonFilesFolder>, but I don't think that will solve my
problem. And once it is in a non-user-specific location, I have
trouble accessing that location to write a file on a limited account.

I've read (without much comprehension, unfortunately) about security
attributes that I can add to my assembly indicating what kinds of
permissions I need. However, I've seen things like:

[assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum,
All="C:\\example\\sample.txt")]

Is this for real? I can only use this if I hard-code the path to the
file I want access to? That can't be the way this really works, is it?

At the very least, can't we abstract some of the path (c.f.
Environment.SpecialFolder.CommonProgramFiles rather than "C:\\Program
Files\Common Files...").

The assembly *installs* okay because we encourage users to run the
setup with 'Run as Administrator' (in Vista, and as Administrator on
XP), without which, we couldn't install in the global assembly cache.
I'm hoping that I can specify some attributes or even run-time
requests that basically say, "If the user installs this as an
administrator, then whenever this code is used, it will automatically
be allowed to write to that file system location".

Is such a thing possible?

Thanks,
Bob


.



Relevant Pages

  • limited account permission and writing to system areas?
    ... I'm dealing with a security problem in a global assembly that I've created ... filename to one specific filename and always assume that one filename, ... The assembly *installs* okay because we encourage users to run the setup ... with 'Run as Administrator', without ...
    (microsoft.public.dotnet.security)
  • Re: SP2 Will Not Install
    ... SP2 installed without a hitch with your excellent instructions. ... "Judy" wrote: ... is Administrator. ... Remove Admin and Sys afterwards whether SP2 installs or not. ...
    (microsoft.public.windowsupdate)
  • Re: Win7 VirtualStore Weirdness with Excel 2002 and earlier
    ... It explains why I don't have this issue with my installs, and raises an issue Peter will face if he tries to use the NTFS permissions project in his installer on 'Program Files'. ... Here's the solution I found to fix all these issues and prevent UAC from interfering with my apps and their ability to write to their folders/subfolders. ... My knowledge of all the new permissions is woefully lacking but AFAIK nothing should be writing to Program Files except setup Apps. ...
    (microsoft.public.excel.programming)
  • Re: SP2 Will Not Install
    ... Nice work getting SP2 installed. ... Judy wrote: ... is Administrator. ... Remove Admin and Sys afterwards whether SP2 installs or not. ...
    (microsoft.public.windowsupdate)
  • Re: SP2 Will Not Install
    ... "Judy" wrote: ... Everyone is the only one listed in Permissions. ... If I click Advanced, under the Owner tab, under “Current owner of this item” is Administrator. ... Remove Admin and Sys afterwards whether SP2 installs or not. ...
    (microsoft.public.windowsupdate)