Foundations of Security: What Every Programmer Needs to Know / Edition 1

Foundations of Security: What Every Programmer Needs to Know / Edition 1

by Christoph Kern, Anita Kesavan, Neil Daswani

ISBN-10: 1590597842

ISBN-13: 9781590597842

Pub. Date: 02/15/2007

Publisher: Apress

Foundations of Security: What Every Programmer Needs to Know teaches new and current software professionals state-of-the-art software security design principles, methodology, and concrete programming techniques they need to build secure software systems. Once you're enabled with the techniques covered in this book, you can start to alleviate some of the

…  See more details below


Foundations of Security: What Every Programmer Needs to Know teaches new and current software professionals state-of-the-art software security design principles, methodology, and concrete programming techniques they need to build secure software systems. Once you're enabled with the techniques covered in this book, you can start to alleviate some of the inherent vulnerabilities that make today's software so susceptible to attack. The book uses web servers and web applications as running examples throughout the book.

For the past few years, the Internet has had a "wild, wild west" flavor to it. Credit card numbers are stolen in massive numbers. Commercial web sites have been shut down by Internet worms. Poor privacy practices come to light and cause great embarrassment to the corporations behind them. All these security-related issues contribute at least to a lack of trust and loss of goodwill. Often there is a monetary cost as well, as companies scramble to clean up the mess when they get spotlighted by poor security practices.

It takes time to build trust with users, and trust is hard to win back. Security vulnerabilities get in the way of that trust. Foundations of Security: What Every Programmer Needs To Know helps you manage risk due to insecure code and build trust with users by showing how to write code to prevent, detect, and contain attacks.

  • The lead author co-founded the Stanford Center for Professional Development Computer Security Certification.
  • This book teaches you how to be more vigilant and develop a sixth sense for identifying and eliminating potential security vulnerabilities.
  • You'll receive hands-on code examples for a deep and practical understanding of security.
  • You'll learn enough about security to get the job done.

Table of Contents

  1. Security Goals
  2. Secure Systems Design
  3. Secure Design Principles
  4. Exercises for Part 1
  5. Worms and Other Malware
  6. Buffer Overflows
  7. Client-State Manipulation
  8. SQL Injection
  9. Password Security
  10. Cross-Domain Security in Web Applications
  11. Exercises for Part 2
  12. Symmetric Key Cryptography
  13. Asymmetric Key Cryptography
  14. Key Management and Exchange
  15. MACs and Signatures
  16. Exercises for Part 3

Read More

Product Details

Publication date:
Expert's Voice Series
Edition description:
Sales rank:
Product dimensions:
6.90(w) x 9.10(h) x 0.90(d)

Table of Contents

Foreword     xv
About the Authors     xvii
About the Technical Reviewer     xix
Acknowledgments     xxi
Preface     xxiii
Security Design Principles
Security Goals     3
Security Is Holistic     3
Physical Security     4
Technological Security     4
Policies and Procedures     6
Authentication     7
Something You Know     7
Something You Have     8
Something You Are     10
Final Notes on Authentication     11
Authorization     12
Access Control Lists (ACLs)     13
Access Control Models     14
The Bell-LaPadula Model     15
Confidentiality     17
Message/Data Integrity     18
Accountability     19
Availability     20
Non-repudiation     21
Concepts at Work     22
Secure Systems Design     25
Understanding Threats     25
Defacement     26
Infiltration     26
Phishing     27
Pharming     28
Insider Threats     28
Click Fraud     29
Denial-of-Service (DoS)     29
Data Theft and Data Loss     30
Designing-In Security     30
Windows 98     31
The Internet     31
Turtle Shell Architectures     34
Convenience and Security     35
SimpleWebServer Code Example     35
Hypertext Transfer Protocol (HTTP)     35
Code Walkthrough     36
Security in Software Requirements     44
Specifying Error Handling Requirements     44
Sharing Requirements with Quality Assurance (QA)     46
Handling Internal Errors Securely     47
Including Validation and Fraud Checks     48
Writing Measurable Security Requirements     50
Security or Bust     50
Security by Obscurity     51
Flaws in the Approach     51
SimpleWebServer Obscurity     52
Things to Avoid     55
Open vs. Closed Source     57
A Game of Economics     58
"Good Enough" Security     59
Secure Design Principles     61
The Principle of Least Privilege     61
Defense-in-Depth     63
Prevent, Detect, Contain, and Recover     63
Don't Forget Containment and Recovery     64
Password Security Example     65
Diversity-in-Defense     65
Securing the Weakest Link     66
Weak Passwords     66
People     66
Implementation Vulnerabilities     67
Fail-Safe Stance     67
SimpleWebServer Fail-Safe Example     67
Attempted Fix 1: Checking the File Length     69
Attempted Fix 2: Don't Store the File in Memory     69
Fix: Don't Store the File in Memory, and Impose a Download Limit     70
Secure by Default     71
Simplicity     72
Usability     73
Security Features Do Not Imply Security     74
Exercises for Part 1     77
Secure Programming Techniques
Worms and Other Malware     83
What Is a Worm?     83
An Abridged History of Worms     84
The Morris Worm: What It Did     84
The Morris Worm: What We Learned     85
The Creation of CERT     86
The Code Red Worm     86
The Nimda Worm     87
The Blaster and SQL Slammer Worms     87
More Malware      89
Buffer Overflows     93
Anatomy of a Buffer Overflow     93
A Small Example     94
A More Detailed Example     94
The safe_gets() Function     98
Safe String Libraries     100
Additional Approaches     101
StackGuard     101
Static Analysis Tools     102
Performance     103
Heap-Based Overflows     103
Other Memory Corruption Vulnerabilities     103
Format String Vulnerabilities     104
Integer Overflows     104
Client-State Manipulation     107
Pizza Delivery Web Site Example     108
Attack Scenario     110
Solution 1: Authoritative State Stays at Server     112
Solution 2: Signed State Sent to Client     114
Using HTTP POST Instead of GET     117
Cookies     119
JavaScript     121
SQL Injection     123
Attack Scenario     124
Solutions     130
Why Blacklisting Does Not Work     130
Whitelisting-Based Input Validation     132
Escaping     132
Second Order SQL Injection     133
Prepared Statements and Bind Variables     134
Mitigating the Impact of SQL Injection Attacks     136
Password Security     139
A Strawman Proposal     139
Hashing     141
Offline Dictionary Attacks     143
Salting     144
Online Dictionary Attacks     150
Additional Password Security Techniques     151
Strong Passwords     151
"Honeypot" Passwords     151
Password Filtering     151
Aging Passwords     152
Pronounceable Passwords     152
Limited Login Attempts     152
Artificial Delays     152
Last Login     153
Image Authentication     153
One-Time Passwords     154
Cross-Domain Security in Web Applications     155
Interaction Between Web Pages from Different Domains     156
HTML, JavaScript, and the Same-Origin Policy     156
Possible Interactions of Documents from Different Origins     157
HTTP Request Authentication     159
Lifetime of Cached Cookies and HTTP Authentication Credentials     160
Attack Patterns     161
Cross-Site Request Forgery (XSRF)      162
Cross-Site Script Inclusion (XSSI)     164
Cross-Site Scripting (XSS)     165
Preventing XSRF     169
Inspecting Referer Headers     170
Validation via User-Provided Secret     170
Validation via Action Token     171
Security Analysis of the Action Token Scheme     173
Preventing XSSI     176
Authentication via Action Token     176
Restriction to POST Requests     177
Preventing Resource Access for Cost Reasons     177
Preventing XSS     178
General Considerations     179
Simple Text     180
Tag Attributes (e.g., Form Field Value Attributes)     181
URL Attributes (href and src)     183
Style Attributes     185
Within Style Tags     186
In JavaScript Context     186
JavaScript-Valued Attributes     189
Redirects, Cookies, and Header Injection     190
Filters for "Safe" Subsets of HTML     191
Unspecified Charsets, Browser-Side Charset Guessing, and UTF-7 XSS Attacks     192
Non-HTML Documents and Internet Explorer Content-Type Sniffing     193
Mitigating the Impact of XSS Attacks     194
Exercises for Part 2     197
Introduction to Cryptography
Symmetric Key Cryptography     203
Introduction to Encryption     204
Substitution Ciphers     204
Notation and Terminology     205
Block Ciphers     205
Security by Obscurity: Recap     208
Encrypting More Data     208
AES Code Example     210
Stream Ciphers     217
One-Time Pad     217
RC4     217
Steganography     219
What Is Steganography?     219
Steganography vs. Cryptography     220
Asymmetric Key Cryptography     221
Why Asymmetric Key Cryptography?     221
RSA     223
Elliptic Curve Cryptography (ECC)     223
Symmetric vs. Asymmetric Key Cryptography     224
Certificate Authorities     224
Identity-Based Encryption (IBE)     225
Authentication with Encryption     225
Key Management and Exchange     227
Types of Keys     227
Identity Keys     227
Conversation or Session Keys     227
Integrity Keys     228
Key Generation     228
Random Number Generation     229
The rand() function     230
Random Device Files     230
Random APIs     231
Key (Secret) Storage     231
Keys in Source Code     231
Storing the Key in a File on Disk     233
"Hard to Reach" Places     233
Storing Secrets in External Devices     233
Key Agreement and Exchange     235
Using Asymmetric Keys     236
Diffie-Hellman (DH)     236
MACs and Signatures     239
Secure Hash Functions     239
Message Authentication Codes (MACs)     240
CBC MACs     240
HMAC     241
Signatures     242
Certificates and Certificate Authorities (CAs)     243
Signing and Verifying     246
Registration Authorities (RAs)     246
Web of Trust     247
Attacks Against Hash Functions     247
SSL     247
Server-Authenticated-Only     248
Mutual Authentication     249
Exercises for Part 3     251
Defense-in-Depth: The FLI Model     255
Protecting Against Failure     256
Protecting Against Lies     257
Protecting Against Infiltration     257
Other Techniques     258
Using an FLI-like Model     258
References     258
Source Code Listings     261
References     267
Index     277

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >