.NET security
Posted on 26 Jul 2006 at 15:16
Thomas Lee looks at the security architecture of .net and delves into code access security
Log l = Log.Create( "C:\\log.txt" );
l.Clear();
Let's suppose there's also a third-party logging tool, implemented by the file log.dll, that looked something like this:
public class Log {
public static Log Create( string f ) {
FileStream fs = new FileStream ( f, ... );
}
Finally, the FileStream class, found in the CLR class library, might look something like this:
public class FileStream {
public FileStream( ... ) {
FileIOPermission fi = new ...;
fi.Demand();
...
In this example, the application invokes the log class, which in turn invokes the FileStream class in order to clear the log. To ensure security, the FileStream class calls into fi.demand to perform a stack walk to ensure all callers have the appropriate permission to perform this operation. The FileStream class itself doesn't know or care that the file being managed is actually a log file - it simply checks that the file operation being performed is allowed. This means that if the permission set for myapp.exe and log.dll allows writing to c:\log.txt, the demand method will succeed and the write operation would be carried out; otherwise, an exception would be raised.
For more information about .NET security, you can consult the MSDN library online at www.microsoft.com. The best source of details around .NET Framework security is the book .NET Framework Security by Brian LaMacchia et al (ISBN 0-672-32184-X).
advertisement
- Getting to grips with Microsoft's IT Health Environment Scanner
- Virtualise your servers
- The changing face of travel gadgets
- Build your own distributed file system
- The bulletproof Dell that costs an arm and a leg
- Microsoft Office 2010 Technical Preview: Q&A
- Lawnmowers, the TyTN II and one odd insurance request
- There'll never be a bulletproof OS
- How far can we trust apps?
- Five nice touches in Outlook 2010
- ATI Radeon HD 5970: 42% more expensive in the UK
- Office 2010 Beta – 32-bit or 64-bit – The Choice is Clear
- Why Britain's watchdogs have fewer teeth than goldfish
- Tabbed documents: how to make Office 2010 great
- Outlook 2010 People Pane – does it spell death to Xobni
- Microsoft Outlook 2010 screenshots
- Co-Authoring in Word 2010 and SharePoint Foundation 2010
- Microsoft Outlook 2010 screenshots: Backstage view
- Flash 10.1: Developing for Desktop and Device
- Microsoft Office 2010 screenshots: Recover unsaved items
- Sky Player shows up in Windows 7
- Tweetlevel reveals most influential Twitterers
- Apple "refuses to repair smokers' Macs"
- Spotify arrives on Symbian
- Chrome OS and Android to "converge over time"
- Microsoft to pay News Corp to stay off Google
- Christmas sales surge knocks out eBay search
- Windows 8 set for 2012 release
- Q&A: Why Conficker was a victim of its own success
- App developers losing faith in Android
advertisement
Printed from www.pcpro.co.uk


