无忧论文网 · 始于1999 · 学术论文辅导与论文发表推荐服务

An overview of common programming security vulnerabilities and possible solutions

栏目
论文
具体类型
硕士毕业论文
语言
法文
用途
范文参考
更新
关键词
thesis范文overviewcommon programming security vulnerabilitiespossible solutions
分类标签
留学生论文帮写thesis
原站著录信息
原编号
lw201202071402442547
原文字数
5,421 字
原文件格式
DOC
原库登记日期
2012-02-07

摘要

Vrije Universiteit Brussel Faculteit Wetenschappen Departement Informatica en Toegepaste Informatica VRIJE UNIVERSITEIT BRUSSEL SCIENTIA VINCERE TENEBRAS An overview of common programming security vulnerabilities and possible solutions Proefschrift ingediend m…

Vrije Universiteit Brussel
Faculteit Wetenschappen
Departement Informatica en Toegepaste
Informatica
VRIJE UNIVERSITEIT BRUSSEL
SCIENTIA VINCERE TENEBRAS
An overview of common programming
security vulnerabilities and possible solutions
Proefschrift ingediend met het oog op het behalen van de graad van Licentiaat in
de Informatica
Door: Yves Younan
Promotor: Prof. Dr. D. Vermeir
Augustus 2003
Dedicated to the memory of Yolande De Moor, my mother (1944-2000).
Abstract
Programming security vulnerabilities are the most common cause of software security
breaches in current day computing. While these can easily be avoided by
an attentive programmer, many programs still contain these kinds of vulnerabilities.
This document will describe what the most commonly occuring ones are
and will then explain how these can be abused to make a program do something
it did not intend to do. We will then take a look at how a recent vulnerability
in popular piece of software was exploited to allow an attacker to take control of
the execution flow of that program. Several solutions exist to detect and prevent
many, though not all, of the vulnerabilities described in this document in existing
programs without requiring source code modifications, and in some cases without
even requiring access to the source code to the applications. We will take an indepth
look at how these solutions are implemented and what their effects are on
legitimate programs, how they attempt to mitigate the restrictions they impose and
what their impact is on the performance of the programs they attempt to protect.
We will also describe if and how these solutions can be bypassed.
Acknowledgements
First and foremost I would like to thank Prof. Dr. Dirk Vermeir for his insights
and comments while I was doing my internship and when I was writing this thesis.
I would also like to thank the following people:
Dirk van Deun, for proofreading and correcting lots of mistakes.
Theodor Ragnar Gislason a.k.a. DiGiT, for teaching me so much about
security many years ago.
Matt Miller a.k.a. skape, for interesting discussions.
The GOBBLES group, for answering my questions pertaining to their exploit.
|WARL0RD| for proofreading the night before the deadline and still finding
some mistakes.
1
Contents
1 Introduction 6
2 Introduction to the IA32-Architecture 9
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.2 Two’s complement . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.3 Memory organization . . . . . . . . . . . . . . . . . . . . . . . . 10
2.3.1 Memory models . . . . . . . . . . . . . . . . . . . . . . 10
2.3.2 Real and protected mode . . . . . . . . . . . . . . . . . . 11
2.3.3 Global and local descriptor tables . . . . . . . . . . . . . 11
2.3.4 Segment Selectors . . . . . . . . . . . . . . . . . . . . . 14
2.3.5 Paging . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.4 Registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.4.1 General purpose registers . . . . . . . . . . . . . . . . . . 18
2.4.2 Segment registers . . . . . . . . . . . . . . . . . . . . . . 19
2.4.3 Other basic registers . . . . . . . . . . . . . . . . . . . . 19
2.4.4 Memory management registers . . . . . . . . . . . . . . . 20
2.4.5 Control registers . . . . . . . . . . . . . . . . . . . . . . 20
2.5 Little Endian versus Big Endian . . . . . . . . . . . . . . . . . . 21
2.6 Procedure Calls . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.1 Introduction to stacks . . . . . . . . . . . . . . . . . . . . 21
2.6.2 Procedure stacks . . . . . . . . . . . . . . . . . . . . . . 21
2.6.3 Procedure call technicalities . . . . . . . . . . . . . . . . 22
3 Programming language and operating systems specifics 24
3.1 Procedure calls in C . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.2 System calls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.1 BSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
3.2.2 Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4 Shellcode 27
2
CONTENTS
5 Programming Security Vulnerabilities 33
5.1 Stack-based Overflows . . . . . . . . . . . . . . . . . . . . . . . 33
5.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.1.2 Exploitation of a buffer overflow . . . . . . . . . . . . . . 34
5.2 Heap-based Overflows . . . . . . . . . . . . . . . . . . . . . . . 39
5.2.1 Exploiting malloc . . . . . . . . . . . . . . . . . . . . . . 41
5.2.2 Off by five and off by one . . . . . . . . . . . . . . . . . 48
5.2.3 C++ Virtual Pointers . . . . . . . . . . . . . . . . . . . . 50
5.3 Double free . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.4 Integer Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 57
5.4.2 Integer Overflows . . . . . . . . . . . . . . . . . . . . . . 57
5.4.3 Integer Signedness Errors . . . . . . . . . . . . . . . . . 58
5.5 Format String Vulnerabilities . . . . . . . . . . . . . . . . . . . . 62
5.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 62
5.5.2 Format Strings . . . . . . . . . . . . . . . . . . . . . . . 63
5.5.3 Exploiting a format string vulnerability . . . . . . . . . . 63
5.6 Temporary file races . . . . . . . . . . . . . . . . . . . . . . . . 68
5.7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6 Case Study 70
6.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.2 Apache HTTPd exploit . . . . . . . . . . . . . . . . . . . . . . . 70
6.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.3 Chunked Transfer Encoding . . . . . . . . . . . . . . . . . . . . 70
6.3.1 Analysis of the exploit . . . . . . . . . . . . . . . . . . . 72
6.3.2 Vulnerable apache code . . . . . . . . . . . . . . . . . . 76
7 Solutions 79
7.1 Non-executable stack . . . . . . . . . . . . . . . . . . . . . . . . 79
7.1.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 79
7.1.2 Openwall Linux kernel patch . . . . . . . . . . . . . . . . 79
7.1.3 Non-executable stack problems . . . . . . . . . . . . . . 80
7.2 Non-executable pages . . . . . . . . . . . . . . . . . . . . . . . . 88
7.2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 88
7.2.2 PaX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
7.3 Defeating non-executable-memory: return-into-libc . . . . . . . . 97
7.3.1 Introduction to the executable and linking format . . . . . 97
7.3.2 Return-into-libc . . . . . . . . . . . . . . . . . . . . . . . 98
7.4 Changing mmap()’ed addresses . . . . . . . . . . . . . . . . . . . 99
7.4.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 99
3
CONTENTS
7.4.2 Openwall . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.4.3 PaX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
7.4.4 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . 100
7.5 Canaries: StackGuard . . . . . . . . . . . . . . . . . . . . . . . . 101
7.5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 101
7.5.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . 102
7.5.3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . 105
7.5.4 Bypassing StackGuard . . . . . . . . . . . . . . . . . . . 105
7.6 Stack Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
7.6.1 Global ret stack method . . . . . . . . . . . . . . . . . . 107
7.6.2 Ret Range Check Method . . . . . . . . . . . . . . . . . 109
7.6.3 Conclusion . . . . . . . . . . . . . . . . . .

全文与附件

提交申请后,可在会员中心查看原件和附件的查找进度。

申请查询全文与附件