Home > Store

Ajax Security

Register your product to gain access to bonus material or receive a coupon.

Ajax Security

Book

  • Sorry, this book is no longer in print.
Not for Sale

Description

  • Copyright 2008
  • Dimensions: 7" x 9-1/4"
  • Pages: 504
  • Edition: 1st
  • Book
  • ISBN-10: 0-321-49193-9
  • ISBN-13: 978-0-321-49193-0

The Hands-On, Practical Guide to Preventing Ajax-Related Security Vulnerabilities

More and more Web sites are being rewritten as Ajax applications; even traditional desktop software is rapidly moving to the Web via Ajax. But, all too often, this transition is being made with reckless disregard for security. If Ajax applications aren’t designed and coded properly, they can be susceptible to far more dangerous security vulnerabilities than conventional Web or desktop software. Ajax developers desperately need guidance on securing their applications: knowledge that’s been virtually impossible to find, until now.

            Ajax Security systematically debunks today’s most dangerous myths about Ajax security, illustrating key points with detailed case studies of actual exploited Ajax vulnerabilities, ranging from MySpace’s Samy worm to MacWorld’s conference code validator. Even more important, it delivers specific, up-to-the-minute recommendations for securing Ajax applications in each major Web programming language and environment, including .NET, Java, PHP, and even Ruby on Rails. You’ll learn how to:

·        Mitigate unique risks associated with Ajax, including overly granular Web services, application control flow tampering, and manipulation of program logic

·        Write new Ajax code more safely—and identify and fix flaws in existing code

·        Prevent emerging Ajax-specific attacks, including JavaScript hijacking and persistent storage theft

·        Avoid attacks based on XSS and SQL Injection—including a dangerous SQL Injection variant that can extract an entire backend database with just two requests

·        Leverage security built into Ajax frameworks like Prototype, Dojo, and ASP.NET AJAX Extensions—and recognize what you still must implement on your own

·        Create more secure “mashup” applications

Ajax Security will be an indispensable resource for developers coding or maintaining Ajax applications; architects and development managers planning or designing new Ajax software, and all software security professionals, from QA specialists to penetration testers.

Sample Content

Online Sample Chapter

Transparency in Ajax Applications

Downloadable Sample Chapter

Download the chapter

Table of Contents

    Preface xvii

    Preface (The Real One) xvix

Chapter 1 Introduction to Ajax Security 1

    An Ajax Primer 2

        What Is Ajax? 2

        Asynchronous 3

        JavaScript 6

        XML 11

        Dynamic HTML (DHTML) 11

    The Ajax Architecture Shift 11

        Thick-Client Architecture 12

        Thin-Client Architecture 13

        Ajax: The Goldilocks of Architecture 15

        A Security Perspective: Thick-Client Applications 16

        A Security Perspective: Thin-Client Applications 17

        A Security Perspective: Ajax Applications 18

    A Perfect Storm of Vulnerabilities 19

        Increased Complexity, Transparency, and Size 19

        Sociological Issues 22

        Ajax Applications: Attractive and Strategic Targets 23

    Conclusions 24

Chapter 2 The Heist 25

    Eve 25

        Hacking HighTechVacations.net 26

        Hacking the Coupon System 26

        Attacking Client-Side Data Binding 32

        Attacking the Ajax API 36

    A Theft in the Night 42

Chapter 3 Web Attacks 45

    The Basic Attack Categories 45

        Resource Enumeration 46

        Parameter Manipulation 50

    Other Attacks 75

        Cross-Site Request Forgery (CSRF) 75

        Phishing 76

        Denial-of-Service (DoS) 77

    Protecting Web Applications from Resource Enumeration and Parameter

        Manipulation 77

        Secure Sockets Layer 78

    Conclusions 78

Chapter 4  Ajax Attack Surface 81

    Understanding the Attack Surface 81

    Traditional Web Application Attack Surface 83

        Form Inputs 83

        Cookies 84

        Headers 85

        Hidden Form Inputs 86

        Query Parameters 86

        Uploaded Files 89

    Traditional Web Application Attacks: A Report Card 90

    Web Service Attack Surface 92

        Web Service Methods 92

        Web Service Definitions 94

    Ajax Application Attack Surface 94

        The Origin of the Ajax Application Attack Surface 96

        Best of Both Worlds–for the Hacker 98

    Proper Input Validation 98

        The Problem with Blacklisting and Other Specific Fixes 99

        Treating the Symptoms Instead of the Disease 102

        Whitelist Input Validation 105

        Regular Expressions 109

        Additional Thoughts on Input Validation 109

    Validating Rich User Input 111

        Validating Markup Languages 111

        Validating Binary Files 113

        Validating JavaScript Source Code 114

        Validating Serialized Data 120

    The Myth of User-Supplied Content 122

    Conclusion 123

Chapter 5 Ajax Code Complexity 125

    Multiple Languages and Architectures 125

        Array Indexing 126

        String Operations 128

        Code Comments 129

        Someone Else’s Problem 130

    JavaScript Quirks 132

        Interpreted, Not Compiled 132

        Weakly Typed 133

    Asynchronicity 135

        Race Conditions 135

        Deadlocks and the Dining Philosophers Problem 139

        Client-Side Synchronization 144

    Be Careful Whose Advice You Take 144

    Conclusions 145

Chapter 6 Transparency in Ajax Applications 147

    Black Boxes Versus White Boxes 147

        Example: MyLocalWeatherForecast.com 150

        Example: MyLocalWeatherForecast.com “Ajaxified” 152

        Comparison Conclusions 156

    The Web Application as an API 156

        Data Types and Method Signatures 158

    Specific Security Mistakes 158

        Improper Authorization 159

        Overly Granular Server API 161

        Session State Stored in JavaScript 164

        Sensitive Data Revealed to Users 165

        Comments and Documentation Included in Client-Side Code 166

        Data Transformation Performed on the Client 167

    Security through Obscurity 172

        Obfuscation 173

    Conclusions 174

Chapter 7 Hijacking Ajax Applications 175

    Hijacking Ajax Frameworks 176

        Accidental Function Clobbering 176

        Function Clobbering for Fun and Profit 178

    Hijacking On-Demand Ajax 184

    Hijacking JSON APIs 190

        Hijacking Object Literals 195

        Root of JSON Hijacking 195

        Defending Against JSON Hijacking 196

    Conclusions 199

Chapter 8 Attacking Client-Side Storage 201

    Overview of Client-Side Storage Systems 201

        General Client-Side Storage Security 202

    HTTP Cookies 204

        Cookie Access Control Rules 206

        Storage Capacity of HTTP Cookies 211

        Lifetime of Cookies 215

        Additional Cookie Storage Security Notes 216

        Cookie Storage Summary 216

    Flash Local Shared Objects 218

        Flash Local Shared Objects Summary 225

    DOM Storage 226

        Session Storage 227

        Global Storage 229

        The Devilish Details of DOM Storage 231

        DOM Storage Security 233

        DOM Storage Summary 234

    Internet Explorer userData 235

        Security Summary 240

    General Client-Side Storage Attacks and Defenses 240

        Cross-Domain Attacks 241

        Cross-Directory Attacks 242

        Cross-Port Attacks 243

    Conclusions 243

Chapter 9 Offline Ajax Applications 245

    Offline Ajax Applications 245

    Google Gears 247

        Native Security Features and Shortcomings of Google Gears 248

        Exploiting WorkerPool 251

        LocalServer Data Disclosure and Poisoning 253

        Directly Accessing the Google Gears Database 257

        SQL Injection and Google Gears 258

        How Dangerous Is Client-Side SQL Injection? 262

    Dojo.Offline 264

        Keeping the Key Safe 265

        Keeping the Data Safe 266

        Good Passwords Make for Good Keys 267

    Client-Side Input Validation Becomes Relevant 268

    Other Approaches to Offline Applications 270

    Conclusions 270

Chapter 10 Request Origin Issues 273

    Robots, Spiders, Browsers, and Other Creepy Crawlers 273

        “Hello! My Name Is Firefox. I Enjoy Chunked Encoding, PDFs, and

        Long Walks on the Beach.” 275

    Request Origin Uncertainty and JavaScript 276

        Ajax Requests from the Web Server’s Point of View 276

        Yourself, or Someone Like You 280

        Sending HTTP Requests with JavaScript 282

        JavaScript HTTP Attacks in a Pre-Ajax World 284

        Hunting Content with XMLHttpRequest 286

        Combination XSS/XHR Attacks in Action 290

    Defenses 292

    Conclusions 294

Chapter 11 Web Mashups and Aggregators 295

    Machine-Consumable Data on the Internet 296

        Early 90’s: Dawn of the Human Web 296

        Mid 90s: The Birth of the Machine Web 297

        2000s: The Machine Web Matures 298

        Publicly Available Web Services 299

    Mashups: Frankenstein on the Web 301

        ChicagoCrime.org 302

        HousingMaps.com 303

        Other Mashups 304

    Constructing Mashups 304

        Mashups and Ajax 306

    Bridges, Proxies, and Gateways–Oh My! 308

        Ajax Proxy Alternatives 309

    Attacking Ajax Proxies 310

        Et Tu, HousingMaps.com? 312

    Input Validation in Mashups 314

    Aggregate Sites 317

    Degraded Security and Trust 324

    Conclusions 327

Chapter 12 Attacking the Presentation Layer 329

    A Pinch of Presentation Makes the Content Go Down 329

    Attacking the Presentation Layer 333

    Data Mining Cascading Style Sheets 334

    Look and Feel Hacks 337

        Advanced Look and Feel Hacks 341

    Embedded Program Logic 345

    Cascading Style Sheets Vectors 347

        Modifying the Browser Cache 348

    Preventing Presentation Layer Attacks 352

    Conclusion 353

Chapter 13 JavaScript Worms 355

    Overview of JavaScript Worms 355

        Traditional Computer Viruses 356

    JavaScript Worms 359

        JavaScript Worm Construction 361

        JavaScript Limitations 363

        Propagating JavaScript Worms 364

        JavaScript Worm Payloads 364

        Putting It All Together 372

    Case Study: Samy Worm 373

        How It Worked 374

        The Virus’ Payload 377

        Conclusions About the Samy Worm 379

    Case Study: Yamanner Worm (JS/Yamanner-A) 380

        How It Worked 380

        The Virus’ Payload 383

        Conclusions About the Yamanner Worm 384

    Lessons Learned from Real JavaScript Worms 387

    Conclusions 389

Chapter 14 Testing Ajax Applications 391

    Black Magic 391

    Not Everyone Uses a Web Browser to Browse the Web 396

        Catch-22 398

    Security Testing Tools–or Why Real Life Is Not Like Hollywood 399

        Site Cataloging 400

        Vulnerability Detection 401

        Analysis Tool: Sprajax 403

        Analysis Tool: Paros Proxy 406

        Analysis Tool: LAPSE (Lightweight Analysis for Program Security in Eclipse) 408

        Analysis Tool:WebInspect™ 409

    Additional Thoughts on Security Testing 411

Chapter 15 Analysis of Ajax Frameworks 413

    ASP.NET 413

        ASP.NET AJAX (formerly Atlas) 414

        ScriptService 417

        Security Showdown: UpdatePanel Versus ScriptService 419

        ASP.NET AJAX and WSDL 420

        ValidateRequest 424

        ViewStateUserKey 425

        ASP.NET Configuration and Debugging 426

    PHP 427

        Sajax 427

        Sajax and Cross-Site Request Forgery 430

    Java EE 431

        Direct Web Remoting (DWR) 432

    JavaScript Frameworks 434

        A Warning About Client-Side Code 435

        Prototype 435

    Conclusions 437

Appendix A Samy Source Code 439

Appendix B Source Code for Yamanner Worm 447

Index 453

Preface

Download the preface

Index

Download the index

Updates

Submit Errata

More Information

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020