The Tangled Web

Tangled Web

A Guide to Securing Modern Web Applications
by Michal Zalewski
November 2011, 320 pp.
ISBN-13: 
9781593273880

Download Chapter 3: "Hypertext Transfer Protocol

Modern web applications are built on a tangle of technologies that have been developed over time and then haphazardly pieced together. Every piece of the web application stack, from HTTP requests to browser-side scripts, comes with important yet subtle security consequences. To keep users safe, it is essential for developers to confidently navigate this landscape.

In The Tangled Web, Michal Zalewski, one of the world’s top browser security experts, offers a compelling narrative that explains exactly how browsers work and why they’re fundamentally insecure. Rather than dispense simplistic advice on vulnerabilities, Zalewski examines the entire browser security model, revealing weak points and providing crucial information for shoring up web application security. You’ll learn how to:

  • Perform common but surprisingly complex tasks such as URL parsing and HTML sanitization
  • Use modern security features like Strict Transport Security, Content Security Policy, and Cross-Origin Resource Sharing
  • Leverage many variants of the same-origin policy to safely compartmentalize complex web applications and protect user credentials in case of XSS bugs
  • Build mashups and embed gadgets without getting stung by the tricky frame navigation policy
  • Embed or host user-supplied content without running into the trap of content sniffing

For quick reference, “Security Engineering Cheat Sheets” at the end of each chapter offer ready solutions to problems you’re most likely to encounter. With coverage extending as far as planned HTML5 features, The Tangled Web will help you create secure web applications that stand the test of time.

Author Bio 

Michal Zalewski is an internationally recognized information security expert with a long track record of delivering cutting-edge research. He is credited with discovering hundreds of notable security vulnerabilities and frequently appears on lists of the most influential security experts. He is the author of Silence on the Wire (No Starch Press), Google's "Browser Security Handbook," and numerous important research papers.

Table of contents 

Preface and Acknowledgments

1. Security in the World of Web Applications

Part I: Anatomy of the Web
2. It Starts with A URL
3. Hypertext Transfer Protocol
4. Hypertext Markup Language
5. Cascading Style Sheets
6. Browser-Side Scripts
7. Non-HTML Document Types
8. Content Rendering with Browser Plug-Ins

Part II: Browser Security Features
9. Content Isolation Logic
10. Origin Inheritance
11. Life Outside Same-Origin Rules
12. Other Security Boundaries
13. Content Recognition Mechanisms
14. Dealing with Rogue Scripts
15. Extrinsic Site Privileges

Part III: A Glimpse of Things to Come
16. New and Upcoming Security Features
17. Other Browser Mechanisms of Note
18. Common Web Vulnerabilities

Epilogue
Notes
Index

View the detailed Table of Contents (PDF)
View the Index (PDF)

Reviews 

"Thorough and comprehensive coverage from one of the foremost experts in browser security."
Tavis Ormandy, Google Inc.

"For anyone involved in programming web pages, The Tangled Web should be considered required reading."
Ben Rothke, Slashdot (Read More)

"I recommend reading this book if you want to know a lot, and I mean a lot, about how screwed up Web browsers, protocols, and related technologies truly are."
Richard Bejtlich, TaoSecurity (Read More)

"A must-read for anyone who values their security and privacy online."
Collin Jackson, Researcher at the Carnegie Mellon Web Security Group

"Perhaps the most thorough and insightful treatise on the state of security for web-driven technologies to date. A must have!"
Mark Dowd, Azimuth Security, Author of The Art of Software Security Assessment

"The best book out there on web security right now."
Dave Aitel, Dailydave (Read More)

"Does a fine job of dissecting the anatomy of the Web and offering an extensive look at browser security features and what to look for in the future. The issues covered are truly current and faced by all security professionals."
Elhadji Sarr, Security Management Magazine (Read More)

"A must read for any web developer, anyone that wonders why the Blue Coat proxy system chucks out such strange packets, and anyone that really wants to understand how the web works from a security perspective."
Stephen Northcutt, SANS.edu (Read More)

"The Tangled Web captures a lot of nuances between CSS and JavaScript implementations. Each chapter concludes with a great cheat sheet. Overall, I enjoyed the book. If you test or build web apps then you will too."
Chris Rohlf, Matasano Security, EM_386 (Read More)

"Most security books either focus on underlying theory or on a single application or service, covered in detail. What's interesting about The Tangled Web is that it does some of both. Unlike a lot of people, Zalewski...knows his internet history, and he uses the right amount of it to put today's problems in context and explain their genesis."
Wendy Grossman, ZDNet UK (Read More)

"I love this book... there's no other way to say it. Every once in a while you get a book that's well written, contains good content, and sparks those little ideas in the back of your brain."
Chris John Riley, Caтcн22 (in)secuяity (Read More)

"Of particular value is the discussion of how features interact, sometimes in unexpected ways, to make what seems an innocuous or even beneficial change become a disaster waiting to happen. The practical guidance on how to avoid such pitfalls and do a better job with security using the currently available technology is both timely and to-the-point."
Richard Austin, IEEE Cipher (Read More)

"The book offers a fascinating insight into technologies we all use and appreciate, and is a definite must-read (and re-read) for web developers and everyone else who deals with web application security."
Help Net Security (Read More)

"The sort of book that should be required reading for every web developer."
Packet Storm (Read More)

"A fascinating, enlightening and enjoyable read."
Global Nerdy (Read More)

"While I thought that I knew all about a lot of the areas that this book covers, in just about every section the author went beyond what I knew to discuss aspects of the technology that I had never considered."
Stephen Chapman, Felgall.com (Read More)

"A fantastic book on the current state of affairs for web security, and one which I cannot help but classify as 5 stars."
Defensive Depth Consulting (Read More)

"If you're a developer, tester, or infrastructure implementer, you would be wise to read and then re-read The Tangled Web."
Michael Larsen, TESTHEAD (Read More)

"Perhaps one the most valuable parts of The Tangled Web is how Zalewski adds a handy "Security Engineering Cheat Sheet" to the end of each chapter. Having these quick tips at ones fingertips is a remarkable asset and great addition to the book."
Cory Gackenheimer, cgack.com (Read More)

"Provides an invaluable reference for anyone working with, testing or deploying web applications."
Bites of Apple (Read More)

"The amount of knowledge conveyed in the book is breath-taking."
404 Tech Support (Read More)

"Michal Zalewski has a colorful writing style. His book is serious and loaded with technical detail, but that doesn't stop him from turning a nice phrase here and there."
John D. Cook, The Endeavor (Read More)

"Fun to read, educational and (if you are actually creating websites) very useful."
Tony Lawrence, A.P. Lawrence (Read More)

"This is a must read for anyone who wants to engage web client security on a professional level."
Gynvael "GynDream" Coldwind, gynvael.coldwind.pl/ (Read More)

"Whether you work in IT security or are a web application developer, this definitely is a book you don't want to miss."
Michael Kohl, Citizen428.blog (Read More)

"Zalewski's book puts a bright, uncomfortable spotlight on the fundamental insecurities of Web browsers, but it also shows you how to improve the security of Web applications."
Books, Books & More (New) Books (Read More)

"A solid book, full of interesting and useful information. For web developers and security experts it should be a must read book."
Jorge Tavares Weblog (Read More)

"If you're a web developer and want to get a better understanding of security I think this is a very good book and worth checking out."
Patrick Gillespie, patorjk.com (Read More)

"A classic – arguably canon – as far as security training books go, and especially when it comes to web application security."
—Britt Kemp, Bishop Fox Labs

Updates 

View the latest errata.