Q

Understanding and preventing integer overflows

Integer overflow exploits can completely take over your programs. Expert Jeff Williams explains the vulnerabilities that leave you open to these types of attacks.

What are integer overflows? How do they differ from buffer overflows? What kind of damage do they cause and how can I prevent them?
An integer overflow occurs whenever a computer program tries to store an integer into a register or variable that isn't large enough to hold that value. Generally, the size of these locations is determined by the size of the register on the processor being used, usually 32 bits. Buffer overflows are a different sort of exploit. (For an introduction to buffer overflows, see the chapter on buffer overflows from the OWASP Guide to Building Secure Web Applications and Web Services.)

Math operations such as addition, multiplication and shifts can produce a result that is too large to store -- an integer overflow. Depending on the compiler, this integer overflow can result in a sign error, truncating the largest or smallest portion of the result, or another type of error. An integer overflow could lead to a security problem if the overflow affects the value of a pointer that references other code or data in memory. An attack could exploit the integer overflow in a way that allows execution of arbitrary code, resulting in a complete takeover of the vulnerable program's process.

These flaws can be extremely tricky to find and eliminate. The best approach is to use a safe integer class that has been built to avoid these problems. David LeBlanc's column "Integer Handling with the C++ SafeInt Class" provides a detailed mathematical analysis of integer overflows.
This was first published in June 2006

Dig deeper on Internet Application Security

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchSOA

TheServerSide

SearchCloudApplications

SearchAWS

SearchBusinessAnalytics

SearchFinancialApplications

SearchHealthIT

Close