Web Application Defender's CookbookThe Web ApplicationDefender's cookbookThe Web ApplicationDefender's cookbookBattling Hackers andProtecting∪sersRyan barnettWILEYWiley publishing, IncThe Web Application Defender's Cookbook: Battling Hackers and Protecting UsersPublished byJohn wiley &e Sons, Inc10475 Crosspoint boulevardIndianapolis, In 46256Www.wlley.comCopyright@ 2013 by Ryan BarnettPublished simultaneously in CanadaISBN:978-1-118-36218-1ISBN:978-1-118-56871-2(ebkISBN:978-1-118-41705-8(ebk)ISBN:978-1-118-56865-1(ebk)Manufactured in the united states of america10987654321No part of this publication may be reproduced, stored in a retrieval system or transmitted in any formor by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except aspermitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the priorwritten permission of the Publisher, or authorization through payment of the appropriate per-copyfee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978)750-8400, fax(978)646-8600 Requests to the Publisher for permission should be addressed to the PermissionsDepartment, John Wiley Sons, Inc, 111 River Street, Hoboken, NJ 07030, (201)748-6011, fax(201)748-6008,oronlineathttp://www.wileycom/go/permission:Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations orwarranties with respect to the accuracy or completeness of the contents of this work and specificallydisclaim all warranties, including without limitation warranties of fitness for a particular purpose. Nowarranty may be created or extended by sales or promotional materials. The advice and strategies con-tained herein may not be suitable for every situation. This work is sold with the understanding that thepublisher is not engaged in rendering legal, accounting, or other professional services. If professionalassistance is required, the services of a competent professional person should be sought. Neither thepublisher nor the author shall be liable for damages arising herefrom. The fact that an organization orWeb site is referred to in this work as a citation and/ or a potential source of further information doesnot mean that the author or the publisher endorses the information the organization or website mayprovide or recommendations it may make. Further, readers should be aware that Internet websitelisted in this work may have changed or disappeared between when this work was written and when itis readFor general information on our other products and services please contact our Customer CareDepartment within the United States at( 877)762-2974, outside the United States at(317)572-3993 or fax(317)572-4002Wiley also publishes its books in a variety of electronic formats and by print-on-demand not all content that is available in standard print versions of this book may appear or be packaged in all bookformats. If you have purchased a version of this book that did not include media that is referenced byoraccompaniesastandardprintversionyoumayrequestthismediabyvisitinghttp://booksupportwiley.com.FormoreinformationaboutWileyproductsvisitusatwww.wiley.comLibrary of Congress Control Number: 2012949513Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley &e sons,Inc and/or its affiliates in the United States and other countries and may not be used without writtenpermission. All other trademarks are the property of their respective owners. John Wiley &e Sons, Inc isnot associated with any product or vendor mentioned in this bookThis book is dedicated to my incredible daughter Isabella. You are so full of imaginationkindness, and humor that i have a constant smile on my face. You are my Supergirl-flyingtae-kwon-do-kicking fairy princess I thank God every day for bringing you into my lifeand for allowing me the joy and privilege of being your father.I love you Izzy, and I am so proud of youCreditsExecutive editorVice President and Executive GroupCarol longPublisherRichard wadleyProject EditorEd connorVice president and executive publisherNeil eddeTechnical editorMichael greggAssociate publisherm mintelProduction editorDaniel scribnerProject Coordinator CoverKatie CrockCopy EditorGayle johnCompositorCraig johnsonEditorial ManagerMary Beth WakefieldHappenstance Type-O-RamaProofreaderFreelancer Editorial ManagerNicole hirschmanRosemarie grahamIndexerAssociate Director of MarketingRon straussDavid mayhewCover ImageMarketing ManagerO Mak Art / iStockPhotoAshley zurcherCover DesignerBusiness ManagerRyan SneedAmy KniesProduction ManagerTim Tate