jump to navigation

Top 10 Secure Coding Practices 4 January 2008

Posted by Ahmed Abdul Moniem in General Articles.
add a comment

Top 10 Secure Coding Practices

Added by Robert Seacord on Jun 21, 2007

  1. Validate input. Validate input from all untrusted data sources. Proper input validation can eliminate the vast majority of software vulnerabilities. Be suspicious of most external data sources, including command line arguments, network interfaces, environmental variables, and user controlled files [Seacord 05].
  2. Heed compiler warnings. Compile code using the highest warning level available for your compiler and eliminate warnings by modifying the code [C MSC00-A, C++ MSC00-A].
  3. Architect and design for security policies. Create a software architecture and design your software to implement and enforce security policies. For example, if your system requires different privileges at different times, consider dividing the system into distinct intercommunicating subsystems, each with an appropriate privilege set.
  4. Keep it simple. Keep the design as simple and small as possible [Saltzer 74, Saltzer 75]. Complex designs increase the likelihood that errors will be made in their implementation, configuration, and use. Additionally, the effort required to achieve an appropriate level of assurance increases dramatically as security mechanisms become more complex.
  5. Default deny. Base access decisions on permission rather than exclusion. This means that, by default, access is denied and the protection scheme identifies conditions under which access is permitted [Saltzer 74, Saltzer 75].
  6. Adhere to the principle of least privilege. Every process should execute with the the least set of privileges necessary to complete the job. Any elevated permission should be held for a minimum time. This approach reduces the opportunities an attacker has to execute arbitrary code with elevated privileges [Saltzer 74, Saltzer 75].
  7. Sanitize data sent to other systems. Sanitize all data passed to complex subsystems [C STR02-A] such as command shells, relational databases, and commercial off-the-shelf (COTS) components. Attackers may be able to invoke unused functionality in these components through the use of SQL, command, or other injection attacks. This is not necessarily an input validation problem because the complex subsystem being invoked does not understand the context in which the call is made. Because the calling process understands the context, it is responsible for sanitizing the data before invoking the subsystem.
  8. Practice defense in depth. Manage risk with multiple defensive strategies, so that if one layer of defense turns out to be inadequate, another layer of defense can prevent a security flaw from becoming an exploitable vulnerability and/or limit the consequences of a successful exploit. For example, combining secure programming techniques with secure runtime environments should reduce the likelihood that vulnerabilities remaining in the code at deployment time can be exploited in the operational environment [Seacord 05].
  9. Use effective quality assurance techniques. Good quality assurance techniques can be effective in identifying and eliminating vulnerabilities. Penetration testing, fuzz testing, and source code audits should all be incorporated as part of an effective quality assurance program. Independent security reviews can lead to more secure systems. External reviewers bring an independent perspective; for example, in identifying and correcting invalid assumptions [Seacord 05].
  10. Adopt a secure coding standard. Develop and/or apply a secure coding standard for your target development language and platform.

Bonus Secure Coding Practices

  1. Define security requirements. Identify and document security requirements early in the development life cycle and make sure that subsequent development artifacts are evaluated for compliance with those requirements. When security requirements are not defined, the security of the resulting system cannot be effectively evaluated.
  2. Model threats. Use threat modeling to anticipate the threats to which the software will be subjected. Threat modeling involves identifying key assets, decomposing the application, identifying and categorizing the threats to each asset or component, rating the threats based on a risk ranking, and then developing threat mitigation strategies that are implemented in designs, code, and test cases [Swiderski 04].

Bonus Photograph

I found the following photograph on the Web, and I’m still trying to figure out who owns the rights to it. If you know, please comment below.

I like this photograph because it illustrates how the easiest way to break system security is often to circumvent it rather than defeat it (as is the case with most software vulnerabilities related to insecure coding practices).

References

[Saltzer 74] Saltzer, J. H. “Protection and the Control of Information Sharing in Multics.” Communications of the ACM 17, 7 (July 1974): 388-402.

[Saltzer 75] Saltzer, J. H. & Schroeder, M. D. “The Protection of Information in Computer Systems.” Proceedings of the IEEE 63, 9 (September 1975), 1278-1308.

[Seacord 05] Seacord, R. Secure Coding in C and C++. Upper Saddle River, NJ: Addison-Wesley, 2006 (ISBN 0321335724).

[Swiderski 04] Swiderski, F. & Snyder, W. Threat Modeling. Redmond, WA: Microsoft Press, 2004.

Extending the ImageMap HTML Control with AJAX 1.0 Extensions 4 January 2008

Posted by Ahmed Abdul Moniem in Web Application Development.
add a comment

In this article, Bilal Haidar will show you how to extend the HTML ImageMap control by adding clickable hot spots so that when hovered over will popup a tiny window informing the user with more information on the spot selected using the AJAX Services.
by Bilal Haidar
Article Contents:

See full article from here

Setting up and running Subversion and Tortoise SVN with Visual Studio and .NET 4 January 2008

Posted by Ahmed Abdul Moniem in General Articles.
add a comment

by Rick Strahl

What’s covered:

This document describes the steps to install and configure Subversion, create a new repository and then walks through the basic steps required to set up local Visual Studio projects using Tortoise SVN.

This isn’t meant to be an all comprehensive tutorial on Subversion, but rather a quick step by step of the essential things to install and configure to get up and running. For more detail you can use the excellent Subversion and Tortoise SVN documentation.

See full article from here 

ASP.NET 2.0 CSS Friendly Control Adapters 1.0 4 January 2008

Posted by Ahmed Abdul Moniem in Web Application Development.
add a comment

Introduction

See full site from here

Welcome! ASP.NET is a great technology for building web sites but it would be even better if it provided more flexibility for customizing the rendered HTML. For example, the Menu control makes it simple to add a menu to a web site, but it would be better if it didn’t create <table> tags and was easier to style using CSS. Happily, it’s easy to customize and adapt the Menu control to generate better HTML. Indeed, you can modify any ASP.NET control so it produces exactly the HTML you want.

The key is to use something that may be new to you: control adapters. These are little chunks of logic that you add to your web site to effectively “adapt” an ASP.NET control to render the HTML you prefer. The ASP.NET 2.0 CSS Friendly Control Adapters kit provides pre-built control adapters that you can easily use to generate CSS friendly markup from some of the more commonly used ASP.NET controls.

Getting Started

Before trying to learn how control adapters work, it’s helpful to see them in action. Use the Examples menu at the top of this page to see the impact of adapting some of the ASP.NET controls.

Each example page lets you enable/disable the adapters so you can immediately see their impact. Likewise, you can dynamically change themes, swapping in a different set of CSS files without changing the HTML markup. A source code viewer lets you study how each sample is constructed.

These sample control adapters demonstrate how to build an ASP.NET web site that is particularly easy to style with CSS. Feel free to use, copy, clone and modify the markup, CSS and code that you find here. To experiment with a local copy of this web site:

  1. Install Visual Web Developer (VWD) or Visual Studio 2005 (VS).
  2. Download this kit’s VSI file. It adds a new web site template to your installation of VWD/VS.
  3. Use the File menu in VWD/VS to create a new web site that uses the new template: Tutorial on ASP.NET CSS Friendly Control Adapters.
  4. Run the new web site using the built-in Cassini web server (F5 key in VWD/VS).

Also you can see this video tutorial: How Do I: Utilize the CSS Friendly Control Adapters? from here

Web Embedding Fonts Tool (WEFT) 4 January 2008

Posted by Ahmed Abdul Moniem in Web Application Development.
add a comment

About WEFT

The Web Embedding Fonts Tool (WEFT) lets Web authors create ‘font objects’ that are linked to their Web pages so when viewed through the browser, pages are displayed in the style contained in the font object.

see the full article from here

Read/Write App.Config File with .NET 2.0 4 January 2008

Posted by Ahmed Abdul Moniem in Windows Application Development.
add a comment

Introduction

Author: Alois Kraus and the full article from here

This is my first CodeProject article. I would like to show you the most important changes in the System.Configuration namespace with .NET 2.0. I have looked at my blog referrer statistics and saw about 20 hits/day by Google. Most of them were searching information on how to configure the new Enterprise Library but there are also a significant number of people that seem to seek answers to the following questions:

  • How to read/write to App.Config?
  • How to store a list of objects in a config file via the System.Configuration mechanism?

Reason enough for me to shed more light on the System.Configuration namespace. The main changes from .NET 1.0/1.1 in the System.Configuration namespace are:

  • Write to your App.Config file through the Configuration class
  • New configuration model for Windows Forms applications
  • Store complex objects including object collections in your App.Config File
  • It is possible to store Connection Strings in the App.Config file. See ConnectionSettings which enables you to store your settings on an SQL Server. The Enterprise Library for Sample SqlConfiguration exercises this by implementing a SqlConfigurationSource which can store and retrieve a ConfigurationSection

So where to start? I think first I will show you the config file and explain how you can create it programmatically in your application.