PC Review


Reply
Thread Tools Rate Thread

Code Access Security - Assert problem

 
 
alunharford@yahoo.com
Guest
Posts: n/a
 
      20th Dec 2006
I'm writing an application that is trusted, but I want it to run some
untrusted code, and I don't understand how I do that. I'm including an
example.
I want to trust my class, TrustedClass, to do whatever it wants to the
file system. I don't want to trust UntrustedClass, so I don't give it
any permissions. But the untrusted code just calls Assert() before it
accesses the file system, and it succeeds.

How do I modify TrustedClass to make sure that UntrustedClass cannot
access the file system?

using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Permissions;
using System.Security;
using System.IO;

namespace SecurityTest
{
//My class
class TrustedClass
{
static void Main(string[] args)
{
PermissionSet permissions = new PermissionSet(null);
permissions.PermitOnly();

UntrustedClass.UntrustedMethod();
}
}

//Adversary's class
class UntrustedClass
{
public static void UntrustedMethod()
{
FileIOPermission permission = new
FileIOPermission(PermissionState.Unrestricted);
permission.Assert();

FileStream fs = new FileStream(@"C:\testing.txt",
FileMode.Create);
}
}
}

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code Access Security(CAS) and Role Based Security(RBS) Tony Johansson Microsoft C# .NET 0 19th Apr 2010 11:19 AM
About Application Security(Code Access Security). It dosn't show correct output Tony Johansson Microsoft C# .NET 3 14th Apr 2010 03:44 PM
problem using ASSERT() in services under XP zarquon5 Windows XP General 0 10th Feb 2006 11:04 PM
an Assert() that will actually break into code neverstill Microsoft ASP .NET 0 6th Jan 2004 05:15 PM
Code Access Security [Was .NET Framework Security Projects] Ben Microsoft Dot NET Framework 3 25th Nov 2003 12:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:10 PM.