<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en"><title type="html">Mage_IronWolf's WebLog</title><subtitle type="html" /><id>http://weblogs.asp.net/mage_ironwolf/atom.aspx</id><link rel="alternate" type="text/html" href="http://weblogs.asp.net/mage_ironwolf/default.aspx" /><link rel="self" type="application/atom+xml" href="http://weblogs.asp.net/mage_ironwolf/atom.aspx" /><generator uri="http://communityserver.org" version="3.0.20510.895">Community Server</generator><updated>2004-03-01T18:38:00Z</updated><entry><title>Maximum View State for a postback</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/mage_ironwolf/archive/2004/08/26/221109.aspx" /><id>http://weblogs.asp.net/mage_ironwolf/archive/2004/08/26/221109.aspx</id><published>2004-08-26T20:57:00Z</published><updated>2004-08-26T20:57:00Z</updated><content type="html">Am dealing with a web page written by someone else. I don't have the source code so can't change it now.&lt;br /&gt; &lt;br /&gt; Issue, the viewstate is 9.5 million characters long. It saves out to over 9MB.&lt;br /&gt; &lt;br /&gt; The page has a check box that does an auto postback.&lt;br /&gt; &lt;br /&gt; When it does that, the page errors and tosses an exception:&lt;br /&gt; &lt;i&gt;Error in Application ErrorSystem.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown. ---&amp;gt; System.Web.HttpException: Maximum request length exceeded. at System.Web.HttpRequest.GetEntireRawContent() at System.Web.HttpRequest.FillInFormCollection() at System.Web.HttpRequest.get_Form() at System.Web.UI.Page.GetCollectionBasedOnMethod() at System.Web.UI.Page.DeterminePostBackMode() at System.Web.UI.Page.ProcessRequestMain() --- End of inner exception stack tr Code: -1&lt;/i&gt;&lt;br /&gt; &lt;br /&gt; So my question would be, what is the maximum postback size you can have? &lt;br /&gt; &lt;br /&gt; &lt;br /&gt; John&lt;br /&gt; &lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=221109" width="1" height="1"&gt;</content><author><name>Mage_IronWolf</name><uri>http://weblogs.asp.net/members/Mage_5F00_IronWolf.aspx</uri></author></entry><entry><title>Some of what I learned at Dev Days 2004</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/mage_ironwolf/archive/2004/03/15/89803.aspx" /><id>http://weblogs.asp.net/mage_ironwolf/archive/2004/03/15/89803.aspx</id><published>2004-03-15T15:45:00Z</published><updated>2004-03-15T15:45:00Z</updated><content type="html">DEV DAYS 2004&lt;br&gt;
&lt;br&gt;
I attended Dev Days 2004 in Minneapolis Thursday Mar 11. The main reason I went was for the security focus that it was to have this year. Dev Days was focused on .NET technology, however, a lot of what was covered in concept can be applied to legacy ASP systems.&lt;br&gt;
&lt;br&gt;
There are a couple of primary key things I got out of it. &lt;br&gt;
&lt;br&gt;
1 - Beware of hidden fields. Beware of using them to pass critical information when posting a page. They can be hijacked and be used to misrepresent that data. An airline was selling tickets for $1 because of this feature. &lt;br&gt;
&lt;br&gt;
2 - Make use of Error handling built into the .NET framework. Modify the web.config file to push a user to a generic error page and log the error and as much of the rich data into the event log or appropriate file log. &lt;br&gt;
&lt;br&gt;
3 - Be very careful of granting any rights to any part of a database other than execute permissions on Stored Procedures. Any extra information that can be gained is precious to a hacker.&lt;br&gt;
&lt;br&gt;
4 - Don't assume that because it is Intranet, that you can code with other than best practice techniques. Develop a best practice for both Internal and External web code. &lt;br&gt;
&lt;br&gt;
5 - Storing information in cookies is an invite to try to hack them. Be very careful of using them and if you do, make sure they are temporary and have a short life. It would be better to make the user login every 30 minutes than to leave the cookie out there to be stolen.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Some of the topics discussed were:&lt;br&gt;
&lt;br&gt;
Threat modeling -- Identifying assets, architecture, relationships &amp; threats. Determine where threats are dangerous and plan and design to prevent those from affecting you.&lt;br&gt;
&lt;br&gt;
Disclosure -- All errors should be either handled or at least redirected to a neutral error page and the error logged.&lt;br&gt;
&lt;br&gt;
Techniques to defend the application -- 
&lt;ul&gt;
	&lt;li&gt;HTMLEncode all input echoed to a web page&lt;/li&gt;
	&lt;li&gt;Use regular expressions to validate &lt;/li&gt;
	&lt;li&gt;Run validation on server side even if it was validated on client side&lt;/li&gt;
	&lt;li&gt;Verify ValidateRequest on the html source page is set to true&lt;/li&gt;
	&lt;li&gt;Use encrypted techniques to access the database&lt;/li&gt;
	&lt;li&gt;Validate parameters being passed in to database&lt;/li&gt;
	&lt;li&gt;Logging errors and invalid password attempts to a log&lt;/li&gt;
	&lt;li&gt;Split out levels of security. Use NT permissions to protect pages in Intranet.&lt;/li&gt;
	&lt;li&gt;.NET will allow a web.config file for each folder. Levels of security can be tightened.&lt;/li&gt;
&lt;/ul&gt;	
&lt;br&gt;
Some major common threats to applications -- 	
&lt;ul&gt;
	&lt;li&gt;SQL Injection -- Not as big a deal with Stored Procedures but still a possibility&lt;/li&gt;
	&lt;li&gt;XSS -- Cross Server Scripting -- Placing script tags that are echoed to the web page that can cause either damage, redirect or inconvenience to users.&lt;/li&gt;
	&lt;li&gt;Hidden tag overwriting -- Using hidden tags to change the page and cause errors.&lt;/li&gt;
	&lt;li&gt;Session Hijacking -- Using hardware to gather information and then log to the server with captured  information.&lt;/li&gt;
&lt;/ul&gt;
&lt;br&gt;
I talked to Jacs and several others about the process we are using for securing our data connections. It isn't the absolute best practice, however, it is a legitimate process for securing them. The current best practice utilizes encryption but even that has to store a key somewhere. &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Good day to all,&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
John Debnam&lt;br&gt;
Comments Welcome&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=89803" width="1" height="1"&gt;</content><author><name>Mage_IronWolf</name><uri>http://weblogs.asp.net/members/Mage_5F00_IronWolf.aspx</uri></author></entry><entry><title>Much more detailed explaination of what we have implemented for our security</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/mage_ironwolf/archive/2004/03/05/84851.aspx" /><id>http://weblogs.asp.net/mage_ironwolf/archive/2004/03/05/84851.aspx</id><published>2004-03-05T21:34:00Z</published><updated>2004-03-05T21:34:00Z</updated><content type="html">&lt;style&gt;
	a {
		text-decoration: none;
		font-variant : small-caps;
		font-weight : bold;
	}
&lt;/style&gt;
&lt;div style="font-family: Garamond; text-decoration: none;"&gt;
I am going to explain the security process I did in the previous message. I think some concepts were crossed up.&lt;br&gt;
&lt;br&gt;
&lt;hr&gt;
&lt;strong&gt;1st half&lt;/strong&gt;&lt;br&gt;
&lt;br&gt;
The article at &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/secmod/html/secmod08.asp"&gt;MSDN Building Secure ASP.NET Applications&lt;/a&gt; explains multiple processes that can be used to secure applications.&lt;br&gt;
&lt;br&gt;
Microsoft has enabled &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q329290"&gt;ASP.NET to encrypt credentials and session state connection strings. (Q329290).&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
What I have done is to use the utility &lt;a href="http://download.microsoft.com/download/2/9/8/29829651-e0f0-412e-92d0-e79da46fd7a5/Aspnet_setreg.exe"&gt;Aspnet_setreg.exe&lt;/a&gt; to encrypt a SQL DB login. This login is only granted the rights as explained in the &lt;a href="http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q329290"&gt;(Q329290)&lt;/a&gt; article. &lt;br&gt;
&lt;br&gt;
Each database environment has a different login. So, for DEV I use a database login of something like DB_DEV_ID, QA has a login of DB_QA_ID and PROD is DB_PROD_ID. Since the registry only gets a single setting, even if someone were to change the other registry settings the login would fail. The registry can not be ripped and placed on another machine as part of the decryption is a key to that specific machine.&lt;br&gt;
&lt;br&gt;
Once I had that in place and proper rights granted to ONLY Stored Procedures for this login, I modified the web.config file to impersonate that login. ASP.NET security will not allow the impersonation id to be displayed. It is not available to the code. &lt;br&gt;
&lt;br&gt;
This is all done per the 2 articles mentioned. &lt;br&gt;
&lt;br&gt;
&lt;hr&gt;
&lt;strong&gt;2nd half &lt;/strong&gt;&lt;br&gt;
&lt;br&gt;
I placed an Un-Encrypted registry setting for the environment. Every application will use the same setting so it only has 3 possible settings (DEV, QA, PROD), depending on the environment.&lt;br&gt;
&lt;br&gt;
I then put 3 DB connection strings in the web.config file and name them uniquely.&lt;br&gt;
&lt;br&gt;
&lt;blockquote&gt;
&amp;lt;add key="cnHRDb_DEV" value="Integrated Security=SSPI;Persist Security Info=False;data source=DB_DEV;database=HR;" /&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;add key="cnHRDb_QA" value="Integrated Security=SSPI;Persist Security Info=False;data source=DB_QA;database=HR;" /&amp;gt;&lt;br&gt;
&lt;br&gt;
&amp;lt;add key="cnHRDb_PROD" value="Integrated Security=SSPI;Persist Security Info=False;data source=DB_PROD;database=HR;" /&amp;gt;&lt;br&gt;
&lt;/blockquote&gt;
&lt;br&gt;
When I go to define the database connection, I read from the registry to determine what environment I am in and then use the proper connection string. &lt;br&gt;
&lt;br&gt;
I can not connect to the Prod database with the QA login. Because of this, we can't cross environments on accident (or thru evil intent).&lt;br&gt;
&lt;br&gt;
&lt;hr&gt;
&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
This process means that the only location of the login is encrypted and can not be displayed or used for anything other than logging in. We only grant EXEC to Stored Procedures in the database so have no direct SQL happening. &lt;br&gt;
&lt;br&gt;
I hope this explains it a bit better.&lt;br&gt;
&lt;br&gt;
John&lt;br&gt;
&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=84851" width="1" height="1"&gt;</content><author><name>Mage_IronWolf</name><uri>http://weblogs.asp.net/members/Mage_5F00_IronWolf.aspx</uri></author></entry><entry><title>Quick thoughts on what we are doing for security with .NET</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/mage_ironwolf/archive/2004/03/03/83446.aspx" /><id>http://weblogs.asp.net/mage_ironwolf/archive/2004/03/03/83446.aspx</id><published>2004-03-03T22:25:00Z</published><updated>2004-03-03T22:25:00Z</updated><content type="html">My work has an initiative to remove all login information from web.config and UDL files. The problem we were facing was that we still had to edit those files when we changed environments. ie., when you move from DEV to QA, you have to change the DB server you were connecting to.&lt;br&gt;
&lt;br&gt;
Working with another person here, I developed a 2 level approach for .NET apps.&lt;br&gt;
&lt;br&gt;
1 - We are using the built in encryption/decryption in .NET to read a login/password from an encrypted registry setting and have the .NET application impersonate that login. This works well as we are using it to connect it to some HR information. &lt;br&gt;
&lt;br&gt;
2 - To deal with the environment issue, I set up a registry setting on all levels of the servers, including DEV, with a single value. It's value is DEV, QA, or PROD. When I need to create a DB connection, I read the registry, determine the environment based on the value and then read out the proper DB connection string from the web.config. The web.config file contains all 3 strings. &lt;br&gt;
&lt;br&gt;
Since I am using integrated security, the actual login is hidden. We don't have to worry about someone copying the wrong web.config file into the wrong environment and thus causing issues. &lt;br&gt;
&lt;br&gt;
I also connect to a Web Service for some security. We filter certain pages in different applications  based on levels of security. I have been able to use the same principal for changing the Web Service URL so that the correct one is being hit.&lt;br&gt;
&lt;br&gt;
I am still working out a way to do this with the UDL files, without redoing all of the COM+. &lt;br&gt;
&lt;br&gt;
Any comments or ideas would be appreciated.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
John Debnam&lt;br&gt;
Programmer/Analyst&lt;br&gt;
&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=83446" width="1" height="1"&gt;</content><author><name>Mage_IronWolf</name><uri>http://weblogs.asp.net/members/Mage_5F00_IronWolf.aspx</uri></author></entry><entry><title>Intro with a little bit about me</title><link rel="alternate" type="text/html" href="http://weblogs.asp.net/mage_ironwolf/archive/2004/03/01/82310.aspx" /><id>http://weblogs.asp.net/mage_ironwolf/archive/2004/03/01/82310.aspx</id><published>2004-03-02T00:38:00Z</published><updated>2004-03-02T00:38:00Z</updated><content type="html">My job entails new development and support of current ASP.NET applications and support of current asp applications.

I will be attending the DevDays in Minneapolis on Mar 11. 

I have been part of our security development team here at work. I have set up code to use .NET's internal encrypted registry settings to do impersonation and then an unencrypted registry setting to read environmental settings to know what database to use and what web service to use to verify security.


John&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=82310" width="1" height="1"&gt;</content><author><name>Mage_IronWolf</name><uri>http://weblogs.asp.net/members/Mage_5F00_IronWolf.aspx</uri></author></entry></feed>