• Tidak ada hasil yang ditemukan

Marco.Tabini.and.Associates.PHP.Architects.Guide.to.PHP.Security.Sep.2005

N/A
N/A
Protected

Academic year: 2017

Membagikan "Marco.Tabini.and.Associates.PHP.Architects.Guide.to.PHP.Security.Sep.2005"

Copied!
201
0
0

Teks penuh

(1)

.424

7.50 x 9.25

7.50 x 9.25

php|architect’s

Guide to

PHP Security

A Step-by-step Guide to Writing

Secure and Reliable PHP Applications

Ilia Alshanetsky

php|architect’s

Guide to

PHP Security

NanoBooks are excellent, in-depth resources created by the publishers of

php|architect (http://www.phparch.com), the world’s premier magazine dedicated to PHP professionals.

NanoBooks focus on delivering high-quality content with in-depth analysis and expertise, centered around a single, well-defined topic and without any of the fluff of larger, more expensive books.

Shelve under PHP/Web Development/Internet Programming

From the publishers of

php|architect’s Guide to PHP Security

Ilia Alshanetsky

US

$32.99

Canada

$47.99

UK (net)

£18.99

With the number of security flaws and exploits discovered and released

every day constantly on the rise, knowing how to write secure and reliable

applications is become more and more important every day.

Written by Ilia Alshanetsky, one of the foremost experts on PHP security in

the world,

php|architect’s Guide to PHP Security

focuses on providing you

with all the tools and knowledge you need to both secure your existing

applications and writing new systems with security in mind.

This book gives you a step-by-step guide to each security-related topic,

providing you with real-world examples of proper coding practices and their

implementation in PHP in an accurate, concise and complete way.

¸ Provides techniques applicable to any version of PHP,

including 4.x and 5.x

¸ Includes a step-by-step guide to securing your applications

¸ Includes a comprehensive coverage of security design

¸ Teaches you how to defend yourself from hackers

¸ Shows you how to distract hackers with a “tar pit” to help you

fend off potential attacks

(2)

PHP

|

ARCHITECT

S

G

UIDE

TO

PHP S

ECURITY

(3)

php|architect’s฀Guide฀to฀Security

Contents Copyright © 2005 Ilia Alshanetsky – All Rights Reserved

Book and cover layout, design and text Copyright © 2005 Marco Tabini & Associates, Inc. – All Rights Reserved First Edition: First Edition

ISBN 0-9738621-0-6

Produced in Canada Printed in the United States

No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, with-out the prior written permission of the publisher, except in the case of brief quotations embedded in critical reviews or articles.

Disclaimer

Although every effort has been made in the preparation of this book to ensure the accuracy of the information contained therein, this book is provided “as-is” and the publisher, the author(s), their distributors and retailers, as well as all af-filiated, related or subsidiary parties take no responsibility for any inaccuracy and any and all damages caused, either directly or indirectly, by the use of such information.

We have endeavoured to properly provide trademark information on all companies and products mentioned in this book by the appropriate use of capitals. However, we cannot guarantee the accuracy of such information.

Marco Tabini & Associates, The MTA logo, php|architect, the php|architect logo, NanoBook and NanoBook logo are trade-marks or registered tradetrade-marks of Marco Tabini & Associates Inc.

Bulk฀Copies

Marco Tabini & Associates, Inc. offers trade discounts on purchases of ten or more copies of this book. For more informa-tion, please contact our sales offices at the address or numbers below.

Credits

Written by Ilia Alshanetsky Published by

Marco Tabini & Associates, Inc. 28 Bombay Ave.

Toronto, ON M3H 1B7 Canada

(416) 630-6202

(877) 630-6202 toll free within North America info@phparch.com / www.phparch.com Marco Tabini, Publisher

(4)

About฀the฀Author

Ilia Alshanetsky is the principal of Advanced Internet Designs Inc., a company that specializes in security auditing, per-formance analysis and application development.

He is the author of FUDforum (http://fudforum.org), a highly popular, Open Source bulletin board focused on

provid-ing the maximum functionality at the highest level of security and performance.

Ilia is also a Core PHP Developer who authored or co-authored a series of extensions, including SHMOP, PDO, SQLite, GD and ncurses. An active member of PHP’s Quality Assurance Team, he is responsible for hundreds of bug fixes, as well as a sizable number of performance tweaks and features.

(5)
(6)

To฀my฀parents,

(7)
(8)

Contents

Foreword

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

13

Introduction฀

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

17

1

฀฀฀Input฀Validation฀

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

21

The฀Trouble฀with฀Input฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀22

An฀Alternative฀to฀Register฀Globals:฀Superglobals฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀25

The฀Constant฀Solution฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀25

The฀$_REQUEST฀Trojan฀Horse฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀27

Validating฀Input฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀28

Validating฀Numeric฀Data฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀28

Locale฀Troubles฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀29

String฀Validation฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀30

Content฀Size฀Validation฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀34

(9)

8 Contents

Being฀Careful฀with฀File฀Uploads฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀37

Configuration฀Settings฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀37

File฀Input฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀38

File฀Content฀Validation฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀39

Accessing฀Uploaded฀Data฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀41

File฀Size฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀42

The฀Dangers฀of฀Magic฀Quotes฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀43

Magic฀Quotes฀Normalization฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀44

Magic฀Quotes฀&฀Files฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀46

Validating฀Serialized฀Data฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀47

External฀Resource฀Validation฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀49

2

฀฀฀Cross-Site฀Scripting฀Prevention฀

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

53

The฀Encoding฀Solution฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀54

Handling฀Attributes฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀54

HTML฀Entities฀&฀Filters฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀56

Exclusion฀Approach฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀60

Handling฀Valid฀Attributes฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀63

URL฀Attribute฀Tricks฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀64

XSS฀via฀Environment฀Variables฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀66

IP฀Address฀Information฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀66

Referring฀URL฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀67

Script฀Location฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀67

More฀Severe฀XSS฀Exploits฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀68

Cookie/Session฀Theft฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀69

Form฀Data฀Theft฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀70

Changing฀Page฀Content฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀71

3

฀฀฀SQL฀Injection

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

73

Magic฀Quotes฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀74

Prepared฀Statements฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀75

No฀Means฀of฀Escape฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀77

The฀LIKE฀Quandary฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀78

(10)

9 Contents

Authentication฀Data฀Storage฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀80

Database฀Permissions฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀83

Maintaining฀Performance฀฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀83

Query฀Caching฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀85

4

฀฀฀Preventing฀Code฀Injection

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

87

Path฀Validation฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀88

Using฀Full฀Paths฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀88

Avoiding฀Dynamic฀Paths฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀89

Possible฀Dangers฀of฀Remote฀File฀Access฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀89

Validating฀File฀Names฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀91

Securing฀Eval฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀94

Dynamic฀Functions฀and฀Variables฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀95

Code฀Injection฀via฀PCRE฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀97

5

฀฀฀Command฀Injection฀

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

101

Resource฀Exhaustion฀via฀Command฀Injection฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀102

The฀PATH฀Exploit฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀104

Hidden฀Dangers฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀105

Application฀Bugs฀and฀Setting฀Limits฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀106

PHP฀Execution฀Process฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀108

6

฀฀฀Session฀Security

• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • •

113

Sessions฀&฀Cookies฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀114

Man฀in฀the฀Middle฀Attacks฀ ฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀114

Encryption฀to฀the฀Rescue!฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀115

Server฀Side฀Weakness฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀115

URL฀Sessions฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀115

Session฀Fixation฀฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀117

Surviving฀Attacks฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀117

Native฀Protection฀Mechanism฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀118

User-land฀Session฀Theft฀ ฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀฀•฀ ฀119

Referensi

Dokumen terkait

Using the rule based method, the categorization will be done by matching the content of the new apprentice logbook with the rules that have been made based on the job type

Skripsi ini diajukan untuk memenuhi salah satu syarat memperoleh gelar Sarjana Pendidikan pada Fakultas Pendidikan Ekonomi dan Bisnis. © 2014 Aggih Firdansyah

PERBED AAN KEBUGARAN JASMANI SISWA ANGGOTA EKSTRAKURIKULER SOFTBALL D I SMAN 27 BAND UNG KELAS X D AN XI YANG MENGGUNAKAN TREAD MILL D AN FARTLEK.. Universitas Pendidikan Indonesia

Pengujian ini terdiri atas 3 bagian yaitu pengujian demodulator TCM 3105 CCITT V.23, demodulator TCM 3105 Bell 202 dan demodulator ADF 7021. Untuk demodulator

Selain itu pengelolaan DAS dapat disebutkan merupakan suatu bentuk pengembangan wilayah yang menempatkan DAS sebagai suatu unit pengelolaan sumberdaya alam (SDA) yang

If you wish to make charts like this and don’t have PPT 2007, we have provided the graphical elements to help you build this yourself. Here is the description of the

Dari Tabel 8 dapat dilihat,bahwa kegiatan ekonomi di luar pertanian dan di luar peterrnakankedua dusun berbeda, yakni di Dusun Bantarjo suami yang selalu melakukankegiatan di

Tingginya beban kerja pada dinas pagi berhubungan dengan layanan tambahan dari Rumah Sakit berupa layanan terapi dan diagnostik yang diberikan sedangkan pada