The Artima Developer Community
Sponsored Link

Artima Developer Spotlight Forum
SANS Compiles Top 25 Most Dangerous Programming Errors

27 replies on 2 pages. Most recent reply: Jan 30, 2009 7:21 AM by Fireblaze .

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 27 replies on 2 pages [ 1 2 | » ]
Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 12, 2009 5:42 PM
Reply to this message Reply
Advertisement

The SANS (SysAdmin, Audit, Network, Security) Institute, together with a host of other private and governmental organizations, compiled a list of the Top 25 Most Dangerous Programming Errors. The aim of the list is partly to highlight that a relatively short list of coding errors lead to an overwhelming number of security breaches and software defects.

According to the SANS report,

The impact of these errors is far reaching. Just two of them led to more than 1.5 million web site security breaches during 2008 - and those breaches cascaded onto the computers of people who visited those web sites, turning their computers into zombies.

The Top 25 list was compiled with input from a vast array companies and government organizations:

Ranging from Symantec and Microsoft, to DHS's National Cyber Security Division and NSA's Information Assurance Division, to OWASP and the Japanese IPA, to the University of California at Davis and Purdue University. The MITRE and the SANS Institute managed the Top 25 Errors initiative, but the impetus for this project came from the National Security Agency and financial support for MITRE's project engineers came from the US Department of Homeland Security's National Cyber Security Division...

The top 25 errors are divided into three categories:

  • Insecure Interaction Between Components (9 errors)
  • Risky Resource Management (9 errors)
  • Porous Defenses (7 errors)

The errors listed are the following. SANS Web site contains more in-depth description of each error type:

  • Improper Input Validation
  • Improper Encoding or Escaping of Output
  • Failure to Preserve SQL Query Structure (aka 'SQL Injection')
  • Failure to Preserve Web Page Structure (aka 'Cross-site Scripting')
  • Failure to Preserve OS Command Structure (aka 'OS Command Injection')
  • Cleartext Transmission of Sensitive Information
  • Cross-Site Request Forgery (CSRF)
  • Race Condition
  • Error Message Information Leak
  • Failure to Constrain Operations within the Bounds of a Memory Buffer
  • External Control of Critical State Data
  • External Control of File Name or Path
  • Untrusted Search Path
  • Failure to Control Generation of Code (aka 'Code Injection')
  • Download of Code Without Integrity Check
  • Improper Resource Shutdown or Release
  • Improper Initialization
  • Incorrect Calculation
  • Improper Access Control (Authorization)
  • Use of a Broken or Risky Cryptographic Algorithm
  • Hard-Coded Password
  • Insecure Permission Assignment for Critical Resource
  • Use of Insufficiently Random Values
  • Execution with Unnecessary Privileges
  • Client-Side Enforcement of Server-Side Security

What do you think of SANS's Top 25 list? How do you defend against those errors in your code?


Steve Merrick

Posts: 9
Nickname: erisian
Registered: Mar, 2008

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 13, 2009 4:01 AM
Reply to this message Reply
This looks at first sight like an article about how to avoid errors in your code, but turns out to be a commercial for secure programming: how to make your code as hard as possible for hackers to crack. This isn't a bad aim, but it would be better, I feel, to make the intention clear from the outset.

As it was, I started reading what I thought might be a valuable article, and discovered that it was of no interest or use to me at all.

Frank Sommers

Posts: 2642
Nickname: fsommers
Registered: Jan, 2002

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 13, 2009 7:24 AM
Reply to this message Reply
There are many open-source tools, as well as commercial ones, that help ensure that these types of errors are minimized. For example, I use FindBugs, which is very helpful in pinpointing possible issues, especially around the errors mentioned in this article.

Even though this list may seem like an obvious compilation of possible coding errors, it's easy to overlook some of these problems. I think it's important to integrate some form of automatic error checking, e.g., FindBugs, into the build process so that such problems are automatically flagged. It may also be helpful to prevent code checkins in the presence of such problems.

One issue, though, is that there is a diverse source of such errors. For instance, FindBugs works on Java code, but many cross-site scripting errors result from defective JavaScript, HTML, or a combination of these.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 13, 2009 8:55 AM
Reply to this message Reply
> Even though this list may seem like an obvious compilation
> of possible coding errors, it's easy to overlook some of
> these problems.

I think it's dangerous to assume that most developers recognize these practices as problems. I've found even the most well-known of these (SQL injection vulnerability) in the wild numerous times.

All developers should read through this list and many others like it and understand why these are problems. Relying solely on tools to find issues doesn't seem very bright to me.

nes

Posts: 137
Nickname: nn
Registered: Jul, 2004

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 14, 2009 10:10 AM
Reply to this message Reply
What came to my mind while reading this list is that while useful in many cases, neither tools nor mechanical verification methodology are the silver bullet to errors. Take for instance "Cleartext Transmission of Sensitive Information": how could a tool or a methodology possibly tell the programmer what information is confidential and what is not? This is more of a design error that requires domain and technical knowledge plus presence of mind to avoid it. I guess a checklist could help avoid the most common design errors of this type ...

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 15, 2009 6:58 AM
Reply to this message Reply
The errors are due to bad tools, not human stupidity:

* Improper Input Validation

On the UI level, there is no API that automates the editing of the data structures inside programs. The programmer should say "I want to edit this number that has a range from 10 to 20", not "textBox.toString().toInteger()".

On the programming language level, the use of fundamental data types (integers, floats, etc) is wrong. When a function requires a number in range 10..20, it's wrong to use a 32-bit integer or even a byte. But no programming language allows for that.

* Improper Encoding or Escaping of Output

End-to-end encryption is needed for all electronic communications on all protocol levels.

* Failure to Preserve SQL Query Structure (aka 'SQL Injection')

If the edited data were not strings but actual data with a type, then SQL injection would be impossible.

* Failure to Preserve Web Page Structure (aka 'Cross-site Scripting')

Also a result of non-encrypted communications.

* Failure to Preserve OS Command Structure (aka 'OS Command Injection')

The security model of existing operating systems is wrong. Just like you don't invite any stranger into your house, but only the ones that you have called, the operating systems should not allow execution of anything unless this anything has been 'invited'.

The security that hardware provides is also wrong: CPUs offer an all-or-nothing security model, i.e. the only security is at the process level. Within a process, there is no security between different components.

* Cleartext Transmission of Sensitive Information

Also a result of non-encrypted communications.

* Cross-Site Request Forgery (CSRF)

Encryption would solve this problem as well.

* Race Condition

The methods of accessing state in a multithreaded environment are not enforced mathematically in programming languages.

State shouldn't be shared between threads or processes, unless there is a logic that is validated as secure by a mathematical model.

* Error Message Information Leak

That's because programming languages do not force the programmer to handle all error cases, and therefore the information from thrown exceptions is sent to the client.

* Failure to Constrain Operations within the Bounds of a Memory Buffer

C and C++ are evil! Not even operating systems should be written in those languages.

There are (or can be) much safer alternatives.

* External Control of Critical State Data

Encryption and a better security model can fix this problem.

* External Control of File Name or Path

Better data input validation and better encryption can fix this problem.

* Untrusted Search Path

Encryption and a better security model can fix this problem.

* Failure to Control Generation of Code (aka 'Code Injection')

A better security model can fix this problem. Attackers may inject any code they like, but it would not do anything harmful.

* Download of Code Without Integrity Check

End-to-end encryption would solve this problem.

* Improper Resource Shutdown or Release

Resources are limited, but tools behave as if resources are unlimited. In most tools, there is no provision for the case when resources are low.

And the problem of error handling is at work here: resource allocation errors are not handled properly, and the tools do not force programmers to handle errors appropriately.

* Improper Initialization

More problems with tools:

1) programming languages allow data to be uninitialized (C/C++).

2) programming languages allow initialization to be skipped when errors happen.

* Incorrect Calculation

More typing and error handling issues.

* Improper Access Control (Authorization)

Bad security model. Capability-based security should be used.

* Use of a Broken or Risky Cryptographic Algorithm

End-to-end encryption would solve this problem: since everything would be encrypted by default, there would be no need to invent encryption.

* Hard-Coded Password

A programming language with a proper type system and a prohibition of hard-coded resources (perhaps enforced externally by a tool) would solve the problem.

* Insecure Permission Assignment for Critical Resource

Bad security model.

* Use of Insufficiently Random Values

Random numbers should be created by hardware random number generators.

Modern computers usually don't come with one.

* Execution with Unnecessary Privileges

Bad security model.

* Client-Side Enforcement of Server-Side Security

Encryption and a better security model can fix this problem.

Conclusion

I do not dismiss entirely current tools (operating systems and programming languages), but they are far from optimal.

All the above faults are the results of lack of proper typing, security model, error handling and communication encryption.

Computers were invented to automate tasks, so why typing, error handling, security and encryption are not fully automated?

Why do we blame the programmers for not doing their job correctly, and not blame the tools? after all, one of the reasons higher level languages were invented is to reduce the error rate of programs written in raw assembly.

We clearly need better tools, and these tools can exist, as research has shown.

I know that, in the end, it's all about economics, and it's not viable to replace everything we have with something new for economic reasons, but we have to ask ourselves:

For how long would we have to put up with billions of dollars of losses just because we can't spend a certainly smaller amount of money to improve our tools?

Sebastian Kübeck

Posts: 44
Nickname: sebastiank
Registered: Sep, 2005

Top 11 Reasons Why Top 10 (or Top 25) Lists Don’t Work Posted: Jan 17, 2009 1:47 PM
Reply to this message Reply
http://www.informit.com/articles/article.aspx?p=1322398

Summary:

1. Executives don't care about technical bugs.
2. Too much focus on bugs.
3. Vulnerability lists help auditors more than developers.
4. One person's top bug is another person's yawner.
5. Using bug parade lists for training leads to awareness but does not educate.
6. Bug lists change with the prevailing technology winds. 7. Top ten lists mix levels. Taxonomies are always superior to lists, especially when they are simple.
8. Automated tools can find bugs — let them.
9. Metrics built on top ten lists are misleading.
10. When it comes to testing, security requirements are more important than vulnerability lists.
11. Ten is not enough. A myopic focus on ten bugs makes little sense.

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: Top 11 Reasons Why Top 10 (or Top 25) Lists Don’t Work Posted: Jan 19, 2009 6:58 AM
Reply to this message Reply
> http://www.informit.com/articles/article.aspx?p=1322398
>
> Summary:

> 3. Vulnerability lists help auditors more than developers.

That article basically says the same thing over and over. I agree but that doesn't mean these lists don't have value. If the implication is that we must have bug lists without other education or there must be no bug lists, then that's obviously a false dichotomy.

Lists like are good for developers (especially novices) because they explain why it's good to do something. I can't tell you the number of times I've seen good practice jettisoned because no value was seen in the practice. Lists like this allow people to learn from the mistakes of others instead of learning the hard way.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 1:14 AM
Reply to this message Reply
> On the programming language level, the use of fundamental
> data types (integers, floats, etc) is wrong. When a
> function requires a number in range 10..20, it's wrong to
> use a 32-bit integer or even a byte. But no programming
> language allows for that.

Pascal and ADA spring to mind as two that do.

Achilleas Margaritis

Posts: 674
Nickname: achilleas
Registered: Feb, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 3:13 AM
Reply to this message Reply
> > On the programming language level, the use of
> fundamental
> > data types (integers, floats, etc) is wrong. When a
> > function requires a number in range 10..20, it's wrong
> to
> > use a 32-bit integer or even a byte. But no programming
> > language allows for that.
>
> Pascal and ADA spring to mind as two that do.

Which unfortunately are not widely used. Ada could solve lots of problems regarding safety and security.

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 3:55 AM
Reply to this message Reply
> > Pascal and ADA spring to mind as two that do.
>
> Which unfortunately are not widely used. Ada could solve
> lots of problems regarding safety and security.

It seems to be an idea which has failed to gain widespread acceptance. Does anyone know of any more recent examples of integer subrange types in a language?

Also worth mentioning is the failure of most languages to provide checks for integer overflow.

Alex Stojan

Posts: 95
Nickname: alexstojan
Registered: Jun, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 7:00 AM
Reply to this message Reply
> > > Pascal and ADA spring to mind as two that do.
> >
> > Which unfortunately are not widely used. Ada could
> solve
> > lots of problems regarding safety and security.
>
> It seems to be an idea which has failed to gain widespread
> acceptance. Does anyone know of any more recent examples
> of integer subrange types in a language?
>
> Also worth mentioning is the failure of most languages to
> provide checks for integer overflow.

How about using a user-defined type (class) to specify an integer range, including all the security checks and whatever else we might want to define for some specific purpose? Doesn't that make more sense than a built-in integer range construct?

Mark Thornton

Posts: 275
Nickname: mthornton
Registered: Oct, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 7:25 AM
Reply to this message Reply
>
> How about using a user-defined type (class) to specify an
> integer range, including all the security checks and
> whatever else we might want to define for some specific
> purpose? Doesn't that make more sense than a built-in
> integer range construct?

Expressing the subtype relationships could prove difficult (i.e. 1..2 is a subtype of 0..5).

Secondly any language powerful enough to describe such user defined types with full capabilities (including appropriate overloaded operators) is likely to present other problems. Notably permitting user overloading of operators remains controversial.

Alex Stojan

Posts: 95
Nickname: alexstojan
Registered: Jun, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 7:33 AM
Reply to this message Reply
> >
> > How about using a user-defined type (class) to specify
> an
> > integer range, including all the security checks and
> > whatever else we might want to define for some specific
> > purpose? Doesn't that make more sense than a built-in
> > integer range construct?
>
> Expressing the subtype relationships could prove difficult
> (i.e. 1..2 is a subtype of 0..5).
>

How do you do that in Pascal or Ada?


> Secondly any language powerful enough to describe such
> user defined types with full capabilities (including
> appropriate overloaded operators) is likely to present
> other problems. Notably permitting user overloading of
> operators remains controversial.

What problems specifically would that present?

James Watson

Posts: 2024
Nickname: watson
Registered: Sep, 2005

Re: SANS Compiles Top 25 Most Dangerous Programming Errors Posted: Jan 20, 2009 7:54 AM
Reply to this message Reply
> How about using a user-defined type (class) to specify an
> integer range, including all the security checks and
> whatever else we might want to define for some specific
> purpose? Doesn't that make more sense than a built-in
> integer range construct?

I don't know that it makes more sense. It makes as much sense.

The idea that just by providing the right features and tools we can eliminate bugs is completely bogus. All studies on the subject point to the contrary. Improvements in tooling can make a big difference but it will not solve the problem.

If the range can be specified on the variable, the programmer can still specify the wrong range. It's no more safe than many other comprehensive validation scheme. The point is that input should be checked. There's no tool that can protect us from incorrect specification.

I actually think that putting data validation in code is a bad solution for a lot of problems. For one, it makes code a lot harder to make reusable. The valid range for your application may not be the same as it is for my application. How would library and framework developers deal with that? They'd have to allow the maximum range supported by the type and that defeats the purpose.

Flat View: This topic has 27 replies on 2 pages [ 1  2 | » ]
Topic: Adobe's Adrian Ludwig on Running AIR on Linux Previous Topic   Next Topic Topic: The Jamon Templating Engine

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use