About the Authors |
|
xv | |
Preface |
|
xvii | |
Acknowledgments |
|
xxi | |
|
I. Introduction to Software Security Assessment |
|
|
|
Software Vulnerability Fundamentals |
|
|
3 | (22) |
|
|
3 | (1) |
|
|
4 | (5) |
|
|
5 | (2) |
|
|
7 | (2) |
|
The Necessity of Auditing |
|
|
9 | (5) |
|
Auditing Versus Black Box Testing |
|
|
11 | (2) |
|
Code Auditing and the Development Life Cycle |
|
|
13 | (1) |
|
Classifying Vulnerabilities |
|
|
14 | (4) |
|
|
14 | (1) |
|
Implementation Vulnerabilities |
|
|
15 | (1) |
|
Operational Vulnerabilities |
|
|
16 | (1) |
|
|
17 | (1) |
|
|
18 | (5) |
|
|
18 | (1) |
|
|
19 | (1) |
|
Assumptions and Misplaced Trust |
|
|
20 | (1) |
|
|
21 | (1) |
|
|
21 | (1) |
|
|
22 | (1) |
|
|
23 | (2) |
|
|
25 | (42) |
|
|
25 | (1) |
|
Software Design Fundamentals |
|
|
26 | (10) |
|
|
26 | (1) |
|
Abstraction and Decomposition |
|
|
27 | (1) |
|
|
28 | (3) |
|
Principles of Software Design |
|
|
31 | (2) |
|
|
33 | (3) |
|
Enforcing Security Policy |
|
|
36 | (13) |
|
|
36 | (2) |
|
|
38 | (2) |
|
|
40 | (1) |
|
|
41 | (4) |
|
|
45 | (3) |
|
|
48 | (1) |
|
|
49 | (17) |
|
|
50 | (3) |
|
Application Architecture Modeling |
|
|
53 | (6) |
|
|
59 | (3) |
|
Documentation of Findings |
|
|
62 | (3) |
|
Prioritizing the Implementation Review |
|
|
65 | (1) |
|
|
66 | (1) |
|
|
67 | (24) |
|
|
67 | (1) |
|
|
68 | (5) |
|
|
68 | (1) |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
71 | (1) |
|
Spoofing and Identification |
|
|
72 | (1) |
|
|
73 | (1) |
|
Web-Specific Considerations |
|
|
73 | (3) |
|
|
73 | (1) |
|
|
74 | (1) |
|
|
74 | (1) |
|
|
75 | (1) |
|
Default Site Installations |
|
|
75 | (1) |
|
Overly Verbose Error Messages |
|
|
75 | (1) |
|
Public-Facing Administrative Interfaces |
|
|
76 | (1) |
|
|
76 | (13) |
|
|
76 | (3) |
|
|
79 | (4) |
|
|
83 | (6) |
|
|
89 | (2) |
|
Application Review Process |
|
|
91 | (76) |
|
|
91 | (1) |
|
Overview of the Application Review Process |
|
|
92 | (1) |
|
|
92 | (1) |
|
|
93 | (1) |
|
|
93 | (4) |
|
|
94 | (1) |
|
|
95 | (1) |
|
|
96 | (1) |
|
|
97 | (9) |
|
|
98 | (1) |
|
|
98 | (1) |
|
|
99 | (2) |
|
|
101 | (2) |
|
|
103 | (2) |
|
|
105 | (1) |
|
Documentation and Analysis |
|
|
106 | (2) |
|
Reporting and Remediation Support |
|
|
108 | (1) |
|
|
109 | (2) |
|
External Flow Sensitivity |
|
|
109 | (2) |
|
|
111 | (1) |
|
|
111 | (22) |
|
Code Comprehension Strategies |
|
|
113 | (6) |
|
Candidate Point Strategies |
|
|
119 | (9) |
|
Design Generalization Strategies |
|
|
128 | (5) |
|
|
133 | (14) |
|
|
133 | (2) |
|
Subsystem and Dependency Analysis |
|
|
135 | (1) |
|
|
136 | (1) |
|
|
137 | (2) |
|
|
139 | (8) |
|
|
147 | (11) |
|
|
148 | (3) |
|
|
151 | (4) |
|
|
155 | (2) |
|
|
157 | (1) |
|
|
158 | (6) |
|
|
159 | (2) |
|
|
161 | (1) |
|
High-Level Attack Vectors |
|
|
162 | (2) |
|
Documentation of Findings |
|
|
164 | (1) |
|
|
164 | (3) |
|
II. Software Vulnerabilities |
|
|
|
|
167 | (36) |
|
|
167 | (1) |
|
|
168 | (19) |
|
|
169 | (1) |
|
|
169 | (11) |
|
|
180 | (3) |
|
|
183 | (3) |
|
Global and Static Data Overflows |
|
|
186 | (1) |
|
|
187 | (2) |
|
|
187 | (1) |
|
Finding Your Code in Memory |
|
|
188 | (1) |
|
|
189 | (7) |
|
|
190 | (1) |
|
Heap Implementation Hardening |
|
|
191 | (2) |
|
Nonexecutable Stack and Heap Protection |
|
|
193 | (1) |
|
Address Space Layout Randomization |
|
|
194 | (1) |
|
|
194 | (1) |
|
Function Pointer Obfuscation |
|
|
195 | (1) |
|
Assessing Memory Corruption Impact |
|
|
196 | (6) |
|
Where Is the Buffer Located in Memory? |
|
|
197 | (1) |
|
What Other Data Is Overwritten? |
|
|
197 | (1) |
|
How Many Bytes Can Be Overwritten? |
|
|
198 | (1) |
|
What Data Can Be Used to Corrupt Memory? |
|
|
199 | (2) |
|
Are Memory Blocks Shared? |
|
|
201 | (1) |
|
What Protections Are in Place? |
|
|
202 | (1) |
|
|
202 | (1) |
|
|
203 | (94) |
|
|
203 | (1) |
|
|
204 | (1) |
|
|
204 | (7) |
|
|
207 | (2) |
|
|
209 | (1) |
|
|
209 | (2) |
|
Arithmetic Boundary Conditions |
|
|
211 | (12) |
|
Unsigned Integer Boundaries |
|
|
213 | (7) |
|
Signed Integer Boundaries |
|
|
220 | (3) |
|
|
223 | (23) |
|
|
224 | (1) |
|
|
225 | (6) |
|
|
231 | (2) |
|
|
233 | (2) |
|
Integer Promotion Applications |
|
|
235 | (3) |
|
Usual Arithmetic Conversions |
|
|
238 | (4) |
|
Usual Arithmetic Conversion Applications |
|
|
242 | (2) |
|
|
244 | (2) |
|
Type Conversion Vulnerabilities |
|
|
246 | (25) |
|
Signed/Unsigned Conversions |
|
|
246 | (2) |
|
|
248 | (11) |
|
|
259 | (6) |
|
|
265 | (6) |
|
|
271 | (6) |
|
|
271 | (1) |
|
|
272 | (5) |
|
|
277 | (5) |
|
|
277 | (1) |
|
Pointer Arithmetic Overview |
|
|
278 | (2) |
|
|
280 | (2) |
|
|
282 | (14) |
|
|
282 | (2) |
|
|
284 | (3) |
|
|
287 | (1) |
|
|
288 | (1) |
|
|
289 | (7) |
|
|
296 | (1) |
|
|
297 | (90) |
|
|
297 | (1) |
|
|
298 | (28) |
|
|
298 | (9) |
|
Structure and Object Mismanagement |
|
|
307 | (5) |
|
|
312 | (4) |
|
|
316 | (3) |
|
|
319 | (2) |
|
|
321 | (5) |
|
|
326 | (13) |
|
|
327 | (9) |
|
|
336 | (1) |
|
|
337 | (2) |
|
|
339 | (23) |
|
|
339 | (1) |
|
Return Value Testing and Interpretation |
|
|
340 | (11) |
|
|
351 | (9) |
|
|
360 | (2) |
|
Auditing Memory Management |
|
|
362 | (23) |
|
|
362 | (7) |
|
|
369 | (8) |
|
Allocator Scorecards and Error Domains |
|
|
377 | (2) |
|
|
379 | (6) |
|
|
385 | (2) |
|
Strings and Metacharacters |
|
|
387 | (72) |
|
|
387 | (1) |
|
|
388 | (19) |
|
Unbounded String Functions |
|
|
388 | (5) |
|
|
393 | (7) |
|
|
400 | (7) |
|
|
407 | (11) |
|
|
408 | (3) |
|
|
411 | (3) |
|
|
414 | (4) |
|
Common Metacharacter Formats |
|
|
418 | (16) |
|
|
418 | (4) |
|
|
422 | (3) |
|
|
425 | (4) |
|
|
429 | (2) |
|
|
431 | (3) |
|
|
434 | (12) |
|
Eliminating Metacharacters |
|
|
434 | (5) |
|
|
439 | (2) |
|
|
441 | (5) |
|
Character Sets and Unicode |
|
|
446 | (11) |
|
|
446 | (4) |
|
Windows Unicode Functions |
|
|
450 | (7) |
|
|
457 | (2) |
|
Unix I: Privileges and Files |
|
|
459 | (100) |
|
|
459 | (1) |
|
|
460 | (4) |
|
|
461 | (1) |
|
|
462 | (2) |
|
|
464 | (1) |
|
|
464 | (13) |
|
|
466 | (2) |
|
|
468 | (7) |
|
|
475 | (2) |
|
Privilege Vulnerabilities |
|
|
477 | (17) |
|
Reckless Use of Privileges |
|
|
477 | (2) |
|
Dropping Privileges Permanently |
|
|
479 | (7) |
|
Dropping Privileges Temporarily |
|
|
486 | (2) |
|
Auditing Privilege-Management Code |
|
|
488 | (3) |
|
|
491 | (3) |
|
|
494 | (18) |
|
|
494 | (1) |
|
|
495 | (3) |
|
|
498 | (1) |
|
Privilege Management with File Operations |
|
|
499 | (1) |
|
|
500 | (3) |
|
|
503 | (1) |
|
|
503 | (4) |
|
|
507 | (1) |
|
|
508 | (4) |
|
|
512 | (3) |
|
|
512 | (1) |
|
|
513 | (1) |
|
|
514 | (1) |
|
|
515 | (11) |
|
|
515 | (7) |
|
|
522 | (4) |
|
|
526 | (12) |
|
|
527 | (1) |
|
The stat() Family of Functions |
|
|
528 | (4) |
|
|
532 | (1) |
|
|
533 | (1) |
|
|
534 | (1) |
|
|
535 | (3) |
|
|
538 | (9) |
|
|
538 | (6) |
|
|
544 | (2) |
|
Temporary Directory Cleaners |
|
|
546 | (1) |
|
|
547 | (10) |
|
|
548 | (2) |
|
|
550 | (5) |
|
|
555 | (1) |
|
|
556 | (1) |
|
|
557 | (2) |
|
|
559 | (66) |
|
|
559 | (1) |
|
|
560 | (5) |
|
|
560 | (2) |
|
|
562 | (1) |
|
|
562 | (1) |
|
|
563 | (2) |
|
|
565 | (7) |
|
|
565 | (5) |
|
|
570 | (2) |
|
|
572 | (39) |
|
Process Attribute Retention |
|
|
573 | (1) |
|
|
574 | (6) |
|
|
580 | (11) |
|
|
591 | (18) |
|
Process Groups, Sessions, and Terminals |
|
|
609 | (2) |
|
Interprocess Communication |
|
|
611 | (7) |
|
|
612 | (1) |
|
|
612 | (2) |
|
|
614 | (1) |
|
|
615 | (3) |
|
|
618 | (6) |
|
|
619 | (3) |
|
|
622 | (1) |
|
|
623 | (1) |
|
|
624 | (1) |
|
Windows I: Objects and the File System |
|
|
625 | (60) |
|
|
625 | (1) |
|
|
626 | (1) |
|
|
627 | (9) |
|
|
629 | (3) |
|
|
632 | (4) |
|
|
636 | (11) |
|
|
637 | (1) |
|
|
638 | (1) |
|
|
639 | (8) |
|
|
647 | (7) |
|
|
648 | (1) |
|
|
649 | (1) |
|
Security Descriptors Programming Interfaces |
|
|
649 | (3) |
|
|
652 | (2) |
|
|
654 | (5) |
|
|
654 | (1) |
|
ShellExecute and ShellExecuteEx |
|
|
655 | (1) |
|
|
656 | (2) |
|
|
658 | (1) |
|
|
659 | (21) |
|
|
659 | (2) |
|
|
661 | (15) |
|
|
676 | (4) |
|
|
680 | (4) |
|
|
681 | (1) |
|
|
682 | (2) |
|
|
684 | (1) |
|
Windows II: Interprocess Communication |
|
|
685 | (70) |
|
|
685 | (1) |
|
|
686 | (3) |
|
|
686 | (2) |
|
|
688 | (1) |
|
|
689 | (9) |
|
|
690 | (1) |
|
|
690 | (1) |
|
|
691 | (3) |
|
|
694 | (3) |
|
|
697 | (1) |
|
|
697 | (1) |
|
|
698 | (7) |
|
|
698 | (1) |
|
|
699 | (1) |
|
|
699 | (1) |
|
|
700 | (3) |
|
|
703 | (2) |
|
|
705 | (1) |
|
|
705 | (1) |
|
|
706 | (1) |
|
|
706 | (19) |
|
|
706 | (1) |
|
|
707 | (1) |
|
Microsoft Interface Definition Language |
|
|
708 | (1) |
|
|
708 | (2) |
|
Application Configuration Files |
|
|
710 | (1) |
|
|
711 | (5) |
|
|
716 | (2) |
|
Context Handles and State |
|
|
718 | (3) |
|
|
721 | (1) |
|
Auditing RPC Applications |
|
|
722 | (3) |
|
|
725 | (29) |
|
|
725 | (6) |
|
DCOM Configuration Utility |
|
|
731 | (1) |
|
DCOM Application Identity |
|
|
732 | (1) |
|
DCOM Subsystem Access Permissions |
|
|
733 | (1) |
|
|
734 | (2) |
|
|
736 | (2) |
|
|
738 | (2) |
|
|
740 | (1) |
|
Auditing DCOM Applications |
|
|
741 | (8) |
|
|
749 | (5) |
|
|
754 | (1) |
|
Synchronization and State |
|
|
755 | (74) |
|
|
755 | (1) |
|
|
756 | (6) |
|
Reentrancy and Asynchronous-Safe Code |
|
|
757 | (2) |
|
|
759 | (1) |
|
|
760 | (2) |
|
|
762 | (21) |
|
System V Process Synchronization |
|
|
762 | (3) |
|
Windows Process Synchronization |
|
|
765 | (5) |
|
Vulnerabilities with Interprocess Synchronization |
|
|
770 | (13) |
|
|
783 | (27) |
|
|
786 | (1) |
|
|
786 | (2) |
|
|
788 | (3) |
|
|
791 | (18) |
|
|
809 | (1) |
|
|
810 | (15) |
|
|
811 | (2) |
|
|
813 | (2) |
|
Threading Vulnerabilities |
|
|
815 | (10) |
|
|
825 | (4) |
|
III. Software Vulnerabilities in Practice |
|
|
|
|
829 | (62) |
|
|
829 | (2) |
|
|
831 | (32) |
|
|
832 | (2) |
|
|
834 | (2) |
|
Basic IP Header Validation |
|
|
836 | (8) |
|
|
844 | (7) |
|
|
851 | (2) |
|
|
853 | (10) |
|
|
863 | (1) |
|
Basic UDP Header Validation |
|
|
864 | (1) |
|
|
864 | (1) |
|
Transmission Control Protocol |
|
|
864 | (26) |
|
Basic TCP Header Validation |
|
|
866 | (1) |
|
|
867 | (2) |
|
|
869 | (3) |
|
|
872 | (8) |
|
|
880 | (10) |
|
|
890 | (1) |
|
|
891 | (30) |
|
|
891 | (1) |
|
|
892 | (4) |
|
Proxy Versus Packet Filters |
|
|
893 | (2) |
|
|
895 | (1) |
|
|
895 | (1) |
|
Packet-Filtering Firewalls |
|
|
896 | (1) |
|
|
896 | (9) |
|
|
896 | (3) |
|
|
899 | (2) |
|
|
901 | (1) |
|
|
902 | (3) |
|
Simple Stateful Firewalls |
|
|
905 | (4) |
|
|
905 | (1) |
|
|
906 | (1) |
|
|
906 | (1) |
|
|
907 | (2) |
|
Stateful Inspection Firewalls |
|
|
909 | (5) |
|
|
911 | (3) |
|
|
914 | (6) |
|
|
914 | (3) |
|
|
917 | (2) |
|
Spooky Action at a Distance |
|
|
919 | (1) |
|
|
920 | (1) |
|
Network Application Protocols |
|
|
921 | (86) |
|
|
921 | (1) |
|
Auditing Application Protocols |
|
|
922 | (15) |
|
|
922 | (1) |
|
Identify Elements of Unknown Protocols |
|
|
923 | (4) |
|
Match Data Types with the Protocol |
|
|
927 | (8) |
|
|
935 | (1) |
|
Access to System Resources |
|
|
935 | (2) |
|
Hypertext Transfer Protocol |
|
|
937 | (11) |
|
|
937 | (3) |
|
|
940 | (1) |
|
|
941 | (1) |
|
|
942 | (6) |
|
Internet Security Association and Key Management Protocol |
|
|
948 | (24) |
|
|
952 | (4) |
|
|
956 | (15) |
|
Encryption Vulnerabilities |
|
|
971 | (1) |
|
Abstract Syntax Notation (ASN.1) |
|
|
972 | (12) |
|
|
975 | (1) |
|
Canonical Encoding and Distinguished Encoding |
|
|
976 | (1) |
|
Vulnerabilities in BER, CER, and DER Implementations |
|
|
977 | (2) |
|
Packed Encoding Rules (PER) |
|
|
979 | (4) |
|
|
983 | (1) |
|
|
984 | (1) |
|
|
984 | (21) |
|
Domain Names and Resource Records |
|
|
984 | (2) |
|
Name Servers and Resolvers |
|
|
986 | (1) |
|
|
987 | (1) |
|
Resource Record Conventions |
|
|
988 | (1) |
|
|
989 | (1) |
|
DNS Protocol Structure Primer |
|
|
990 | (3) |
|
|
993 | (3) |
|
|
996 | (6) |
|
|
1002 | (3) |
|
|
1005 | (2) |
|
|
1007 | (76) |
|
|
1007 | (1) |
|
|
1008 | (6) |
|
|
1009 | (1) |
|
|
1009 | (1) |
|
|
1009 | (1) |
|
|
1010 | (1) |
|
|
1011 | (1) |
|
Server-Side Transformation |
|
|
1012 | (1) |
|
|
1013 | (1) |
|
|
1014 | (13) |
|
|
1014 | (3) |
|
|
1017 | (1) |
|
|
1018 | (2) |
|
|
1020 | (2) |
|
|
1022 | (5) |
|
State and HTTP Authentication |
|
|
1027 | (13) |
|
|
1028 | (1) |
|
|
1029 | (1) |
|
|
1030 | (2) |
|
Embedding State in HTML and URLs |
|
|
1032 | (1) |
|
|
1033 | (3) |
|
|
1036 | (2) |
|
|
1038 | (2) |
|
|
1040 | (4) |
|
|
1040 | (1) |
|
|
1040 | (1) |
|
|
1041 | (1) |
|
|
1041 | (2) |
|
|
1043 | (1) |
|
Web Tier: Model-View-Controller |
|
|
1044 | (2) |
|
|
1046 | (14) |
|
|
1046 | (1) |
|
|
1047 | (1) |
|
|
1048 | (1) |
|
|
1049 | (7) |
|
|
1056 | (1) |
|
Authorization and Access Control |
|
|
1057 | (1) |
|
|
1058 | (1) |
|
Phishing and Impersonation |
|
|
1059 | (1) |
|
|
1060 | (15) |
|
|
1061 | (5) |
|
OS and File System Interaction |
|
|
1066 | (3) |
|
|
1069 | (1) |
|
|
1070 | (1) |
|
|
1071 | (3) |
|
|
1074 | (1) |
|
|
1075 | (1) |
|
Harsh Realities of the Web |
|
|
1075 | (3) |
|
|
1078 | (3) |
|
|
1081 | (2) |
|
|
1083 | (42) |
|
|
1083 | (1) |
|
Web Services and Service-Oriented Architecture |
|
|
1084 | (2) |
|
|
1085 | (1) |
|
|
1085 | (1) |
|
|
1085 | (1) |
|
Web Application Platforms |
|
|
1086 | (1) |
|
|
1086 | (7) |
|
|
1086 | (1) |
|
|
1087 | (4) |
|
|
1091 | (2) |
|
|
1093 | (3) |
|
|
1093 | (1) |
|
|
1094 | (1) |
|
|
1095 | (1) |
|
|
1095 | (1) |
|
|
1095 | (1) |
|
|
1096 | (1) |
|
|
1096 | (1) |
|
|
1096 | (9) |
|
|
1097 | (1) |
|
|
1098 | (1) |
|
|
1099 | (2) |
|
|
1101 | (1) |
|
|
1101 | (2) |
|
|
1103 | (1) |
|
|
1104 | (1) |
|
|
1105 | (8) |
|
|
1106 | (1) |
|
|
1107 | (1) |
|
|
1108 | (1) |
|
|
1108 | (1) |
|
|
1109 | (1) |
|
|
1110 | (1) |
|
|
1110 | (1) |
|
|
1111 | (1) |
|
|
1112 | (1) |
|
|
1113 | (5) |
|
|
1113 | (2) |
|
|
1115 | (1) |
|
|
1115 | (1) |
|
|
1116 | (1) |
|
|
1117 | (1) |
|
|
1118 | (1) |
|
|
1118 | (1) |
|
|
1118 | (5) |
|
|
1118 | (1) |
|
|
1119 | (1) |
|
|
1120 | (1) |
|
|
1120 | (1) |
|
|
1121 | (1) |
|
|
1121 | (1) |
|
|
1121 | (1) |
|
|
1121 | (2) |
|
|
1123 | (2) |
Bibliography |
|
1125 | (4) |
Index |
|
1129 | |