Most organizations have a firewall, anti-virus software,
and intrusion detection systems, all intended to keep
attackers out. So why is it that computer security is a
bigger problem than ever before? The answer is simple--bad
software lies at the heart of all computer security
problems. Point solutions based on watching the network
simply treat symptoms of the problem, and usually in a
reactive way. If you are serious about computer security,
you need to read this book.
This book includes many essential lessons intended for
both security professionals, who have come to realize that
software is the problem, and software developers, who
intend to make their code behave.
Welcome to Building Secure Software, the book
that cuts to the heart of computer security to help you get
security right the first time. Make your software behave
the way you want it to, and do security the right way.
Building Secure Software provides the expertise
and techniques to help you ensure the security of essential
software. By considering threats and vulnerabilities early
in the development cycle, security that actually works can
be built into your system. You'll learn how to determine an
acceptable level of risk, develop security tests, and plug
security holes before software is even shipped. Written for
anyone involved in software development and use, from
managers to coders, this book is your first step to
building more secure software.
Inside you'll find the ten guiding principles for
software security, as well as detailed coverage of:
- Software risk management for security
- Selecting technologies to make your code more
secure
- Security implications of open source and proprietary
software
- How to audit software
- The dreaded buffer overflow
- Access control and password authentication
- Random number generation
- Applying cryptography
- Trust management and input
- Client-Side security
- Dealing with firewalls
Only by building secure software can you defend yourself
against security breaches and gain the confidence that
comes with knowing you won't have to play the "penetrate
and patch" game anymore. Wouldn't you rather design things
properly and thoroughly test your system than have your
problems announced to the world on the front page? Let
these expert authors help save you time, money,
credibility, and your customer's trust.
Contents
-
- Preface
- Organization
- Code Examples
- Acknowledgements
- Contacting Us
- 1: Introduction to Software Security
- It's all about the Software
- Dealing with Widespread Security Failures
- Technical Trends Affecting Software Security
- The 'ilities
- What is Security?
- Isn't that just reliability?
- Penetrate and Patch is Bad
- On Art and Engineering
- Security Goals
- Prevention
- Traceability and Auditing
- Monitoring
- Privacy and Confidentiality
- Multi-level security
- Anonymity
- Authentication
- Integrity
- Know Your Enemy: Common software security pitfalls
- Threats Against Software
- Software Project Goals
- Software Security means Good Software
- SIDEBAR
- Hackers, Crackers, and Attackers
- Who is the bad guy?
- 2: Managing Software Security Risk
- An Overview of Software Risk Management for
Security
- The Role of Security Personne
- Software Security Personnel in the Lifecycle
- Deriving Requirements
- Risk Assessment
- Design for Security
- Implementation
- Security Testing
- A Dose of Reality
- Getting People to Think about Security
- Software Risk Management in Practice
- When Development Goes Astray
- When Security Analysis Goes Astray
- Black box testing
- Red teaming
- The Common Criteria
- Software Risk Management for Security
- 3: Selecting Technologies
- Choosing a Language
- Choosing a Distributed Object Platform
- CORBA
- DCOM
- EJB and RMI
- Choosing an Operating System
- Authentication Technologies
- Host-based authentication
- Physical Tokens
- Biometric Authentication
- Cryptographic authentication
- Defense in depth and authentication
- Conclusion
- 4: On Open Source and Closed Source
- Security by Obscurity
- Reverse Engineering
- Code Obfuscation
- Security for Shrink-Wrapped Software
- Security by obscurity is no panacea
- The Flip-Side: Open Source Software
- Is the many eyeballs phenomenon real?
- Why vulnerability detection is hard
- Other Worries
- On publishing crypto algorithms
- Two more open source fallacies
- The Microsoft fallacy
- The Java fallacy
- An example: GNU Mailman security
- More evidence: Trojan horses
- To open source or not to open source
- Another security lesson from buffer overflows
- Beating the Drum
- Conclusion
- 5: Guiding Principles for Software Security
- Principle 1: Secure the weakest link
- Principle 2: Practice defense in depth
- Principle 3: Fail securely
- Principle 4: Follow the principle of least
privilege
- Principle 5: Compartmentalize
- Principle 6: Keep it simple
- Principle 7: Promote privacy
- Principle 8: Remember that hiding secrets is hard
- Principle 9: Be reluctant to trust
- Principle 10: Use your community resources
- Conclusion
- 6: Auditing Software
- Architectural Security Analysis
- Attack Trees
- Reporting analysis findings
- Implementation Security Analysis
- Auditing source code
- ITS4
- Using ITS4 in an analysis
- Conclusion
- 7: Buffer Overflows
- What is a Buffer Overflow?
- Why Are Buffer Overflows A Security Problem?
- Defending against buffer overflow
- Major Gotchas
- Internal buffer overflows
- More Input Overflows
- Other Risks
- Tools That Can Help
- Smashing stacks
- Heap Overflows
- Memory address
- Variable
- Contents
- Stack Overflows
- Decoding the stack
- To infinity.. and beyond!
- Attack code
- A Unix Exploit
- What about Windows?
- In Conclusion
- SIDEBAR: Buffer Overflow, Deja vu All Over Again
- 8: Access Control
- The Unix Access Control Model
- How Unix Permissions Work
- Modifying file attributes
- Modifying Ownership
- The umask
- The programmatic interface
- Setuid Programming
- Access Control in Windows NT
- Compartmentalization
- Fine-Grained Privileges
- 9: Race Conditions
- What is a Race Condition?
- Time of Check, Time of Use
- Broken passwd
- Avoiding TOCTOU Problems
- Secure File Access
- Temporary files
- File Locking
- Other Race Conditions
- Java 2 policy manipulation
- Conclusion
- 10: Randomness and Determinism
- Pseudo-random number generators
- Examples of PRNGs
- The Blum-Blum-Shub PRNG
- The Yarrow-AES PRNG
- Attacks against PRNGs
- How to cheat in online gambling
- Statistical tests on PRNGs
- Entropy Gathering and Estimation
- Hardware solutions
- Software solutions
- Poor entropy collection: How to read "secret" Netscape
messages
- Handling Entropy
- Statistical Tests Revisited
- Practical sources of randomness
- Yarrow
- Random numbers for Windows
- Random numbers for Linux
- Random numbers in Java
- Conclusion
- 11: Applying Cryptography
- General recommendations
- Developers are not Cryptographers
- Data Integrity
- Export Laws
- Common Crypto Libraries
- Cryptlib
- OpenSSL
- Crypto++
- BSAFE
- Cryptix
- Programming with Cryptography
- Encryption
- Hashing
- Public Key Encryption
- Threading
- Cookie Encryption
- More uses for cryptographic hashes
- SSL and TLS
- Stunnel
- One-time pads
- The Catch
- Conclusion
- 12: Trust Management and Input Validation
- A few words on trust
- Examples of Misplaced Trust
- Trust Is Transitive
- Protection from hostile callers
- Invoking other programs safely
- Problems from the Web
- Client-side security
- erl Problems
- Format String Attacks
- Automatically Detecting Input Problems
- It Pays to be Paranoid
- 13: Password Authentication
- Password Storage
- Adding users to a password database
- Password Authentication
- Password Selection
- More advice
- Throwing dice
- Passphrases
- Application-selected passwords
- One-Time Passwords
- Conclusion
- 14: Database Security
- The Basics
- Access Control
- Using Views for Access Control
- Field Protection
- Security against statistical attacks
- Conclusion
- 15: Client-side Security
- Copy Protection Schemes
- License files
- Thwarting the Casual Pirate
- Other License Features
- Other Copy Protection Schemes
- Authenticating Untrusted Clients
- Tamperproofing
- Anti-Debugger Measures
- Checksums
- Responding to Misuse
- Decoys
- Code Obfuscation
- Basic Obfuscation Techniques
- Encrypting Program Parts
- Conclusion
- 16: Through the Firewall
- Basic Strategies
- Client Proxies
- Server Proxies
- SOCKS
- Peer-to-Peer
- Conclusions
- Appendix A: Cryptography Basics
- The Ultimate Goals of Cryptography
- Attacks on Cryptography
- Types of Cryptography
- Symmetric Cryptography
- Types of Symmetric Algorithms
- Security of Symmetric Algorithms
- Public Key Cryptography
- Attacks Against Public Key Cryptography
- Cryptographic Hashing Algorithms
- Other attacks on cryptographic hashes
- What's a good hash algorithm to use?
- Digital Signatures
- Conclusions
- References