Robert Hurlbut's Blog

Thoughts on .NET, Security, Architecture, Agility, and Databases.

Syndication

.Company / Other Sites / Other Blogs

.NET Links

.NET Local Boston Events

.NET User Groups in New England

Blogs - .NET

Blogs - Agile

Blogs - Architecture

Blogs - CLR

Blogs - Security

Blogs - SQL Server

Blogs - System.Transactions

Enterprise Services (COM+) Resources

Indigo Resources

Microsoft Security Resources

Presentation resources

Recommended Books

Rotor Resources

Security Resources

ASP.NET 2.0 Partial Trust Web Sites

Prompted by Dinis Cruz's question on my CLR Hosting in Whidbey/2.0 post, I checked if it is now easier to create Partial-trust ASP.NET web sites in 2.0.

By default, ASP.NET sites run and are built as "Full Trust" sites. This means a web application has full access to the machine's resources. That may be OK if you are hosting the site on your own server (I would still caution running with "Full trust" on your own server as well!), but what if you are hosting your web application on a shared server such as at an ISP with multiple other companies and people you don't know hosting their site as well?  If each ASP.NET web site is running with Full Trust (and using the same Windows user), one web application could read the files from another application's folder, i.e. web.config!

In ASP.NET 1.0, you could only run your web applications with Full Trust. In ASP.NET 1.1, this was fixed slightly by allowing web applications to run in partial-trust mode. The standard trust levels are "Full", "High", "Medium", "Low", and "Minimal". The problem with 1.1, though, was that you had to set this trust level at machine level, i.e. machine.config. And, of course, that would affect the entire machine. If you reset the level at the top, many web applications that were running correctly would probably start throwing exceptions as it does take some extra coding to get partial-trust sites to run correctly.

Update: Actually, as mentioned by Dinis, my results in ASP.NET 2.0 are very similar to what was already available in ASP.NET 1.1.  You could set trust levels at web.config levels -- I was mistaken.

Tests still need to be done to determine if partial-trust assemblies are any more powerful in ASP.NET 2.0 than in ASP.NET 1.1, as one of the biggest problems with 1.1 was the lack of functionality in the "highest" partial trust application.

Published Monday, September 20, 2004 11:43 AM by RHurlbut

Comments

# re: ASP.NET 2.0 Partial Trust Web Sites@ Monday, September 20, 2004 8:22 PM

Robert,
I knew MS will make security tighter. It is a good thing for the application, but BAD news for developers!

Thanks for heads-up, Maxim

[www.ipattern.com do you?]

# re: ASP.NET 2.0 Partial Trust Web Sites@ Tuesday, September 21, 2004 9:47 PM

The only way I found to making partial-trust assemblies work in ASP.NET is to have separate components (such as an error handler that can write to the event log and send email) that AllowPartiallyTrustedCallers - is that the permission name? Anyway, as long as you are SURE that your component does not compromise security, say by refusing event log delete permissions since you only write them, then it is ok as far as I know. I'm certainly interested in more info!

by Darrell

# re: ASP.NET 2.0 Partial Trust Web Sites@ Thursday, September 23, 2004 11:13 PM

And keep in mind that the built-in trust levels are pretty broad swaths of permissions. Even if you can live with a Medium trust level--probably the lowest practical level for production Web sites--it probably has permissions your site doesn't need. The principle of least privilege almost mandates that you create custom trust levels for production sites.

# re: ASP.NET 2.0 Partial Trust Web Sites@ Thursday, September 23, 2004 11:31 PM

Excellent point, Don.