Acknowledgments |
|
xiii | |
Introduction |
|
xv | |
Part I Primer |
|
|
1 Welcome to the Wide World of Web Application Security |
|
|
3 | (20) |
|
Misplaced Priorities and the Need for a New Focus |
|
|
4 | (2) |
|
Network Security versus Application Security: The Parable of the Wizard and the Magic Fruit Trees |
|
|
6 | (3) |
|
|
7 | (2) |
|
|
9 | (2) |
|
|
11 | (9) |
|
|
13 | (1) |
|
2 Cross-Site Scripting (XSS) |
|
|
13 | (1) |
|
3 Broken Authentication and Session Management |
|
|
14 | (1) |
|
4 Insecure Direct Object References |
|
|
15 | (1) |
|
5 Cross-Site Request Forgery |
|
|
15 | (1) |
|
6 Security Misconfiguration |
|
|
16 | (1) |
|
7 Insecure Cryptographic Storage |
|
|
16 | (1) |
|
8 Failure to Restrict URL Access |
|
|
17 | (1) |
|
9 Insufficient Transport Layer Protection |
|
|
18 | (1) |
|
10 Unvalidated Redirects and Forwards |
|
|
19 | (1) |
|
Wrapping Up the OWASP Top Ten |
|
|
19 | (1) |
|
Secure Features, Not Just Security Features |
|
|
20 | (1) |
|
|
21 | (2) |
|
|
23 | (30) |
|
|
24 | (8) |
|
|
25 | (2) |
|
|
27 | (3) |
|
More Validation Practices |
|
|
30 | (1) |
|
The Defense-in-Depth Approach |
|
|
31 | (1) |
|
|
32 | (3) |
|
Attack Surface Reduction Rules of Thumb |
|
|
34 | (1) |
|
Classifying and Prioritizing Threats |
|
|
35 | (18) |
|
|
36 | (2) |
|
|
38 | (1) |
|
|
39 | (2) |
|
Common Weakness Enumeration (CWE) |
|
|
41 | (1) |
|
|
42 | (2) |
|
Common Vulnerability Scoring System (CVSS) |
|
|
44 | (9) |
Part II Web Application Security Principles |
|
|
|
53 | (38) |
|
|
54 | (2) |
|
Authentication Fundamentals |
|
|
56 | (4) |
|
|
57 | (3) |
|
Two-Factor and Three-Factor Authentication |
|
|
60 | (1) |
|
Web Application Authentication |
|
|
61 | (9) |
|
Password-Based Authentication Systems |
|
|
61 | (1) |
|
Built-In FM? Authentication |
|
|
61 | (3) |
|
Single Sign-On Authentication |
|
|
64 | (3) |
|
Custom Authentication Systems |
|
|
67 | (2) |
|
|
69 | (1) |
|
Securing Password-Based Authentication |
|
|
70 | (10) |
|
Attacks Against Passwords |
|
|
70 | (4) |
|
The Importance of Password Complexity |
|
|
74 | (2) |
|
|
76 | (4) |
|
Secure Authentication Best Practices |
|
|
80 | (11) |
|
When and Where to Perform Authentication |
|
|
80 | (4) |
|
Securing Web Authentication Mechanisms |
|
|
84 | (7) |
|
|
91 | (58) |
|
|
92 | (38) |
|
|
93 | (1) |
|
|
93 | (1) |
|
Authorization Fundamentals |
|
|
94 | (2) |
|
|
96 | (1) |
|
Detailed Authorization Check Process |
|
|
96 | (6) |
|
|
102 | (1) |
|
|
103 | (5) |
|
|
108 | (8) |
|
Custom Authorization Mechanisms |
|
|
116 | (4) |
|
|
120 | (1) |
|
|
121 | (2) |
|
Web Authorization Best Practices |
|
|
123 | (4) |
|
Attacks Against Authorization |
|
|
127 | (3) |
|
Session Management Fundamentals |
|
|
130 | (10) |
|
|
130 | (3) |
|
How to Manage Session State? |
|
|
133 | (1) |
|
Why Do We Need Session Management? |
|
|
134 | (1) |
|
|
135 | (1) |
|
|
136 | (2) |
|
Jetty: Session Predictability in the Real World |
|
|
138 | (2) |
|
Attacks Against Session State |
|
|
140 | (1) |
|
Securing Web Application Session Management |
|
|
140 | (9) |
|
Session Management Best Practices |
|
|
141 | (8) |
|
5 Browser Security Principles: The Same-Origin Policy |
|
|
149 | (20) |
|
Defining the Same-Origin Policy |
|
|
150 | (5) |
|
An Important Distinction: Client-Side vs. Server-Side |
|
|
152 | (2) |
|
A World Without the Same-Origin Policy |
|
|
154 | (1) |
|
Exceptions to the Same-Origin Policy |
|
|
155 | (11) |
|
|
155 | (1) |
|
|
156 | (2) |
|
iframes and JavaScript document.domain |
|
|
158 | (3) |
|
Adobe Flash Player Cross-Domain Policy File |
|
|
161 | (3) |
|
|
164 | (1) |
|
XMLHttpRequest (Ajax) and Cross-Origin Resource Sharing |
|
|
164 | (2) |
|
|
166 | (1) |
|
Final Thoughts on the Same-Origin Policy |
|
|
166 | (3) |
|
6 Browser Security Principles: Cross-Site Scripting and Cross-Site Request Forgery |
|
|
169 | (44) |
|
|
170 | (27) |
|
Cross-Site Scripting Explained |
|
|
171 | (6) |
|
|
177 | (3) |
|
|
180 | (2) |
|
|
182 | (2) |
|
|
184 | (2) |
|
Another Variation: HTML Injection |
|
|
186 | (2) |
|
XSS Defense: Encoding Output |
|
|
188 | (3) |
|
XSS Defense: Sanitizing Input |
|
|
191 | (2) |
|
XSS Defense: Using a Reduced Markup Language |
|
|
193 | (1) |
|
XSS Defense-in-Depth: HttpOnly |
|
|
194 | (2) |
|
XSS Defense-in-Ltpth: Content Security Policy (CSP) |
|
|
196 | (1) |
|
Final Thoughts on Cross-Site Scripting |
|
|
197 | (1) |
|
Cross-Site Request Forgery |
|
|
197 | (16) |
|
Cross-Site Request Forgery Explained |
|
|
199 | (2) |
|
HTTP GET and the Concept of Safe Methods |
|
|
201 | (1) |
|
Ineffective CSRF Defense: Relying on POST |
|
|
202 | (1) |
|
Ineffective CSRF Defense: Checking the Referer Header |
|
|
202 | (2) |
|
Ineffective CSRF Defense: URL Rewriting |
|
|
204 | (1) |
|
Better CSRF Defense: Shared Secrets |
|
|
205 | (1) |
|
Better CSRF Defense: Double-Submitted Cookies |
|
|
206 | (1) |
|
|
207 | (1) |
|
|
208 | (1) |
|
What Being "Logged In" Means |
|
|
208 | (2) |
|
Final Thoughts on Cross-Site Request Forgery |
|
|
210 | (3) |
|
7 Database Security Principles |
|
|
213 | (40) |
|
Structured Query Language (SQL) Injection |
|
|
215 | (23) |
|
SQL Injection Effects and Confidentiality-Integrity-Availability |
|
|
217 | (6) |
|
The Dangers of Detailed Errors |
|
|
223 | (4) |
|
Blind SQL Injection: No Errors Required |
|
|
227 | (3) |
|
Solving the Problem: Validating Input |
|
|
230 | (2) |
|
|
232 | (1) |
|
Solving the Problem: Escaping Input |
|
|
233 | (5) |
|
Setting Database Permissions |
|
|
238 | (4) |
|
|
238 | (2) |
|
Separate Accounts for Separate Roles |
|
|
240 | (2) |
|
Stored Procedure Security |
|
|
242 | (4) |
|
The Stored-Procedures-Only Approach: Reducing Permissions Even Further |
|
|
243 | (1) |
|
SQL Injection in Stored Procedures |
|
|
244 | (2) |
|
Insecure Direct Object References |
|
|
246 | (7) |
|
No Technical Knowledge Required |
|
|
246 | (2) |
|
Insecure Direct Object References and Confidentiality-Integrity-Availability |
|
|
248 | (1) |
|
Solving the Problem: Pre- or Post-Request Authorization Checks |
|
|
249 | (2) |
|
Final Thoughts on Insecure Direct Object References |
|
|
251 | (2) |
|
8 File Security Principles |
|
|
253 | (34) |
|
Keeping Your Source Code Secret |
|
|
254 | (17) |
|
Static Content and Dynamic Content |
|
|
256 | (2) |
|
|
258 | (1) |
|
Interpreted versus Compiled Code |
|
|
259 | (1) |
|
|
260 | (4) |
|
|
264 | (1) |
|
Keep Secrets Out of Static Files |
|
|
265 | (3) |
|
Exposing Sensitive Functionality |
|
|
268 | (3) |
|
Security Through Obscurity |
|
|
271 | (1) |
|
|
271 | (7) |
|
Forceful Browsing and Insecure Direct Object References |
|
|
272 | (1) |
|
|
273 | (3) |
|
Redirect Workflow Manipulation |
|
|
276 | (2) |
|
|
278 | (4) |
|
|
279 | (1) |
|
More Directory Traversal Vulnerabilities |
|
|
280 | (2) |
|
|
282 | (5) |
Part III Secure Development and Deployment |
|
|
9 Secure Development Methodologies |
|
|
287 | |
|
|
288 | (5) |
|
|
288 | (3) |
|
The Penetrate-and-Patch Approach |
|
|
291 | (2) |
|
The Holistic Approach to Application Security |
|
|
293 | (18) |
|
|
294 | (2) |
|
|
296 | (5) |
|
|
301 | (2) |
|
|
303 | (3) |
|
|
306 | (3) |
|
Security Incident Response Planning |
|
|
309 | (2) |
|
Industry Standard Secure Development Methodologies and Maturity Models |
|
|
311 | (4) |
|
The Microsoft Security Development Lifecycle (SDL) |
|
|
311 | (1) |
|
OWASP Comprehensive Lightweight Application Security Process (CLASP) |
|
|
312 | (2) |
|
The Software Assurance Maturity Model (SAMM) |
|
|
314 | (1) |
|
The Building Security In Maturity Model (BSIMM) |
|
|
315 | (1) |
|
Conclusions on Secure Development Methodologies and Maturity Models |
|
|
316 | |
Epilogue The Wizard, the Giant, and the Magic |
|
Fruit Trees: A Happy Ending |
|
319 | (2) |
Index |
|
321 | |