Avoiding Buffer Overruns
来源:互联网 发布:中国钢铁进出口数据 编辑:程序博客网 时间:2024/06/16 07:03
Avoiding Buffer Overruns
A buffer overrun is one of the most common sources of security risk. A buffer overrun is essentially caused by treating unchecked, external input as trustworthy data. The act of copying this data, using operations such as CopyMemory, strcat, strcpy, or wcscpy, can create unanticipated results, which allows for system corruption. In the best of cases, your application will abort with a core dump, segmentation fault, or access violation. In the worst of cases, an attacker can exploit the buffer overrun by introducing and executing other malicious code in your process. Copying unchecked, input data into a stack-based buffer is the most common cause of exploitable faults.
Buffer overruns can occur in a variety of ways. The following list provides a brief introduction to a few types of buffer overrun situations and offers some ideas and resources to help you avoid creating new risks and mitigate existing ones:
- Static buffer overruns
A static buffer overrun occurs when a buffer, which has been declared on the stack, is written to with more data than it was allocated to hold. The less apparent versions of this error occur when unverified user input data is copied directly to a static variable, causing potential stack corruption.
- Heap overruns
Heap overruns, like static buffer overruns, can lead to memory and stack corruption. Because heap overruns occur in heap memory rather than on the stack, some people consider them to be less able to cause serious problems; nevertheless, heap overruns require real programming care and are just as able to allow system risks as static buffer overruns.
- Array indexing errors
Array indexing errors also are a source of memory overruns. Careful bounds checking and index management will help prevent this type of memory overrun.
Preventing buffer overruns is primarily about writing good code. Always validate all your inputs and fail gracefully when necessary. For more information about writing secure code, see the following resources:
- Maguire, Steve [1993], Writing Solid Code, ISBN 1-55615-551-4, Microsoft Press, Redmond, Washington.
- Howard, Michael and LeBlanc, David [2003], Writing Secure Code, 2d ed., ISBN 0-7356-1722-8, Microsoft Press, Redmond, Washington.
Safe string handling is a long-standing issue that continues to be addressed both by following good programming practices and often by using and retrofitting existing systems with secure, string-handling functions. An example of such a set of functions for the Windows shell starts with StringCbCat.
- Avoiding Buffer Overruns
- Avoiding Buffer Overruns
- Avoiding Buffer Overruns with String Safety
- Testing for Buffer Overruns
- Avoiding Delays
- Avoiding GetDlgItem
- Avoiding InvokeRequired
- Avoiding Mutating Tables
- Avoiding memory leaks
- Avoiding memory leaks
- Avoiding memory leaks
- Avoiding Memory Leaks
- Avoiding memory leaks
- Avoiding Memory Leaks
- Avoiding String Concatenation
- Avoiding Memory Leaks
- Avoiding memory leaks
- Avoiding Singleton Abuse
- 越狱相关四:iPhone修改位置信息
- iscrll.js ,新手入门,学习笔记。
- 执行apt-get install 报错:Errors were encountered while processing
- Block的使用
- 解决IE8使用jquery设置网页标题title报错
- Avoiding Buffer Overruns
- 【6月英语学习总结】--Baby需要被关爱
- redis主从配置不生效问题
- oracle帐号scott被锁定如何解锁
- 遍历map的方法
- Python Scrapy爬虫,整站爬取妹子图
- asp 文档缓存尚在构建中
- 关于管道和命令 rm: missing operand
- string的size()和length()