Re: Questions and observations about CAS and the StrongNameIdentityPermssionAttribute.

From: Nicole Calinoiu (calinoiu)
Date: 08/30/05


Date: Tue, 30 Aug 2005 16:43:38 -0400


"John Sheppard" <John.Sheppard@newsgroups.nospam> wrote in message
news:uU6v20ZrFHA.1128@TK2MSFTNGP11.phx.gbl...
<snip>
> Secondly let me pose a question. Is this the official MS answer on
> this subject?

I don't work at Microsoft, so no. <g> I haven't seen anything directly
relevant in the "official" docs yet. The most on-point statement that I
know of from a Microsoft employee is on Eugene Bobukh's blog at
http://blogs.msdn.com/eugene_bobukh/archive/2005/05/06/415217.aspx.

> Because if it is that sucks.

I actually tend to agree (at least partially), so don't shoot the messenger.
<g>

> Not only does it suck it seems very illogical. Why have CAS then if a
> fully trusted assemblies can override your demanded criteria.

Fully trusted code can bypass CAS entirely by calling into unmanaged code
directly, so the ability to bypass any given permission isn't considered a
security hole.

> Think about this. Say I have an object library assembly whose classes I
> have decorated to demand that inheritors and or callers be signed with a
> certain strongnamekey. This works fine as long as I do not fully trust
> the implementation / calling code.

No, it works fine as long the user does not grant unrestricted permissions
to the calling code. You might want to keep in mind that CAS is meant to
prevent the user, not the developer or his code.

> My object library is protected in this scenerio. Or lets say I want to
> have multiple levels of access to my API based upon the SNK of my
> callee/inheritor. Again as long as I do not fully trust the
> calling/implementing assembly all is fine. Now regardless of what the
> object library developer wishes are on this subject I developer B want to
> use he object library so I fully trust the code calling his stuff and
> viola I can now use it. This has ramifications for not only SNIP but
> reflection and I presume FileIO as well.

Code running with an unrestricted permission grant (full trust) always
passed all demands for ReflectionPermission and FileIOPermission. The only
demands it didn't automatically pass were those for identity permissions
that corresponded to evidence it did not have. In v. 2.0, those have been
added to the pass list.

> So if I don't want somebody dynamically reflecting over my code and
> calling private methods I am just SOL.

Yup, and you always were. In addition to highly privileged code being able
to deliberately bypass permission verifications, the user could always
disable CAS entirely if he deliberately wanted to enable bypassing of your
protections.

> This is scary and from my perspective just plain wrong.

Only if you're counting on CAS to protect your code from callers that you
consider "undesirable" even if your users don't. Granted, there's plenty of
documentation out there (including quite a bit that came directly from
Microsoft or was sponsored by Microsoft) that suggests that CAS can do this.
Unfortunately, it's pretty much all wrong even with respect to version 1.x.

> So before I drive out to Redmond and ask Bill why please tell me I'm
> wrong.
>
> Again thanks for the answers but now I have to go take my blood
> preasure medication.
>
> John
>



Relevant Pages

  • Re: Print function name of calling function?
    ... print the name of the function calling f3which could either be f1 ... In gdb it is possible to get a call trace, how can gdb get the call ... You still might not have permission to access it in any case. ... No, you can't depend on having dynamic-linked libraries, ...
    (comp.lang.c)
  • Re: Using output variables
    ... The problem lies in the Web page that calling ... DECLARE @permission int ... EXEC GetPermissions @PID,@UserID,@permission OUTPUT ... > I have the Page calling the stored proc and the proc ...
    (microsoft.public.sqlserver.programming)
  • Re: Permissions Question?
    ... Calling an illegal alien an "undocumented worker" is like calling a ... drug dealer an "unlicensed pharmacist" ... telling me that I don't have permission to run that file. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: What inspires you to practice?
    ... thought that i was calling your office,i was tiold it was your office ... No third grader would want to play like that. ... have only my permission to post the trumpet playing. ... I don't need your permission to post anything, ...
    (rec.music.makers.trumpet)
  • Re: Why arent you upgrading?
    ... uses some superior approach to calling into Win32. ... VCL.Net is just another lib calling just some native DLLs from a CAS POV. ... SWF uses native calls that are declared inside mscorelib or inside the SWF assembly itself. ... IMHO, CAS is one of the few *real* features, that .Net can offer over native development. ...
    (borland.public.delphi.non-technical)