Setting up secure custom Web Controls

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Setting up secure custom Web Controls

    I've read through "Building Secure MS ASP.NET Applications", and "Improving
    Web Application Security", but I'm a little confused about how to properly
    set up security.

    I am building a few controls/components that will be used by another party
    in their own web app - and I have no involvement in the actual web app, only
    these custom controls/components. One of my custom controls relies on the
    Infragistics WebTree control.

    Right now, my controls/components are split up into 3 assemblies, and
    because of this, some methods/properties have to be public even though only
    my own assemblies should be able to call these 'public' methods/proprties.
    I also want to ensure in some cases that only my own assemblies can have
    classes that inherit from other classes in my assemblies. I understand that
    if I strongly name my assemblies, then I can use an attibute on the 'public'
    members to ensure that only my own assemblies can call them. However, I
    start to get confused, because it seems I start to get into issues of full
    trust vs. partial trust, demands vs. link demands, asserts, and APTCA. I'm
    not completely sure when I need to be concerned with each of these things.
    Finally, I want to have an additional satellite assembly (that will be more
    frequently updated, and backwards compatible with my other assemblies).
    This satellite assembly will contain an Xml 'file' in a resource that only
    my assemblies should have access to.

    My controls will only function in an ASP.NET web-app, but some of my
    components and classes may be used in a non-ASP.NET and/or ASP.NET
    environment. What do I need to do to keep things secure, yet still
    functional in a web-app?

    As far as I can tell I have to:

    - Mark my assemblies with APTCA
    - Strongly name my assemblies and have them installed in the GAC (but what
    happens if the consumer of my controls just put's them in the web-apps \bin
    dir instead)?
    - use full demands on public members I want to secure (but also user
    asserts on my assembly code that calls these members to deal with stack-walk
    issues)
    - encrypt the Xml in my satellite resource assembly, and secure the method
    that will provide a decrypted version of the resource
    - use a publisher policy file(/assembly?) to enable me to update the
    sattelite assembly containing the Xml resource without having to update my
    other assemblies while using strong names for all assemblies


    Have I got it right? Is there an easier way? At this point, I'm seriously
    considering just packaging everything into a single assembly (.dll) to avoid
    all the hassles.


    cpnet Guest

  2. Similar Questions and Discussions

    1. communication between an application, custom controls, and user controls
      Hi, and many thanks in advance... I'm a little lost about how to proceed with communication between an application, custom controls, and user...
    2. Setting default playback controls
      I was wondering if there is anyway to set the default playback controls for captivate. (i.e. I would like the Halo playback control to be the...
    3. Why the properties of web user controls which inherted from my custom base UI controls MISSED?
      Why the properties of web user controls which inherted from my custom base UI controls MISSED? How should I to set enable?
    4. Accessing Properties of Custom Controls child Controls
      I am using a Custom Control on a page which renders a button control if required. I need to access the child button control's properties (i.e....
    5. Secure Database-Driven output to Web-Controls like Repeater
      scenario: users can store data (guestbook entries, ther usernames and so on) on a database-driven website and i have to care about that they don't...
  3. #2

    Default RE: Setting up secure custom Web Controls

    Hello,

    As my understanding, you have a Web control and several sub assemblies
    which will called by the web control. You want only the webcontrol can call
    the sub assemblies. Is this right?

    I think you may consider the StrongNameIdentityPermission Attribute for the
    issue:

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/[/url]
    frlrfsystemsecuritypermissionsstrongnameidentitype rmissionattributeclasstopi
    c.asp

    For more about Code Access security:

    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm[/url]
    l/cpconCodeAccessSecurity.asp

    Hope this help,

    Luke

    [MSFT] Guest

  4. #3

    Default Re: Setting up secure custom Web Controls

    Hi Luke,

    I have read the content at the links below (most of it is actually contained
    in the books I mentioned). However, it seems that since these assemblies
    have methods/classes that will be used by an ASP.NET application, then I
    have to include the AllowPartiallyTrustedCallersAttribute in my assemblies.
    But then it seems you get into link demands, and worrying about stack
    walking etc. I'm not clear from this content, which of these things I need
    to worry about to properly secure my assemblies, make sure only my own
    assemblies can call certain public methods within my assemblies, make sure
    that the ASP.NET app code can call my 'unsecured' public methods and so on.

    To try and be more clear about the steps I think I need to take, I think I
    need to:

    - Mark my assemblies with APTCA (i.e. use the
    AllowPartiallyTrustedCallersAttribute attribute)
    - Strongly name my assemblies and have them installed in the GAC (but what
    happens if the consumer of my controls just put's them in the web-apps \bin
    dir instead)?
    - use full demands (ie use the StrongNameIdentityPermission attribute) on
    public members I want to secure (but also user
    asserts on my assembly code that calls these members to deal with stack-walk
    issues)
    - encrypt the Xml in my satellite resource assembly, and secure the method
    that will provide a decrypted version of the resource
    - use a publisher policy file(/assembly?) to enable me to update the
    sattelite assembly containing the Xml resource without having to update my
    other assemblies while using strong names for all assemblies

    Is all of the above necessary, or do I have anything wrong?

    Thanks,
    cpnet



    cpnet Guest

  5. #4

    Default Re: Setting up secure custom Web Controls

    From the description. I think all of the steps listed are necessary for the
    issue. By the way, when you put a strong named assembly in GAC, it can be
    assecced by all application on the computer. If it was in web-apps \bin,
    only the web app can access them directly. Other application need to know
    the exact path to access it.

    Luke

    [MSFT] Guest

  6. #5

    Default Re: Setting up secure custom Web Controls

    Ok, thanks. I do realize that stuff in the GAC can be used by all apps, but
    my understanding was that if I didn't put stuff in the GAC, then the strong
    naming and security attrbutes etc. won't work properly. In other words, I
    thought that to be able to use the StrongNameIdentityPermission attribute on
    my public methods to ensure only my own assemblies can call these methods, I
    had to put my assembiles in the GAC?


    cpnet Guest

  7. #6

    Default Re: Setting up secure custom Web Controls

    GAC is just used for sharing an assembly among several applications. It is
    not a pre-requisite for StrongNameIdentityPermission. Here is an article
    about GAC:

    Working with Assemblies and the Global Assembly Cache
    [url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/htm[/url]
    l/cpconworkingwithassembliesglobalassemblycache.asp

    You assembly should have a strong name, but can be out of GAC.

    Luke

    [MSFT] Guest

  8. #7

    Default Re: Setting up secure custom Web Controls

    Great, thanks.


    cpnet Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139