Home > Ask the Security Experts > Application Security Questions & Answers > How buffer-overflow vulnerabilities occur
Ask The Security Expert: Questions & Answers
EMAIL THIS

How buffer-overflow vulnerabilities occur

Michael Cobb EXPERT RESPONSE FROM: Michael Cobb

Pose a Question
Other Security Categories
Meet all Security Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 12 December 2005
I'm not sure I fully understand buffer overflows. While I can see how deficiencies in buffer management can result from inserting code into a target machine, I cannot see how a hacker can cause that code to be invoked, possibly in such a way that he/she then gains control of the target machine. Can hackers guarantee that their code is invoked or is it a matter of chance?

>
EXPERT RESPONSE
A buffer overflow occurs when a program or process tries to store more data in its allocated data storage area, or buffer, than was originally intended. Since buffers are created to contain a finite amount of data, the extra information can overflow into adjacent buffers. When this occurs, it corrupts or overwrites the valid data held in them. Overflowing a buffer for a local variable in a function can overwrite the return address of that function. (The return address is the next instruction the process should execute once the function completes.) This can cause a segmentation fault that can crash the program. In certain conditions, the hacker will receive a shell prompt after the crash, which gives them control of the computer. And more sophisticated attacks look to overwrite the return address with a pointer to the code they wish to run, instead of trying to attack a computer just by trying to crash it.

Stack-based buffer overflow attacks are the most common, but let's look at the heap-based Buffer Overrun in JPEG Processing (GDI+) exploit to see how ingenious buffer overflow attacks can be.

The Microsoft dynamic link library file called GDIPlus.dll contains libraries for the Graphical Device Interface Plus (GDI+) application programming interface (API). This allows programmers to represent graphical objects and transmit them to output devices, such as monitors and printers. This DLL includes the capability to process JPEG image files, but it normalizes the declared length of the area designed for comments in a JPEG file prior to checking its value. This can cause a heap-based buffer overflow. Heap-based buffer vulnerabilities occur if the unchecked copy of data is written to a buffer that is located on the heap. This means non-executable stack protection mechanisms can be bypassed, ultimately leaving the system vulnerable and allowing the hacker to point the next process to the code they wish to run. Ironically, they can store this in a comment area of the JPEG file. Now, if the hacker wishes to exploit this flaw, he/she only needs the victim to view the doctored image.

Buffer overflow exploits are common because programs written in relatively low-level programming languages, such as assembly language, C and C++, do not perform automatic bounds. This process checks on arrays or pointers and requires the programmer to manually manage the size of allocated memory. While a hacker can't guarantee that their exploit code will work every time, given the success of many viruses and worms, they can have a very high success rate. To see a Java applet demonstrating how buffer overflows work visit: http://nsfsecurity.pr.erau.edu/bom_docs/Demos/script.html. There is also a good beginner's tutorial called Writing Buffer Overflow Exploits at: http://www.securiteam.com/securityreviews/5OP0B006UQ.html.


Sound Off! -   Be the first to post a message to Sound Off!


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
Application Security
Protecting exposed servers from Google hacks (and Google 'dorks')
Which automated quality assurance tools can be used to test software?
Has proof-of-concept mobile device malware translated into any meaningful attacks?
How to test the security of personal details submitted to a website
Is security improved when the number of Internet gateways is reduced?
Are Internet cafe users' email credentials at risk?
Which operating system can best secure an FTP site?
Will firewall technology have to adapt to applications that use port 80?
How secure is a mobile phone platform that has an open source framework?
What ports should be opened and closed when IPsec filters are implemented?

Application Attacks (Buffer Overflows, Cross-Site Scripting)
Tips for SQL injection protection
Microsoft addresses XSS in Internet Explorer
Internet Explorer open to spoofing, scripting attacks
Software still plagued with security holes, researcher says
Microsoft tools won't be quick fix for SQL injection attacks
Microsoft identifies tools to address SQL injection attacks
New defenses for automated SQL injection attacks
Alarming SQL injection attacks
Adobe Flash Player flaw previously patched, Symantec says
Adobe zero day flaw being actively exploited in wild
Application Attacks (Buffer Overflows, Cross-Site Scripting) Research

Web Application Security (Also see Web Access Control)
Microsoft tools won't be quick fix for SQL injection attacks
New defenses for automated SQL injection attacks
HP aims at IBM with application vulnerability scanning as service
Information security book excerpts and reviews
Kaminsky on DNS rebinding attacks, hacking techniques
Webmail security: Best practices for data protection
Tracing malware's steps with RE:Trace
SQL injection attack infects hundreds of thousands of websites
PCI Council issues clarification on Web application security
Web security gateways keep Web-based malware at bay

RELATED GLOSSARY TERMS
Terms from Whatis.com − the technology online dictionary
cache poisoning  (SearchSecurity.com)
cyberterrorism  (SearchSecurity.com)
dictionary attack  (SearchSecurity.com)
directory harvest attack  (SearchSecurity.com)
distributed denial-of-service attack  (SearchSecurity.com)
JavaScript hijacking  (SearchSecurity.com)
ping of death  (SearchSecurity.com)
script kiddy  (SearchSecurity.com)
stack smashing  (SearchSecurity.com)
SYN flooding  (SearchSecurity.com)

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

TechTarget Security Media
Information Security View this month\\'s issue and subscribe today.
Information Security Decisions Apply online for free conference admission.
SearchSecurity.com
HomeNewsMagazineWebcastsWhite PapersLearningAdviceTopicsEventsAbout Us

About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2003 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts