Re: Download behavior of .exe assembly

From: Shel Blauman [MSFT] (sheldonb@online.microsoft.com)
Date: 02/22/03


From: "Shel Blauman [MSFT]" <sheldonb@online.microsoft.com>
Date: Sat, 22 Feb 2003 08:17:56 -0800


Michael, you can generate a log showing exceptions thrown when running a
.NET
object under IE. Take a look at article
http://support.microsoft.com/default.aspx?scid=kb%3ben-us%3b313892, HOW TO:
Use the IEHost Log to Debug .NET Object Hosting in Internet Explorer.

I'm including some instructions on making a downloaded user control function
using code access security. I believe many of the points apply to a
downloaded exe.

Hope this helps,

Shel

How to run a user control assembly hosted on an Internet Information Server
(IIS) on an Internet Explorer (IE) client.

The following applies to an assembly intended to execute with greater
permissions than would normally be granted to the zone the assembly belongs
to, most likely Internet, Local Intranet or Trusted Sites.

  1.. The user control assembly is identifiable in a manner that can be used
to set the membership condition in a code group either using the .NET
Configuration Tool (Mscorcfg.msc) or caspol.exe. Signing using a strong
name or a certificate is preferable, but other sources of identity such as a
URL or site can also be used. Although a URL or site can serve as a
membership condition, they are not recommended, as they are not as secure as
a strong name or a certificate.

To create a strong name use sn.exe:

sn -k keyPair.snk

// This strong name key is used to create a code group that gives //
permissions to this assembly.

// Sign the assembly with the strong name key.

[assembly: AssemblyKeyFile("keyPair.snk")]

  2.. If strong named, the user control has the
AllowedPartiallyTrustedCallers attribute.

// The AllowPartiallyTrustedCallersAttribute requires the assembly to // be
signed with a strong name key.

// This attribute is necessary since the control is called by either an //
intranet or Internet Web page that should be running under //
restricted permissions.

// The fully attributed assembly should look similar to the following:

[assembly: AssemblyKeyFile("snKey.snk")]

[assembly: AssemblyVersion("1.0.0.0")]

[assembly:AllowPartiallyTrustedCallers]

namespace SignedAssembly

  3.. The user control asserts permissions it requires which the zone in
which it is running would not normally be granted. Permissions should only
be asserted if it is positively known the calling application has
insufficient permissions. Asserts should not be performed without a strong
need.
new FileIOPermission(PermissionState.Unrestricted).Assert();

            textBox1.Text = fileDialog.FileName;

            // Display the contents of the file in the text box.

FileStream fsIn = new FileStream(textBox1.Text, FileMode.Open,
FileAccess.Read, FileShare.Read);

            StreamReader sr = new StreamReader(fsIn);

            // Process every line in the file

for (String Line = sr.ReadLine(); Line != null; Line = sr.ReadLine())

            {

                  listBox1.Items.Add(Line);

            }

// It is very important to call RevertAssert to restore the stack walk //
for file operations.

                  FileIOPermission.RevertAssert();

  4.. The user control RevertAsserts immediately after performing asserted
actions.
// It is very important to call RevertAssert to restore the stack walk //
for file operations.

                  FileIOPermission.RevertAssert();

  5.. The user control is hosted in an IIS folder on the server that has an
"Execute permission" set to either "None" or "Scripts Only".

  6.. The client has a code group that the assembly resolves to that grants
the permissions the assembly requires.
caspol -machine -addgroup All_Code -strong -file signedassembly.exe
FullTrust -name FouthCoffeeStrongName -description "Code group granting
trust to code signed by FourthCoffee"

Alternatively, the code group can be created using the Microsoft .NET
Framework Configuration tool (Mscorcfg.msc) found under Administrative
Tools.

  7.. In Internet Explorer, Internet Options, Advanced Security settings,
the "Do not save encrypted pages to disk" should be unchecked if Internet
Explorer Enhanced Security Configuration has been enabled for both
Administrators and for Other Groups on the server. The Internet Explorer
Enhanced Security setting selected is the default on Windows Server 2003.
When in effect, one of the invoked features is the encryption of downloaded
files. Another feature is the automatic setting of "Do not save encrypted
pages to disk" on the client. To successfully download a user control under
these conditions, the client setting for "Do not save encrypted pages to
disk" should be cleared. This functionality is found in Control Panel, Add
or Remove Programs, Add/Remove Windows Components, Internet Explorer
Enhanced Security Configuration.

  8.. The runtime version on the client machine is compatible with the used
to compile the assembly.

  9.. The code group created for the user control is in the same runtime
that the control uses.

If problems occur, check the Fusionbinderror log in "C:\Documents and
Settings\<username>\Local Settings\Temporary Internet Files" to determine
which operations failed. This log must first be copied to another folder
before it can be opened.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Michel Gallant (MVP)" <neutron@istar.ca> wrote in message
news:3E56D9F2.9E2B5DF4@istar.ca...
> For a .net framework 1.0 sp2 client and with the default CAS
configuration,
> the behavior for accessing a .net  exe assembly link a web page appears
> to be do absolutely nothing, at least on Win2000 sp3.
>
> For example, I have configured a native exe, and the corresponding .net
> exe, deployed from a standard web server via:
>    http://pages.istar.ca/~neutron/jauth
> (the application is a simple Authenticode-signature verification utility).
>
> Assuming that I have turned off VS.net  JIT debugger, then clicking the
bottom
> Authnet.exe link on this page causes the download, but IE6 client/.net
framework does nothing.
> This does not seem like the correct response, from a security perspective.
> By comparison, selecting the native .exe download link invokes the
familiar dnld/save dialog.
>
> Wouldn't it make better sense to have the .net framework display some sort
of error message
> (related to permissions) or a dnld/save dialog by default?
>
>  - Michel Gallant
>    MVP Security
>    JavaScience Consulting
>    http://pages.istar.ca/~neutron
>    http://www.jensign.com
>
>


Relevant Pages

  • Re: Win2K3 - cannot open files without extension
    ... The above problem was due to Internet Explorer Enhanced Security ... Configuration enabled. ... in that folder named abc.txt. ... the appropriate permissions to access the item" sounds for me like a permission ...
    (microsoft.public.windows.server.general)
  • Re: intranet permissions
    ... on an Internet Explorer client. ... permissions than would normally be granted to the zone the assembly belongs ... The Internet Explorer ... This functionality is found in Control Panel, ...
    (microsoft.public.dotnet.security)
  • Re: Missing dependency MSHTML.DLL -> PSAPI.DLL
    ... configuration after having updated those components. ... binaries in the Internet Explorer component had changed to become dependent ... it looks like the dependency is needed now...). ... can you confirm that adding Primitive: Psapi component to your ...
    (microsoft.public.windowsxp.embedded)
  • "Current security settings do not allow you to send html forms"
    ... When I try to run adobe photoshop cs html (help files are local to my hard ... I belive the issue is that the submission comes from a FRAME within the ... Select Internet Explorer Enhanced Security Configuration>> click Details. ...
    (microsoft.public.internet.explorer.ieak)
  • "Current security settings do not allow you to send html forms"
    ... When I try to run adobe photoshop cs html (help files are local to my hard ... I belive the issue is that the submission comes from a FRAME within the ... Select Internet Explorer Enhanced Security Configuration>> click Details. ...
    (microsoft.public.scripting.jscript)