<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Varun Sharma's security blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/varun_sharma/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/varun_sharma/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:34:39 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Securing Cloud Services</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/securing-cloud-services</link>
      <pubDate>Mon, 06 Oct 2014 18:35:45 GMT</pubDate>
      <dc:creator><![CDATA[Varunsh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2014/10/06/securing-cloud-services/</guid>
      <description><![CDATA[This blog post is part of a series of posts on Security Best Practices for Microsoft Azure...]]></description>
      <content:encoded><![CDATA[<p>This blog post is part of a series of posts on <a href="http://blogs.msdn.com/b/varun_sharma/archive/2014/09/21/security-best-practices-for-microsoft-azure-applications.aspx">Security Best Practices for Microsoft Azure Applications</a>. You can visit the landing page <a href="http://blogs.msdn.com/b/varun_sharma/archive/2014/09/21/security-best-practices-for-microsoft-azure-applications.aspx">here</a>. 
</p><p>A <a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-what-is/">cloud service</a> consists of one or more web roles and/or worker roles, each with its own application files and configuration. You can also script more advanced IIS and machine configuration changes that run at role startup, including tasks that require administrator control. 
</p><p>Threats and countermeasures for securing cloud services are listed below. 
<table style="border-collapse:collapse" border="0"><colgroup><col style="width:48px"/><col style="width:288px"/><col style="width:288px"/></colgroup><tbody valign="top"><tr><td style="border-top:  solid 1.0pt; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"> </td><td style="padding-left: 7px; padding-right: 7px; border-top:  solid 1.0pt; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Threats</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  solid 1.0pt; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Countermeasures</p></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>1</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p><a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-configure/">Remote desktop</a> is enabled and the remote desktop password is compromised to login to the web or worker role instance. This may happen if an attacker guesses or brute forces the remote desktop password.
</p><p>Remote desktop password is shared across operations personnel. One of them leaves the organization and can still RDP into a web or worker role instance from anywhere on the internet. 
</p><p>When logging into a role using remote desktop client, you get a certificate error since the RDP authentication certificate is self-signed. You may not be able to validate if you are under a man-in-the-middle attack. Such an attack can steal the RDP username and password. 
</p><p>Articles related to this threat:-
</p><p><a href="http://krebsonsecurity.com/2013/12/hacked-via-rdp-really-dumb-passwords/">Hacked Via RDP: Really Dumb Passwords</a>
						</p><p><a href="http://social.msdn.microsoft.com/Forums/azure/en-US/15ddae2b-1d44-45c4-a6e7-f80dad4db7c6/virtual-machine-hacking">Virtual Machine hacking</a>
						</p><p><a href="http://www.theregister.co.uk/2011/08/28/morto_worm_spreading/">Worm spreads via RDP</a>
						</p><p><a href="https://labs.portcullis.co.uk/blog/ssl-man-in-the-middle-attacks-on-rdp/">SSL man-in-the-middle attacks on RDP</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Disable RDP on cloud services by default. Since web or worker roles can restart at any time, <a href="http://blogs.msdn.com/b/kwill/archive/2012/09/19/role-instance-restarts-due-to-os-upgrades.aspx">no planned installations or OS level configuration changes should be done by remote login</a>. Use <a href="http://msdn.microsoft.com/en-us/library/azure/hh180155.aspx">Start Up tasks</a> instead.  Similarly if you need to pull diagnostic information, use <a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/">Windows Azure Diagnostics</a>. There should ideally be no reason to RDP into role instances other than to troubleshoot issues.
</div><p>
 </p></li><li><div>If you must RDP into a cloud service instance, use a <a href="http://blogs.technet.com/b/aaronczechowski/archive/2011/12/08/generating-a-random-password-with-powershell.aspx">password generation tool</a> to set a strong random password. Do not share the password with others. Disable remote desktop immediately after troubleshooting. 
</div><p>
 </p></li><li><div>Enabling RDP on a cloud service is an auditable event. The change in configuration gets logged in the subscription operation logs. This should tell who enabled RDP and when. If password is not shared, correlating with security event logs from role instances will tell who logged in remotely to a role at a particular time. 
</div><p>
 </p></li><li>When logging into a role using remote desktop client, you will get a certificate error since the RDP authentication certificate is self-signed. You cannot be sure if your RDP connection is under a man-in-the-middle attack, which is another reason to not use RDP on a production role instance.  </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>2</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>End users may not be sure if they are connecting to the right web site/ web service hosted on a cloud service. 
</p><p>Data transferred from an end user to a cloud service may be sniffed while in transit. 
</p><p>Articles related to this threat:-
</p><p><a href="http://www.theregister.co.uk/2009/05/07/heartland_breach_costs/">Data-sniffing attack costs Heartland $12.6m</a>
						</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div><a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-custom-domain-name/">Configure a custom domain name for your cloud service</a>. Use CNAME to map .cloudapp.net to your own domain name e.g. www.contoso.com. 
</div><p>
 </p></li><li><div><a href="http://support2.microsoft.com/kb/2990804">Enable SSL</a> or use WCF's message layer security on roles that accept incoming connections on input endpoints. The server authentication certificate should be valid and should chain up to a trust root authority. This certificate should be procured for your own domain name. 
</div><p>
 </p></li><li>Use the "<a href="https://www.owasp.org/index.php/SecureFlag">secure</a>" attribute for all authentication cookies or cookies that have sensitive data in your web site, so that these cookies are sent only on SSL.</li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>3</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>An attacker can access your cloud service from anywhere on the internet. If the application hosted on the cloud service is not built by following security best practices, it may be compromised.
</p><p>Articles related to this threat:-
</p><p><a href="https://www.riskbasedsecurity.com/2014/04/sql-injection-leads-to-bigmoneyjobs-com-leak/">SQL Injection Leads To BigMoneyJobs.com Leak</a>
						</p><p><a href="http://techcrunch.com/2013/12/31/hackers-claim-to-publish-list-of-4-6m-snapchat-usernames-and-numbers/">Confirmed: Snapchat Hack Not A Hoax, 4.6M Usernames And Numbers Published</a>
						</p><p><a href="http://www.cnet.com/news/ftc-and-trendnet-settle-claim-over-hacked-security-cameras/">FTC and TrendNet settle claim over hacked security cameras</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Limit the input endpoints on your cloud service to only those that really need to be exposed to the internet. Use <a href="http://msdn.microsoft.com/en-us/library/azure/hh180158.aspx">internal endpoints</a> or <a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-multi-tier-app-using-service-bus-queues/">queues</a> for inter-role communication. 
</div><p>
 </p></li><li><div>If you are expecting traffic from a set of specific IP addresses only, use IP based filtering at the <a href="http://blogs.msdn.com/b/tomholl/archive/2013/05/07/using-windows-firewall-to-restrict-access-to-windows-azure-instances.aspx">firewall</a>, <a href="http://msdn.microsoft.com/en-us/library/azure/jj154098.aspx">IIS</a> or the application level. Your callers using cloud services can <a href="http://msdn.microsoft.com/en-us/library/azure/dn690120.aspx">reserve an IP address</a> to ensure their service's IP address doesn't change. 
</div><p>
 </p></li><li><div>Implement authentication and authorization at the application level so that only authorized callers/ applications are allowed to call your web site or service. 
</div><p>
 </p></li><li><div>Follow <a href="http://www.microsoft.com/security/sdl/default.aspx">Security Development Lifecycle (SDL)</a> and security best practices when developing applications deployed on cloud services, e.g. all end user input must be validated for a set of allowed characters. 
</div><p>
 </p></li><li>To limit the damage if a cloud service is compromised, do not run the role instances with <a href="http://msdn.microsoft.com/en-us/library/azure/gg557552.aspx">elevated permissions</a>. If you need to run command or code as elevated, try to run it as an elevated <a href="http://msdn.microsoft.com/en-us/library/azure/hh180155.aspx">startup task</a>. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>4</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Cloud service role instances may not be patched. An attacker may exploit a known vulnerability to compromise the system. 
</p><p>Articles related to this threat:-
</p><p><a href="http://aws.amazon.com/security/security-bulletins/jboss-worm-spreading-via-unpatched-or-unsecured-jboss-application-server/">JBoss Worm Spreading via Unpatched or Unsecured JBoss Application Server</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Guest OS has two update settings. 
</div><p>1) Automatic: Azure <a href="http://msdn.microsoft.com/en-us/library/ff729420.aspx">automatically patches Cloud services periodically</a>. 
</p><p>2) Manual: You can manually set the Guest OS version. If you do this and do not update the Guest OS version, it may stay unpatched. It is recommended to use automatic patching. 
</p><p>
 </p></li><li>If you install non-Microsoft software on your cloud service using a startup task, you must consider the patching mechanism for it. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>5</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>End users may be allowed to upload files through your application hosted on a cloud service. An attacker may upload malware to try and compromise a role instance. 
</p><p>Cloud service instances may be subjected to malware through other avenues. 
</p><p>Article related to this threat:-
</p><p><a href="http://www.theregister.co.uk/2011/08/28/morto_worm_spreading/">Worm spreads via RDP</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div><a href="http://go.microsoft.com/fwlink/?linkid=398023&amp;clcid=0x409">Enable anti malware</a> on the cloud service role instances. End user uploaded files should be scanned for malware. 
</div><p>
 </p></li><li>Monitor logs for malware related events. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>6</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>If a role instance is compromised or is under attack, the operations personnel may not get to know about it. Since roles can recycle at any time and will do so when the Guest OS is patched, previous role logs will be lost. </p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Use <a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/">Windows Azure Diagnostics</a> to transfer logs from role instances to Azure storage. 
</div><p>
 </p></li><li><div>Ensure all event logs, including security event logs are transferred. Transfer Azure diagnostic logs and IIS logs for web roles.
</div><p>
 </p></li><li><div>Monitor logs for signs of suspicious activity. 
</div><p>
 </p></li><li><div>To limit access to logs, use a separate storage account for storing diagnostic data than the one used to store application data.
</div><p>
 </p></li><li>To know if logs are deleted, <a href="http://azure.microsoft.com/en-us/documentation/articles/storage-monitor-storage-account/">enable logging on the storage account</a> to log delete requests. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>7</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Secret keys may be stored in your configuration files (Web.Config or .cscfg). The keys/ passwords may be used to connect to other Azure components. 
</p><p>These application configuration files may be compromised. This could happen if the configuration files are stored without proper ACLs on the deployment server, or in the code repository or a backup location. 
</p><p>Incidents related to this threat:-
</p><p><a href="http://searchcloudsecurity.techtarget.com/news/2240224543/Old-AWS-API-key-led-to-search-providers-cloud-security-breach">Old AWS API key led to search provider's cloud security breach</a>
						</p><p><a href="http://readwrite.com/2014/04/15/amazon-web-services-hack-bitcoin-miners-github">Developers, Check Your Amazon Bills For Bitcoin Miners</a>
						</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Use separate subscriptions/ resources for production and test environments. Even if secret keys for test environments are compromised, real data will not be compromised. 
</div><p>
 </p></li><li><div>Secure configuration files on deployment server or code repository using ACLs. 
</div><p>
 </p></li><li><div>Encrypt secrets in configuration files. Even if production configuration files are compromised, the secret keys will not be compromised. 
</div><p>
 </p></li><li>Rotate or change secret keys in configuration files periodically. This will limit the probability that a compromised secret key is still valid. To allow changing of secret keys, <a href="http://msdn.microsoft.com/en-us/library/dn589785.aspx">store them in the service configuration file</a> and not in the Web.Config file. You can change service configuration files without re-deploying the cloud service. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>8</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Your cloud service is unavailable due to unforeseen circumstances. This may happen if there is an issue in the datacenter or a natural disaster that has caused a datacenter to go down. 
</p><p>Article related to this threat:-
</p><p><a href="http://www.datacenterknowledge.com/archives/2012/07/26/windows-azure-down-europe/">Windows Azure Hit by Cloud Outage in Europe</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Create a <a href="http://msdn.microsoft.com/en-us/library/azure/dn251004.aspx">disaster recovery plan</a>
								</div><p>
 </p></li><li>Host your cloud service in multiple regions and use <a href="http://msdn.microsoft.com/en-us/library/azure/hh744832.aspx">Azure traffic manager</a> to failover to a secondary cloud service if the primary is down. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>9
</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Attackers mount a denial of service attack on your cloud service in an attempt to bring it down. 
</p><p>Articles related to this threat:-
</p><p><a href="http://www.gregthatcher.com/Azure/Default.aspx">The Mighty Azure</a>
						</p><p><a href="http://nakedsecurity.sophos.com/2012/08/28/ddos-hong-kong-beauty/">DDoS attack stymies vote in Miss Hong Kong beauty contest</a>
						</p><p><a href="http://blog.bitbucket.org/2009/10/04/on-our-extended-downtime-amazon-and-whats-coming/">On our extended downtime, Amazon and what's coming</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li><div>Windows Azure has a <a href="http://download.microsoft.com/download/4/3/9/43902EC9-410E-4875-8800-0788BE146A3D/Windows%20Azure%20Network%20Security%20Whitepaper%20-%20FINAL.docx">distributed denial-of-service (DDoS) defense system that helps prevent attacks against Windows Azure platform services</a>. It uses standard detection and mitigation techniques such as SYN cookies, rate limiting, and connection limits. However, it is still possible for applications to be targeted individually
</div><p>
 </p></li><li><div><a href="http://msdn.microsoft.com/en-us/library/dn481101.aspx">Monitor</a> your cloud service's uptime and responsiveness. Monitor the cloud service <a href="http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-monitor/">metrics</a>. 
</div><p>
 </p></li><li><div>If you notice that your application is under attack, contact Windows Azure <a href="http://www.windowsazure.com/en-us/support/contact/">Customer Support</a> to receive assistance.
</div><p>
 </p></li><li><div>Use <a href="http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions">Dynamic IP restrictions</a>
								</div><p>
 </p></li><li>Use <a href="http://en.wikipedia.org/wiki/CAPTCHA">CAPTCHA</a> for scenarios where attackers might want to automate specific HTTP requests to consume resources.  </li></ul></td></tr></tbody></table></p>]]></content:encoded>
    </item>
    <item>
      <title>Securing the Microsoft Azure subscription</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/securing-the-microsoft-azure-subscription</link>
      <pubDate>Thu, 02 Oct 2014 20:02:09 GMT</pubDate>
      <dc:creator><![CDATA[Varunsh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2014/10/02/securing-the-microsoft-azure-subscription/</guid>
      <description><![CDATA[This blog post is part of a series of posts on Security Best Practices for Microsoft Azure...]]></description>
      <content:encoded><![CDATA[<p>This blog post is part of a series of posts on <a href="http://blogs.msdn.com/b/varun_sharma/archive/2014/09/21/security-best-practices-for-microsoft-azure-applications.aspx">Security Best Practices for Microsoft Azure Applications</a>. You can visit the landing page <a href="http://blogs.msdn.com/b/varun_sharma/archive/2014/09/21/security-best-practices-for-microsoft-azure-applications.aspx">here</a>. 
</p><p><a href="http://msdn.microsoft.com/en-us/library/azure/hh531793.aspx">Subscriptions</a> help you organize access to cloud service resources. Compromise of a subscription can compromise all data and applications hosted in it. Threats and countermeasures for securing a subscription are listed below.
<table style="border-collapse:collapse" border="0"><colgroup><col style="width:48px"/><col style="width:288px"/><col style="width:288px"/></colgroup><tbody valign="top"><tr style="height: 31px"><td style="border-top:  solid 1.0pt; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"> </td><td style="padding-left: 7px; padding-right: 7px; border-top:  solid 1.0pt; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Threats</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  solid 1.0pt; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Countermeasures</p></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p style="text-align: center">1</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Spoofing of an account administrator, service administrator or co-administrator account to access the subscription. This could happen if the administrator's password is compromised may be by social engineering or brute-forcing or by compromising the administrator's local machine that is used to login to the Azure management portal. 
</p><p>An employee who had access to a subscription using a Microsoft Account (Windows Live ID) leaves the organization, but can still access the subscription. 
</p><p>Article related to this threat:-
</p><p><a href="http://arstechnica.com/security/2014/06/aws-console-breach-leads-to-demise-of-service-with-proven-backup-plan/">AWS console breach leads to demise of service with "proven" backup plan</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li>Use <a href="http://msdn.microsoft.com/en-us/library/azure/hh531793.aspx">organizational accounts</a> or <a href="http://azure.microsoft.com/blog/2012/11/28/windows-azure-now-supports-federation-with-windows-server-active-directory/">on-premise corporate identities</a> instead of Microsoft accounts (Windows Live ID) to provision access to subscriptions. Set a <a href="http://technet.microsoft.com/en-us/library/jj943764.aspx">strong password policy</a> and require passwords to be changed periodically. 
</li><li>Use Multi Factor Authentication to access the Azure Management portal. You can <a href="http://msdn.microsoft.com/en-us/library/azure/dn249466.aspx">add Multi Factor Authentication to Azure Active Directory</a> or enable Multi Factor Authentication on your on-premise STS (e.g. ADFS server).
</li><li>Limit the number of co-administrators to a minimum. To do so, use separate subscriptions for test and production environments, so that developers and testers do not need to be given access to production subscription and/ or use <a href="http://azure.microsoft.com/en-us/documentation/articles/role-based-access-control-configure/">Role Based Access Control</a> on the Azure preview portal to grant (owner/ contributor/ reader) access to subscription or to specific resources or resource groups.
</li><li>Periodically review the list of people who have access to a subscription, resource groups or resources.
</li><li>Administrators should ensure that the machines they are using to connect to the Azure portal have a <a href="http://www.microsoft.com/en-GB/security/pc-security/windows8.aspx">secure configuration</a>, e.g. should be patched and have anti-virus running.
</li><li>Monitor the <a href="http://blogs.msdn.com/b/azuremobile/archive/2013/11/26/operation-logs.aspx">subscription operation logs</a></li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p style="text-align: center">2</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>A <a href="http://msdn.microsoft.com/en-us/library/azure/gg981929.aspx">management certificate</a> or a <a href="http://msdn.microsoft.com/en-us/library/dn385850(v=nav.70).aspx">publishsettings</a> file is compromised and is used to access the subscription. 
</p><p>Or an administrator who had access to a management certificate leaves the company and may still have the certificate and be able to access the subscription. 
</p><p>Articles related to this threat:-
</p><p><a href="http://searchcloudsecurity.techtarget.com/news/2240224543/Old-AWS-API-key-led-to-search-providers-cloud-security-breach">Old AWS API key led to search provider's cloud security breach</a>
						</p><p><a href="http://readwrite.com/2014/04/15/amazon-web-services-hack-bitcoin-miners-github">Developers, Check Your Amazon Bills For Bitcoin Miners</a></p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li>Limit the number of management certificates being used in the subscription. 
</li><li>When using PowerShell, prefer to use <a href="http://msdn.microsoft.com/en-us/library/dn495128.aspx">Add-AzureAccount</a> to login using individual administrator organizational accounts instead of using management certificates.
</li><li>Periodically review the list of management certificates in the subscription. Ensure there is a valid reason for each. 
</li><li>Change management certificates periodically and whenever someone who had access to the management certificate leaves the company.
</li><li>Do not store .publishsettings files, even for test subscriptions in your code repository or folder shares. </li></ul></td></tr><tr><td style="border-top:  none; border-left:  solid 1.0pt; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p style="text-align: center">3</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><p>Someone takes an action on the subscription and it is not possible to tell who took the action and when.</p></td><td style="padding-left: 7px; padding-right: 7px; border-top:  none; border-left:  none; border-bottom:  solid 1.0pt; border-right:  solid 1.0pt"><ul><li>Ensure that administrators are not using shared accounts to login to the Management Portal. They must use their individual organizational accounts or accounts that can be tied back to an individual. 
</li><li>Limit use of management certificates to background jobs or scripts that need to run automatically. All other access should be done using organizational accounts either through the portal or using Power Shell.
</li><li>Subscription operation logs are available for the last 90 days. If you may need to know about actions taken earlier than that, <a href="http://social.msdn.microsoft.com/Forums/en-US/8ca31722-371f-4cc3-9cbe-460a74aba191/exporting-operations-log-to-file?forum=windowsazuremanagement">archive the subscription operation logs</a>. </li></ul></td></tr></tbody></table><p>
 </p></p>]]></content:encoded>
    </item>
    <item>
      <title>Security Best Practices for Microsoft Azure Applications</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/security-best-practices-for-microsoft-azure-applications</link>
      <pubDate>Sat, 20 Sep 2014 18:43:52 GMT</pubDate>
      <dc:creator><![CDATA[Varunsh]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2014/09/20/security-best-practices-for-microsoft-azure-applications/</guid>
      <description><![CDATA[Responsibility for security of applications on Azure is shared by Microsoft and the customer....]]></description>
      <content:encoded><![CDATA[<p>Responsibility for security of applications on Azure is shared by Microsoft and the customer. Microsoft is responsible for the platform and seeks to provide a cloud service that can meet customer's security requirements. <a href="http://azure.microsoft.com/en-us/support/trust-center/">Microsoft Azure Trust Center</a> has details of what Microsoft does to secure Azure. Customers are responsible for securing their applications, data, virtual machines, access credentials, and compliance with regulatory requirements. This blog post and related posts will focus on security best practices that customers can follow to secure their Azure applications. This is based on my learnings from securing Microsoft's line-of-business applications. 
</p><p>The blog posts will outline threats to data and applications hosted on Azure and countermeasures appropriate to address each threat. This is work in progress and posts will be added and updated over time.  For a good overview of Azure components, refer <a href="http://azure.microsoft.com/en-us/documentation/articles/fundamentals-introduction-to-azure/">Introducing Azure</a>. 
</p><p><a href="http://blogs.msdn.com/b/varun_sharma/archive/2014/10/03/securing-the-microsoft-azure-subscription.aspx"><strong>Securing the Microsoft Azure subscription</strong></a><strong>
		</strong></p><p><a href="http://blogs.msdn.com/b/varun_sharma/archive/2014/10/07/securing-cloud-services.aspx"><strong>Securing Cloud Services</strong></a><strong>
		</strong></p><p><strong>Securing Azure Storage (to be added)
</strong></p><p><strong>Securing Azure SQL Database (to be added)</strong></p>]]></content:encoded>
    </item>
    <item>
      <title>TechNet Webcast: Configuring with Least Privilege in SQL Server 2008</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/technet-webcast-configuring-with-least-privilege-in-sql-server-2008</link>
      <pubDate>Sat, 20 Jun 2009 16:00:09 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2009/06/20/technet-webcast-configuring-with-least-privilege-in-sql-server-2008/</guid>
      <description><![CDATA[I recently presented a TechNet Webcast on the topic “Configuring with Least Privilege in SQL Server...]]></description>
      <content:encoded><![CDATA[<p>I recently presented a TechNet Webcast on the topic “Configuring with Least Privilege in SQL Server 2008”. </p>  <p>The topics covered in the Webcast are:-</p>  <p>1. Configuring SQL Server service accounts with least privilege. Service isolation is also explained. </p>  <p>2. Configuring accounts connecting to SQL Server from a Web application (Principals) with least privilege. </p>  <p>3. Running xp_cmdshell with a proxy so that the account invoking xp_cmdshell need not be a sysadmin.</p>  <p>4. Running SQL Server jobs with least privilege. </p>  <p>The Webcast can be viewed here:-</p>  <p><a title="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;EventID=1032415807&amp;CountryCode=US" href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;EventID=1032415807&amp;CountryCode=US">http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&amp;EventID=1032415807&amp;CountryCode=US</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Catch the security flaw #6</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/catch-the-security-flaw-6</link>
      <pubDate>Fri, 10 Apr 2009 10:33:28 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2009/04/10/catch-the-security-flaw-6/</guid>
      <description><![CDATA[If you can find the security issue with this piece of code, write about it by adding a comment to...]]></description>
      <content:encoded><![CDATA[<p>If you can find the security issue with this piece of code, write about it by adding a comment to this blog post. </p>  <p>This is the scenario:-</p>  <p>1. There is a Web site that allows end users to upload their pictures. </p>  <p>2. On the Web server, the Web site is physically located at C:\Inetpub\wwwroot\sampleapp, which is obviously a virtual directory. </p>  <p>3. The uploaded pictures are stored on the file system in the following directory C:\Uploads\{username}. This is <strong>not</strong> a virtual directory. {username} is the logged in user’s username and can contain only alphabets and numbers. </p>  <p>This is what the page looks like to the end user. </p>  <p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/varun_sharma/WindowsLiveWriter/Catchthesecurityflaw6_1042C/fileupload.gif" original-url="http://blogs.msdn.com/blogfiles/varun_sharma/WindowsLiveWriter/Catchthesecurityflaw6_1042C/fileupload.gif"><img title="fileupload" height="279" alt="fileupload" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/varun_sharma/WindowsLiveWriter/Catchthesecurityflaw6_1042C/fileupload_thumb.gif" original-url="http://blogs.msdn.com/blogfiles/varun_sharma/WindowsLiveWriter/Catchthesecurityflaw6_1042C/fileupload_thumb.gif" width="560" border="0" /></a> </p>  <p>This is the code that gets executed. The code for the UploadPicture.aspx.cs file is this. </p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">partial</span> <span style="color: #0000ff">class</span> UploadPicture : System.Web.UI.Page</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> Page_Load(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>         lblUserName.Text = <span style="color: #006080">&quot;Welcome &quot;</span> + User.Identity.Name;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> btnSubmit_Click(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         <span style="color: #0000ff">new</span> UploadHelper().UploadFile(fileUploadControl, User.Identity.Name);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
  </div>
</div>

<p>The code for the UploadHelper.cs file is this:-</p>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
  <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">class</span> UploadHelper</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">private</span> <span style="color: #0000ff">string</span> uploadFolder;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     <span style="color: #0000ff">public</span> UploadHelper()</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>         uploadFolder = <span style="color: #006080">@&quot;C:\Uploads\&quot;;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>     private void SetUpUploadFolder(string userName)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>         uploadFolder += userName + @&quot;</span>\<span style="color: #006080">&quot;;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>         if (!System.IO.Directory.Exists(uploadFolder))</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>             System.IO.Directory.CreateDirectory(uploadFolder);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span>     </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  16:</span>     public string UploadFile(FileUpload fp, string userName)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  17:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  18:</span>         string extension = fp.PostedFile.FileName.Substring(fp.PostedFile.FileName.LastIndexOf(&quot;</span>.<span style="color: #006080">&quot;));</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  19:</span>         if (extension.ToLower() == &quot;</span>.jpg<span style="color: #006080">&quot; || extension.ToLower() == &quot;</span>.gif<span style="color: #006080">&quot;)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  20:</span>         {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  21:</span>             string strFileName = fp.PostedFile.FileName.Substring(fp.PostedFile.FileName.LastIndexOf(&quot;</span>\\&quot;) + 1);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  22:</span>             SetUpUploadFolder(userName);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  23:</span>             <span style="color: #0000ff">string</span> strFullPath = uploadFolder + strFileName;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  24:</span>             fp.SaveAs(strFullPath);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  25:</span>             <span style="color: #0000ff">return</span> strFileName;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  26:</span>         }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  27:</span>         <span style="color: #0000ff">return</span> <span style="color: #0000ff">null</span>;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  28:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  29:</span> }</pre>
  </div>
</div>

<p>If I login to the Web site as “varun” and upload a picture with name mypic.gif, it gets uploaded to this folder on the Web server:-</p>

<p>C:\Uploads\varun\mypic.gif</p>

<p>&#160;</p>

<p>Happy Hunting!</p>]]></content:encoded>
    </item>
    <item>
      <title>Virtual techdays: Top 5 Web Application security bugs in custom code</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/virtual-techdays-top-5-web-application-security-bugs-in-custom-code</link>
      <pubDate>Sun, 15 Feb 2009 23:23:00 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2009/02/15/virtual-techdays-top-5-web-application-security-bugs-in-custom-code/</guid>
      <description><![CDATA[Microsoft Virtual TechDays is starting from the 18th February 09. In the security track, I will be...]]></description>
      <content:encoded><![CDATA[<P>Microsoft <A href="http://www.virtualtechdays.com/home.aspx" mce_href="http://www.virtualtechdays.com/home.aspx">Virtual TechDays</A> is starting from the 18th February 09. In the <A href="http://www.virtualtechdays.com/Agenda.aspx?Event=10" mce_href="http://www.virtualtechdays.com/Agenda.aspx?Event=10">security track</A>, I will be presenting on the topic “Top 5 Web Application Security bugs in custom code”. As a security engineer in the <A class="" href="http://blogs.msdn.com/ace_team" mce_href="http://blogs.msdn.com/ace_team">ACE Team</A>, I have been reviewing line-of-business applications for the past two years. In this presentation, I will talk about the most common security mistakes that developers make while writing code. Since developers from various geographical locations tend to make the same mistakes, the audience can take back a lot of practical knowledge and apply it to secure their applications. </P>]]></content:encoded>
    </item>
    <item>
      <title>catch the security flaw #5 (flaw and its countermeasure)</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/catch-the-security-flaw-5-flaw-and-its-countermeasure</link>
      <pubDate>Mon, 29 Dec 2008 00:10:00 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2008/12/29/catch-the-security-flaw-5-flaw-and-its-countermeasure/</guid>
      <description><![CDATA[In my last post, I showed input validation code that uses RegularExpressionValidators improperly....]]></description>
      <content:encoded><![CDATA[<P mce_keep="true">In my <A href="http://blogs.msdn.com/varun_sharma/archive/2008/12/22/catch-the-security-flaw-5.aspx" target=_blank mce_href="http://blogs.msdn.com/varun_sharma/archive/2008/12/22/catch-the-security-flaw-5.aspx">last post</A>, I showed input validation code that uses RegularExpressionValidators improperly. Thanks to <A href="http://blogs.msdn.com/user/Profile.aspx?UserID=151493" mce_href="http://blogs.msdn.com/user/Profile.aspx?UserID=151493">Mathew Grabau</A> and <A href="http://blogs.mconstantin.eu.org/cchrism/" mce_href="http://blogs.mconstantin.eu.org/cchrism/">Marius Cristian CONSTANTIN</A> for pointing out that the Page’s IsValid property has not been checked before using the input. As a result, effectively, the code performs only client side validation, which can easily be bypassed. As a matter of fact, there are three more vulnerabilities in the code, that, together lead to a bigger vulnerability. </P>
<P>1. “validateRequest” is set to false. </P>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN> &lt;%@ Page Language=<SPAN style="COLOR: #006080">"C#"</SPAN> ValidateRequest=<SPAN style="COLOR: #006080">"false"</SPAN> </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   2:</SPAN> AutoEventWireup=<SPAN style="COLOR: #006080">"true"</SPAN> CodeFile=<SPAN style="COLOR: #006080">"Default2.aspx.cs"</SPAN> Inherits=<SPAN style="COLOR: #006080">"Default2"</SPAN> %&gt;   </PRE></DIV></DIV>
<P>2. User supplied input is, without encoding, rendered back to the browser.</P>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN> <SPAN style="COLOR: #0000ff">protected</SPAN> <SPAN style="COLOR: #0000ff">void</SPAN> btnSubmit_Click(<SPAN style="COLOR: #0000ff">object</SPAN> sender, EventArgs e)   </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   2:</SPAN> {            </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   3:</SPAN>     Response.Write(<SPAN style="COLOR: #006080">"Welcome "</SPAN> + Request[<SPAN style="COLOR: #006080">"txtName"</SPAN>]);  </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   4:</SPAN> }   </PRE></DIV></DIV>
<P>3. The Request object has been used ambiguously. </P>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN> Response.Write(<SPAN style="COLOR: #006080">"Welcome "</SPAN> + Request[<SPAN style="COLOR: #006080">"txtName"</SPAN>]);</PRE></DIV></DIV>
<P mce_keep="true">What I mean by ambiguously is, that, a specific collection like Request.Forms or Request.QueryString has not been used to get the input parameter. If, Request[“txtName”] is used directly, the Web server searches the collections in the following order: </P>
<P>QueryString <BR>Form <BR>Cookies <BR>ClientCertificate <BR>ServerVariables </P>
<P>If “txtName” exists in more than one collection, the Request object returns the first instance that the object encounters [1]. As a result, if “txtName” is entered in the query string as well, it will be picked up from there and not from the form variable. </P>
<P>Therefore, an attacker can lure a victim into clicking a link like</P>
<P><A title="http://xpns/firstwebsite/Default2.aspx?txtname=%3cscript%3ealert('xss')%3b%3c%2fscript%3e" href="http://server_name/firstwebsite/Default2.aspx?txtname=%3cscript%3ealert('xss')%3b%3c%2fscript%3e" mce_href="http://server_name/firstwebsite/Default2.aspx?txtname=%3cscript%3ealert('xss')%3b%3c%2fscript%3e">http://server_name/firstwebsite/Default2.aspx?txtname=%3cscript%3ealert('xss')%3b%3c%2fscript%3e</A></P>
<P>If the victim clicks on this link, enters any name in the text box and clicks the submit button, script payload in the query string will execute in the victim’s browser, leading to cross-site scripting. </P>
<P><A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/varun_sharma/WindowsLiveWriter/catchthesecurityflaw5flawanditscounterme_13EF9/cth5.gif" original-url="http://blogs.msdn.com/blogfiles/varun_sharma/WindowsLiveWriter/catchthesecurityflaw5flawanditscounterme_13EF9/cth5.gif" mce_href="http://blogs.msdn.com/blogfiles/varun_sharma/WindowsLiveWriter/catchthesecurityflaw5flawanditscounterme_13EF9/cth5.gif"><IMG title=cth5 height=267 alt=cth5 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/varun_sharma/WindowsLiveWriter/catchthesecurityflaw5flawanditscounterme_13EF9/cth5_thumb.gif" original-url="http://blogs.msdn.com/blogfiles/varun_sharma/WindowsLiveWriter/catchthesecurityflaw5flawanditscounterme_13EF9/cth5_thumb.gif" width=428 border=0 mce_src="http://blogs.msdn.com/blogfiles/varun_sharma/WindowsLiveWriter/catchthesecurityflaw5flawanditscounterme_13EF9/cth5_thumb.gif"></A> </P>
<P>A much more secure way of writing the same code would be:-</P>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN> &lt;%@ Page Language=<SPAN style="COLOR: #006080">"C#"</SPAN> AutoEventWireup=<SPAN style="COLOR: #006080">"true"</SPAN> CodeFile=<SPAN style="COLOR: #006080">"Default2.aspx.cs"</SPAN> Inherits=<SPAN style="COLOR: #006080">"Default2"</SPAN> %&gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   2:</SPAN>      &lt;html xmlns=<SPAN style="COLOR: #006080">"http://www.w3.org/1999/xhtml"</SPAN> &gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   3:</SPAN>      &lt;body&gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   4:</SPAN>         &lt;form id=<SPAN style="COLOR: #006080">"form1"</SPAN> runat=<SPAN style="COLOR: #006080">"server"</SPAN>&gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   5:</SPAN>          &lt;asp:TextBox ID=<SPAN style="COLOR: #006080">"txtName"</SPAN> runat=<SPAN style="COLOR: #006080">"server"</SPAN>&gt;&lt;/asp:TextBox&gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   6:</SPAN>         &lt;asp:Button ID=<SPAN style="COLOR: #006080">"btnSubmit"</SPAN> runat=<SPAN style="COLOR: #006080">"server"</SPAN> Text=<SPAN style="COLOR: #006080">"Submit"</SPAN> OnClick=<SPAN style="COLOR: #006080">"btnSubmit_Click"</SPAN> /&gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   7:</SPAN>         &lt;asp:RegularExpressionValidator ID=<SPAN style="COLOR: #006080">"regexpName"</SPAN> runat=<SPAN style="COLOR: #006080">"server"</SPAN>     </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   8:</SPAN>                                         ErrorMessage=<SPAN style="COLOR: #006080">"This expression does not validate."</SPAN> </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   9:</SPAN>                                         ControlToValidate=<SPAN style="COLOR: #006080">"txtName"</SPAN>     </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  10:</SPAN>                                         ValidationExpression=<SPAN style="COLOR: #006080">"^[a-zA-Z'.\s]{1,40}$"</SPAN> /&gt;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  11:</SPAN>         &lt;/form&gt;&lt;/body&gt;&lt;/html&gt;</PRE></DIV></DIV>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN> <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #0000ff">partial</SPAN> <SPAN style="COLOR: #0000ff">class</SPAN> Default2 : System.Web.UI.Page</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   2:</SPAN> {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   3:</SPAN>     <SPAN style="COLOR: #0000ff">protected</SPAN> <SPAN style="COLOR: #0000ff">void</SPAN> Page_Load(<SPAN style="COLOR: #0000ff">object</SPAN> sender, EventArgs e)</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   4:</SPAN>     {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   5:</SPAN>     }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   6:</SPAN>     <SPAN style="COLOR: #0000ff">protected</SPAN> <SPAN style="COLOR: #0000ff">void</SPAN> btnSubmit_Click(<SPAN style="COLOR: #0000ff">object</SPAN> sender, EventArgs e)</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   7:</SPAN>     {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   8:</SPAN>         <SPAN style="COLOR: #0000ff">if</SPAN> (Page.IsValid)</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   9:</SPAN>         {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  10:</SPAN>             Response.Write(<SPAN style="COLOR: #006080">"Welcome "</SPAN> +</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  11:</SPAN>                 HttpUtility.HtmlEncode(txtName.Text));</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  12:</SPAN>         }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  13:</SPAN>     }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  14:</SPAN> }    </PRE></DIV></DIV>
<P>References:-<BR>[1] Request Object<BR><A href="http://msdn.microsoft.com/en-us/library/ms524948.aspx">http://msdn.microsoft.com/en-us/library/ms524948.aspx</A></P>]]></content:encoded>
    </item>
    <item>
      <title>Catch the security flaw #5</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/catch-the-security-flaw-5</link>
      <pubDate>Sun, 21 Dec 2008 23:57:24 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2008/12/21/catch-the-security-flaw-5/</guid>
      <description><![CDATA[A lot of web applications use RegularExpressionValidators for performing input validation [1]....]]></description>
      <content:encoded><![CDATA[<p>A lot of web applications use <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.regularexpressionvalidator.aspx" target="_blank">RegularExpressionValidators</a> for performing input validation [1]. Sometimes these validators are not implemented properly, which can lead to potential flaws. See if you can catch the flaw here:-</p>  <p>Code for Default.aspx:-</p>  <div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">   <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">     <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> &lt;%@ Page Language=<span style="color: #006080">&quot;C#&quot;</span> ValidateRequest=<span style="color: #006080">&quot;false&quot;</span> AutoEventWireup=<span style="color: #006080">&quot;true&quot;</span> CodeFile=<span style="color: #006080">&quot;Default2.aspx.cs&quot;</span> Inherits=<span style="color: #006080">&quot;Default2&quot;</span> %&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span>  &lt;html xmlns=<span style="color: #006080">&quot;http://www.w3.org/1999/xhtml&quot;</span> &gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span> &lt;body&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     &lt;form id=<span style="color: #006080">&quot;form1&quot;</span> runat=<span style="color: #006080">&quot;server&quot;</span>&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>&#160; </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     &lt;asp:TextBox ID=<span style="color: #006080">&quot;txtName&quot;</span> runat=<span style="color: #006080">&quot;server&quot;</span>&gt;&lt;/asp:TextBox&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     &lt;asp:Button ID=<span style="color: #006080">&quot;btnSubmit&quot;</span> runat=<span style="color: #006080">&quot;server&quot;</span> Text=<span style="color: #006080">&quot;Submit&quot;</span> OnClick=<span style="color: #006080">&quot;btnSubmit_Click&quot;</span> /&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     &lt;asp:RegularExpressionValidator ID=<span style="color: #006080">&quot;regexpName&quot;</span> runat=<span style="color: #006080">&quot;server&quot;</span>     </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>                                     ErrorMessage=<span style="color: #006080">&quot;This expression does not validate.&quot;</span> </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>                                     ControlToValidate=<span style="color: #006080">&quot;txtName&quot;</span>     </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span>                                     ValidationExpression=<span style="color: #006080">&quot;^[a-zA-Z'.\s]{1,40}$&quot;</span> /&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  12:</span>&#160; </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  13:</span>     &lt;/form&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  14:</span> &lt;/body&gt;</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  15:</span> &lt;/html&gt;</pre>
  </div>
</div>

<p>Code behind Default.aspx.cs file:-</p>

<div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; max-height: 200px; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, &#39;Courier New&#39;, courier, monospace; background-color: #f4f4f4">
  <div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none">
    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   1:</span> <span style="color: #0000ff">public</span> <span style="color: #0000ff">partial</span> <span style="color: #0000ff">class</span> Default2 : System.Web.UI.Page</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   2:</span> {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   3:</span>     <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> Page_Load(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   4:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   5:</span>&#160; </pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   6:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   7:</span>     <span style="color: #0000ff">protected</span> <span style="color: #0000ff">void</span> btnSubmit_Click(<span style="color: #0000ff">object</span> sender, EventArgs e)</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">   8:</span>     {</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">   9:</span>         Response.Write(<span style="color: #006080">&quot;Welcome &quot;</span> + Request[<span style="color: #006080">&quot;txtName&quot;</span>]);</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"><span style="color: #606060">  10:</span>     }</pre>

    <pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, &#39;Courier New&#39;, courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"><span style="color: #606060">  11:</span> }</pre>
  </div>
</div>

<p>&#160;</p>

<p>Reference:-</p>

<p>[1] How To: Use Regular Expressions to Constrain Input in ASP.NET
  <br /><a href="http://msdn.microsoft.com/en-us/library/ms998267.aspx">http://msdn.microsoft.com/en-us/library/ms998267.aspx</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Catch the Security Flaw(s) #4</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/catch-the-security-flaws-4</link>
      <pubDate>Tue, 02 Dec 2008 09:18:00 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2008/12/02/catch-the-security-flaws-4/</guid>
      <description><![CDATA[Identify as many security issues as you can with this piece of code:-...]]></description>
      <content:encoded><![CDATA[<P>Identify as many security issues as you can with this piece of code:-</P>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN>&nbsp;&nbsp;&nbsp;&nbsp; [WebMethod] </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   2:</SPAN>     <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #0000ff">string</SPAN> GetEmpName(<SPAN style="COLOR: #0000ff">string</SPAN> empid) </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   3:</SPAN>     { </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   4:</SPAN>         SqlConnection con = <SPAN style="COLOR: #0000ff">new</SPAN> SqlConnection(<SPAN style="COLOR: #006080">"server=.;database=test;uid=sa;pwd=PassW2rd12"</SPAN>); </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   5:</SPAN>         SqlCommand cmd = <SPAN style="COLOR: #0000ff">new</SPAN> SqlCommand(<SPAN style="COLOR: #006080">"select username from users where id = "</SPAN> + empid, con); </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   6:</SPAN>         con.Open(); </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   7:</SPAN>         <SPAN style="COLOR: #0000ff">string</SPAN> empname = (<SPAN style="COLOR: #0000ff">string</SPAN>)cmd.ExecuteScalar(); </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   8:</SPAN>         con.Close(); </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   9:</SPAN>         <SPAN style="COLOR: #0000ff">return</SPAN> empname; </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  10:</SPAN>     }</PRE></DIV></DIV>
<P>How many did you get? Lets go over them one by one:-</P>
<P>1. The SQL connection string uses SQL Authentication to connect to the server. If possible, you should use Windows authentication instead. This eliminates the need to store credentials in the application. </P>
<P>2. If Windows Authentication is not possible, store the connection string in the web.config file and encrypt it using the <A href="http://msdn.microsoft.com/en-us/library/ms998280.aspx" target=_blank mce_href="http://msdn.microsoft.com/en-us/library/ms998280.aspx">aspnet_regiis</A> tool. </P>
<P>3. The account used to connect to the SQL server is “sa”, which is a member of the all powerful sysadmin server role. Instead, the account used to connect to the SQL Server must have the least amount of permissions on the server as needed to do the job. </P>
<P>3. There is no validation for the “empid” parameter. If only integers are expected, try to parse it into an integer, otherwise use a regular expression for white list validation.</P>
<P>4. The “empid” parameters is being concatenated to form a SQL statement, which is then executed. This means that the application is vulnerable to SQL Injection. Instead of concatenating user input to create a SQL statement, use parameterized SQL. </P>
<P>5. There is no structured exception handling in this code. As a result, verbose error messages containing managed exceptions will be sent to the end user. Implement structured exception handling and close the connection in a <EM>finally</EM> block.</P>
<P>This is how the code looks after restructuring:-</P>
<DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; MAX-HEIGHT: 200px; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BACKGROUND-COLOR: #f4f4f4">
<DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   1:</SPAN>&nbsp; </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   2:</SPAN>     [WebMethod]</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   3:</SPAN>     <SPAN style="COLOR: #0000ff">public</SPAN> <SPAN style="COLOR: #0000ff">string</SPAN> GetEmpName(<SPAN style="COLOR: #0000ff">string</SPAN> empid)</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   4:</SPAN>     {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   5:</SPAN>         <SPAN style="COLOR: #0000ff">int</SPAN> id;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   6:</SPAN>         <SPAN style="COLOR: #0000ff">if</SPAN> (<SPAN style="COLOR: #0000ff">int</SPAN>.TryParse(empid, <SPAN style="COLOR: #0000ff">out</SPAN> id))</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   7:</SPAN>         {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   8:</SPAN>             SqlConnection con = <SPAN style="COLOR: #0000ff">new</SPAN> SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings[<SPAN style="COLOR: #006080">"Conn"</SPAN>].ConnectionString);</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">   9:</SPAN>             SqlCommand cmd = <SPAN style="COLOR: #0000ff">new</SPAN> SqlCommand(<SPAN style="COLOR: #006080">"select username from users where id = @id"</SPAN>, con);</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  10:</SPAN>             cmd.Parameters.Add(<SPAN style="COLOR: #0000ff">new</SPAN> SqlParameter(<SPAN style="COLOR: #006080">"@id"</SPAN>, id));</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  11:</SPAN>             <SPAN style="COLOR: #0000ff">try</SPAN></PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  12:</SPAN>             {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  13:</SPAN>                 con.Open();</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  14:</SPAN>                 <SPAN style="COLOR: #0000ff">return</SPAN> (<SPAN style="COLOR: #0000ff">string</SPAN>)cmd.ExecuteScalar();</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  15:</SPAN>             }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  16:</SPAN>             <SPAN style="COLOR: #0000ff">catch</SPAN> (Exception exp)</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  17:</SPAN>             {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  18:</SPAN>                 LogException(exp);</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  19:</SPAN>                 <SPAN style="COLOR: #0000ff">throw</SPAN> <SPAN style="COLOR: #0000ff">new</SPAN> ApplicationException(<SPAN style="COLOR: #006080">"An unexpected error occured"</SPAN>);</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  20:</SPAN>             }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  21:</SPAN>             <SPAN style="COLOR: #0000ff">finally</SPAN></PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  22:</SPAN>             {</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  23:</SPAN>                 <SPAN style="COLOR: #0000ff">if</SPAN> (con != null &amp;&amp; con.State == ConnectionState.Open)</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  24:</SPAN>                     con.Close();</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  25:</SPAN>             }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  26:</SPAN>         }</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  27:</SPAN>&nbsp; </PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: #f4f4f4; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  28:</SPAN>         <SPAN style="COLOR: #0000ff">return</SPAN> <SPAN style="COLOR: #0000ff">null</SPAN>;</PRE><PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas, 'Courier New', courier, monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"><SPAN style="COLOR: #606060">  29:</SPAN>     }</PRE></DIV></DIV>]]></content:encoded>
    </item>
    <item>
      <title>NASSCOM – DSCI Information Security Summit 2008 Security Tutorial</title>
      <link>https://docs.microsoft.com/archive/blogs/varun_sharma/nasscom-dsci-information-security-summit-2008-security-tutorial</link>
      <pubDate>Mon, 24 Nov 2008 06:38:13 GMT</pubDate>
      <dc:creator><![CDATA[Varun Sharma]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/varun_sharma/2008/11/24/nasscom-dsci-information-security-summit-2008-security-tutorial/</guid>
      <description><![CDATA[My colleague Sagar and I will be conducting an application security workshop at the NASSCOM – DSCI...]]></description>
      <content:encoded><![CDATA[<p></p>  <p>My colleague Sagar and I will be conducting an application security workshop at the NASSCOM – DSCI Information Security Summit 2008 on the 1st December in IIIT, Hyderabad, India. </p>  <p>More information can be found here:- </p>  <p></p>  <p></p>  <p><a title="http://www.nasscom.in/Nasscom/Templates/CustomEvents.aspx?id=55164" href="http://www.nasscom.in/Nasscom/Templates/CustomEvents.aspx?id=55164">http://www.nasscom.in/Nasscom/Templates/CustomEvents.aspx?id=55164</a>&#160;</p>  <p>The agenda is here:-</p>  <p><a title="http://www.nasscom.in/upload/59314/Agenda_Tutorial.pdf" href="http://www.nasscom.in/upload/59314/Agenda_Tutorial.pdf">http://www.nasscom.in/upload/59314/Agenda_Tutorial.pdf</a></p>]]></content:encoded>
    </item>
  </channel>
</rss>