100% found this document useful (1 vote)
15 views

PHP architect s Guide to PHP Security Ilia Alshanetsky download

The document is a promotional overview of 'php|architect’s Guide to PHP Security' by Ilia Alshanetsky, which focuses on securing PHP applications against security flaws and exploits. It provides a step-by-step guide to various security topics, real-world coding practices, and techniques applicable to different PHP versions. The book is part of a series aimed at delivering in-depth resources for PHP professionals.

Uploaded by

kerimkimoni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
15 views

PHP architect s Guide to PHP Security Ilia Alshanetsky download

The document is a promotional overview of 'php|architect’s Guide to PHP Security' by Ilia Alshanetsky, which focuses on securing PHP applications against security flaws and exploits. It provides a step-by-step guide to various security topics, real-world coding practices, and techniques applicable to different PHP versions. The book is part of a series aimed at delivering in-depth resources for PHP professionals.

Uploaded by

kerimkimoni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 47

PHP architect s Guide to PHP Security Ilia

Alshanetsky download

https://ebookultra.com/download/php-architect-s-guide-to-php-
security-ilia-alshanetsky/

Explore and download more ebooks or textbooks


at ebookultra.com
Here are some recommended products for you. Click the link to
download, or explore more at ebookultra.com

PHP Cookbook Solutions Examples for PHP Programmers 3rd


Edition David Sklar

https://ebookultra.com/download/php-cookbook-solutions-examples-for-
php-programmers-3rd-edition-david-sklar/

PHP by Example Toby Butzon

https://ebookultra.com/download/php-by-example-toby-butzon/

PHP MySQL Novice to Ninja 6th edition Edition Butler

https://ebookultra.com/download/php-mysql-novice-to-ninja-6th-edition-
edition-butler/

PHP MySQL Novice to Ninja 5th Edition Kevin Yank

https://ebookultra.com/download/php-mysql-novice-to-ninja-5th-edition-
kevin-yank/
Murach s PHP and MySQL First Printing Edition Joel Murach

https://ebookultra.com/download/murach-s-php-and-mysql-first-printing-
edition-joel-murach/

JavaScript for PHP Developers 1st Edition Stoyan Stefanov

https://ebookultra.com/download/javascript-for-php-developers-1st-
edition-stoyan-stefanov/

Professional PHP Design Patterns 1st Edition Aaron Saray

https://ebookultra.com/download/professional-php-design-patterns-1st-
edition-aaron-saray/

Head First PHP MySQL 1st Edition Lynn Beighley

https://ebookultra.com/download/head-first-php-mysql-1st-edition-lynn-
beighley/

PHP MySQL For Dummies 4th Edition Janet Valade

https://ebookultra.com/download/php-mysql-for-dummies-4th-edition-
janet-valade/
PHP architect s Guide to PHP Security Ilia Alshanetsky
Digital Instant Download
Author(s): Ilia Alshanetsky
ISBN(s): 9780973862102, 0973862106
Edition: Kindle
File Details: PDF, 2.25 MB
Year: 2005
Language: english
php|architect’s
Guide to php|architect’s
PHP Security
With the number of security flaws and exploits discovered and released
Guide to
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


PHP Security

php|architect’s Guide to PHP Security


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.
A Step-by-step Guide to Writing
This book gives you a step-by-step guide to each security-related topic,
Secure and Reliable PHP Applications
providing you with real-world examples of proper coding practices and their
implementation in PHP in an accurate, concise and complete way. Ilia Alshanetsky
¸ 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

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.

Ilia Alshanetsky
US $32.99 From the publishers of

Canada $47.99
UK (net) £18.99 Foreword by Rasmus Lerdorf
Shelve under PHP/Web Development/Internet Programming

7.50 x 9.25 .424 7.50 x 9.25

Licensed to:
Blake Hartle
[email protected]
User #60389
PHP|ARCHITECT’S GUIDE TO
PHP SECURITY

Download from Wow! eBook <www.wowebook.com>


by Ilia Alshanetsky
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

Download from Wow! eBook <www.wowebook.com>


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 trademarks 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. (416) 630-6202
28 Bombay Ave. (877) 630-6202 toll free within North America
Toronto, ON M3H 1B7 [email protected] / www.phparch.com
Canada
Marco Tabini, Publisher

Edited By Martin Streicher

Technical Reviewers Marco Tabini

Layout and Design Arbi Arzoumani

Managing Editor Emanuela Corso


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.

Ilia is a regular speaker at PHP-related conferences worldwide and can often be found teaching the Zend Certification
Training and Professional PHP Development courses that he has written for php|architect. He is also a prolific author, with
articles for PHP|Architect, International PHP Magazine, Oracle Technology Network, Zend.com and others to his name.

Ilia maintains an active blog at http://ilia.ws, filled tips and tricks on how to get the most out of PHP.

Download from Wow! eBook <www.wowebook.com>


Download from Wow! eBook <www.wowebook.com>
Download from Wow! eBook <www.wowebook.com>
To my parents,
Who are and have been my pillar of support
Download from Wow! eBook <www.wowebook.com>
Contents

Download from Wow! eBook <www.wowebook.com>


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
White List Validation • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 36
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

Download from Wow! eBook <www.wowebook.com>


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
SQL Error Handling • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 79
Contents 9

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

Download from Wow! eBook <www.wowebook.com>


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
Expiry Time Tricks • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 119
10 Contents

Server Side Expiry Mechanisms • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 120


Mixing Security and Convenience • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 121
Securing Session Storage • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 122
Session ID Rotation • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 126
IP Based Validation • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 128
Browser Signature • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 129
Referrer Validation • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 130
User Education • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 131

7 Securing File Access• • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 135


The Dangers of “Worldwide” Access • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 136
Securing Read Access • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 137

Download from Wow! eBook <www.wowebook.com>


PHP Encoders • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 137
Manual Encryption • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 138
Open Base Directory • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 139
Securing Uploaded Files • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 140
Securing Write Access • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 140
File Signature • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 142
Safe Mode • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 143
An Alternate PHP Execution Mechanism • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 144
CGI • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 145
FastCGI • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 145
Shared Hosting Woes • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 146
File Masking • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 147

8 Security through Obscurity • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 153


Words of Caution • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 153
Hide Your Files • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 154
Obscure Compiled Templates • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 156
Transmission Obfuscation • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 158
Obscure Field Names • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 158
Field Name Randomization • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 159
Use POST • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 160
Content Compression • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 161
Contents 11

HTML Comments • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 161


Software Identification • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 162

9 Sandboxes and Tar Pits • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 165


Misdirect Attacks with Sandboxes • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 166
Building a Sandbox • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 166
Tracking Passwords • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 167
Identify the Source of the Attack Source • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 169
Find Routing Information • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 170
Limitations with IP Addresses • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 171
Smart Cookie Tricks • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 173
Record the Referring URL • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 173

Download from Wow! eBook <www.wowebook.com>


Capture all Input Data • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 174
Build a Tar Pit • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 176

10 Securing Your Applications • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 179


Enable Verbose Error Reporting • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 180
Replace the Usage of Register Globals • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 180
Avoid $_REQUEST • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 181
Disable Magic Quotes • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 182
Try to Prevent Cross-Site Scripting (XSS) • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 183
Improve SQL Security • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 183
Prevent Code Injection • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 184
Discontinue use of eval() • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 185
Mind Your Regular Expressions • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 185
Watch Out for Dynamic Names • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 185
Minimize the Use of External Commands • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 186
Obfuscate and Prepare a Sandbox • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 187

Index • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 189
Download from Wow! eBook <www.wowebook.com>
Foreword

Download from Wow! eBook <www.wowebook.com>


W
hen I started the PHP project years ago, the goal was to develop a tool for solv-
ing the Web problem by removing barriers and simplifying the interaction between
the web server and the hundreds of sub-systems required to solve a wide variety of
problems. Over the years, I think we have achieved that. PHP has allowed people with all sorts
of different backgrounds to put their ideas on the Web. To me, this is the success of PHP and
what keeps me motivated to continue working on it.
With all the success of PHP, I will be the first to admit that there are areas where we haven’t
done a very good job of educating and providing people with the tools they need. Security is
at the top of that list—we have simplified access to things, provided a language and a set of
functions to do anything anybody could want to do, but we have not provided much in the way
of tools or guidance aimed at helping people write secure applications. We have been content
with being on par with other environments in this respect, while in almost all other areas we
have strived to be better.
Security is not easy. People have to understand their systems well to know where security
14 Foreword

issues are likely to appear, and they have to remember to actually check. Like a small hole in
a balloon, one missed security check will burst their application. PHP provides a number of
tools to help people address security problems, but without a good understanding of when
and how to apply them, they aren’t very useful. We will therefore need a combined effort to try
to collectively achieve better security. Users need to become better educated, and we need to
provide better tools.
Recently, a number of automated security scanners have appeared. Primarily, these detect
cross-site scripting problems, but they also catch the occasional SQL injection. The main thing
I have gotten out of seeing the results of these scans is that the web application security prob-
lem is pervasive and doesn’t care what language an application is written in.
A first step is for people to read a book like this one that outlines common security prob-
lems in web applications. And, while the solutions presented here are all PHP-based using the
tools provided by PHP, most of the problems apply to any language and environment. People

Download from Wow! eBook <www.wowebook.com>


should use this book to solve their PHP-based web application security problems, but they
should also use this book to take a higher-level look at security everywhere in all their systems.
Cross-site scripting and SQL injection are just two examples of inadvertently exposing a sub-
system to end-user data input. What other sub-systems are in your architecture? Are they ap-
propriately protected against direct user input?
There is no security panacea here.—nobody will ever be able to provide one. The closest
we will get is to try to improve the overall awareness of these issues and to provide better tools
for solving them. Having a straightforward architecture that is easy to understand makes this
easier for PHP users. Having a book like this on your bookshelf makes it even easier.

Rasmus Lerdorf
Random documents with unrelated
content Scribd suggests to you:
L'infermo ora pareva preso da uno stupidimento cupo. Teneva gli
occhi fissi su 'l coltello, senza dire niente, con la bocca semiaperta,
con le mani penzoloni lungo i fianchi, come un idiota.
Cirù lo fece sedere, gli tolse la fasciatura, mettendo con le labbra
quei suoni istintivi che indicano il ribrezzo. Un momento, tutti si
chinarono su la piaga, in silenzio, a guardare. Massacese disse:
— Cusì e cusì, — indicando con la punta del coltello la direzione dei
tagli.
Allora, d'un tratto, Gialluca ruppe in un gran pianto. Tutto il suo
corpo veniva scosso dai singhiozzi.
— Curagge! Curagge! — gli ripetevano i marinai, prendendolo per le
braccia.
Massacese incominciò l'opera. Al primo contatto della lama, Gialluca
gittò un urlo; poi stringendo i denti, metteva quasi un muggito
soffocato.
Massacese tagliava lentamente, ma con sicurezza; tenendo fuori la
punta della lingua, per una abitudine ch'egli aveva nel condur le cose
con attenzione. Come il trabaccolo barcollava, il taglio riusciva
ineguale; il coltello ora penetrava più, ora meno. Un colpo di mare
fece affondare la lama dentro i tessuti sani. Gialluca gittò un altro
urlo, dibattendosi, tutto sanguinante, come una bestia tra le mani
dei beccai. Egli non voleva più sottomettersi.
— No, no, no!
— Vien' a qua! Vien' a qua! — gli gridava Massacese, dietro, volendo
seguitare la sua opera perchè temeva che il taglio interrotto fosse
più pericoloso.
Il mare, ancora grosso, romoreggiava in torno, senza fine. Nuvole in
forma di trombe sorgevano dall'ultimo termine ed abbracciavano il
cielo deserto d'uccelli. Oramai, in mezzo a quel frastuono, sotto
quella luce, una eccitazione singolare prendeva quegli uomini.
Involontariamente, essi nel lottare col ferito per tenerlo fermo,
s'adiravano.
— Vien' a qua!
Massacese fece altre quattro o cinque incisioni, rapidamente, a caso.
Sangue misto a materie biancastre sgorgava dalle aperture. Tutti
n'erano macchiati, tranne Nazareno che stava a prua, tremante,
sbigottito dinanzi all'atrocità della cosa.
Ferrante La Selvi, che vedeva la barca pericolare, diede un comando
a squarciagola:
— Molla le scòtteee! Butta 'l timone a l'ôrsa!
I due Talamonte, Massacese, Cirù manovrarono. Il trabaccolo riprese
a correre beccheggiando. Si scorgeva Lissa in lontananza. Lunghe
zone di sole battevano su le acque, sfuggendo di tra le nuvole; e
variavano secondo le vicende celesti.
Ferrante rimase alla sbarra. Gli altri marinai tornarono a Gialluca.
Bisognava nettare le aperture, bruciare, mettere le filacce.
Ora il ferito era in una prostrazione profonda. Pareva che non
capisse più nulla. Guardava i compagni, con due occhi smorti, già
torbidi come quelli degli animali che stanno per morire. Ripeteva ad
intervalli, quasi fra sè:
— So' morto! So' morto!
Cirù, con un po' di stoppa grezza, cercava di pulire; ma aveva la
mano rude, irritava la piaga. Massacese, volendo fino all'ultimo
seguire l'esempio del cerusico di Margadonna, aguzzava certi pezzi di
legno d'abete, con attenzione. I due Talamonte si occupavano del
catrame, poichè il catrame bollente era stato scelto per bruciare la
piaga. Ma era impossibile accendere il fuoco su 'l ponte che ad ogni
momento veniva allagato. I due Talamonte discesero sotto coperta.
Massacese gridò a Cirù:
— Lava nghe l'acqua de mare!
Cirù seguì il consiglio. Gialluca si sottometteva a tutto, facendo un
lagno continuo, battendo i denti. Il collo gli era diventato enorme,
tutto rosso, in alcuni punti quasi violaceo. In torno alle incisioni
cominciavano ad apparire alcune chiazze brunastre. L'infermo
provava difficoltà a respirare, a inghiottire; e lo tormentava la sete.
— Arcummánnete a sante Rocche — gli disse Massacese che aveva
finito di aguzzare i pezzi di legno e che aspettava il catrame.
Spinto dal vento, il trabaccolo ora deviava in su, verso Sebenico,
perdendo di vista l'isola. Ma quantunque le onde fossero ancora forti,
la burrasca accennava a diminuire. Il sole era a mezzo del cielo, tra
nuvole color di ruggine.
I due Talamonte vennero con un vaso di terra pieno di catrame
fumante.
Gialluca s'inginocchiò, per rinnovare il voto al santo. Tutti si fecero il
segno della croce.
— Oh sante Rocche, sálveme! Te 'mprumette 'na lampa d'argente e
l'uoglie pe' tutte l'anne e trenta libbre de ciere. Oh sante Rocche,
sálveme tu! Tenghe la mojie e li fijie... Pietà! Misericordie, sante
Rocche mi'!
Gialluca teneva congiunte le mani; parlava con voce che pareva non
fosse più la sua. Poi si rimise a sedere, dicendo semplicemente a
Massacese:
— Fa.
Massacese avvolse in torno ai pezzi di legno un po' di stoppa; e a
mano a mano ne tuffava uno nel catrame bollente e con quello
strofinava la piaga. Per rendere più efficace e profonda la bruciatura,
versò anche il liquido nelle ferite. Gialluca non mosse un lamento. Gli
altri rabbrividivano, in conspetto di quello strazio.
Disse Ferrante La Selvi, dal suo posto, scotendo il capo:
— L'avet'accise!
Gli altri portarono sotto coperta Gialluca semivivo; e l'adagiarono
sopra una branda. Nazareno rimase a guardia, presso l'infermo. Si
udivano di là le voci gutturali di Ferrante che comandava la manovra
e i passi precipitati dei marinai. La Trinità virava, scricchiolando. A un
tratto Nazareno si accorse d'una falla in cui entrava acqua; chiamò. I
marinai discesero, in tumulto. Gridavano tutti insieme, provvedendo
in furia a riparare. Pareva un naufragio.
Gialluca, benchè prostrato di forze e d'animo, si rizzò su la branda,
imaginando che la barca andasse a picco; e s'aggrappò
disperatamente a uno dei Talamonte. Supplicava, come una
femmina:
— Nen me lasciate! Nen me lasciate!
Lo calmarono; lo riadagiarono. Egli ora aveva paura; balbettava
parole insensate; piangeva; non voleva morire. Poichè
l'infiammazione crescendo gli occupava tutto tutto il collo e la cervice
e si diffondeva anche pe 'l tronco a poco a poco, e la gonfiezza
diveniva ancor più mostruosa, egli si sentiva strozzare. Spalancava
ogni tanto la bocca per bevere l'aria.
— Portateme sopra! A qua me manghe l'arie; a qua me more....
Ferrante richiamò gli uomini sul ponte. Il trabaccolo ora
bordeggiando cercava di acquistare cammino. La manovra era
complicata. Ferrante spiava il vento e dava il comando utile, stando
al timone. Come più il vespro si avvicinava, le onde si placavano.
Dopo qualche tempo, Nazareno venne sopra, tutto sbigottito,
gridando:
— Gialluca se more! Gialluca se more!
I marinai corsero; e trovarono il compagno già morto su la branda,
in un'attitudine scomposta, con gli occhi aperti, con la faccia tumida,
come un uomo strangolato.
Disse Talamonte maggiore:
— È mo'?
Gli altri tacquero, un po' smarriti, dinanzi al cadavere.
Risalirono su 'l ponte, in silenzio. Talamonte ripeteva:
— È mo'?
Il giorno si ritirava lentamente dalle acque. Nell'aria veniva la calma.
Un'altra volta le vele si afflosciavano e il naviglio rimaneva senza
avanzare. Si scorgeva l'isola di Solta.
I marinai, riuniti a poppa, ragionavano del fatto. Un'inquietudine viva
occupava tutti gli animi: Massacese era pallido e pensieroso. Egli
osservò:
— Avéssene da dice che l'avéme fatte murì nu áutre? Avasséme da
passà guai?
Questo timore già tormentava lo spirito di quegli uomini superstiziosi
e diffidenti. Essi risposero:
— È lu vere.
Massacese incalzò:
— Mbé? Che facéme?
Talamonte maggiore disse, semplicemente:
— È morte? Jettámele a lu mare. Facéme vedé ca l'avéme pirdute 'n
mezz'a lu furtunale... Certe, n'arrièsce.
Gli altri assentirono. Chiamarono Nazareno.
— Oh, tu... mute come nu pesce.
E gli suggellarono il segreto nell'animo, con un segno minaccioso.
Poi discesero a prendere il cadavere. Già le carni del collo davano
odore malsano; le materie della suppurazione gocciolavano, ad ogni
scossa.
Massacese disse:
— Mettémele dentr'a nu sacche.
Presero un sacco; ma il cadavere ci entrava per metà. Legarono il
sacco alle ginocchia, e le gambe rimasero fuori. Si guardavano d'in
torno, istintivamente, facendo l'operazione mortuaria. Non si
vedevano vele; il mare aveva un ondeggiamento largo e piano, dopo
la burrasca; l'isola di Solta appariva tutt'azzurra, in fondo.
Massacese disse:
— Mettémece pure 'na preta.
Presero una pietra fra la zavorra, e la legarono ai piedi di Gialluca.
Massacese disse:
— Avande!
Sollevarono il cadavere fuori del bordo e lo lasciarono scivolare nel
mare. L'acqua si richiuse gorgogliando; il corpo discese da prima con
una oscillazione lenta; poi si dileguò.
I marinai tornarono a poppa, ed aspettarono il vento. Fumavano,
senza parlare. Massacese ogni tanto faceva un gesto involontario,
come fanno talora gli uomini cogitabondi.
Il vento si levò. Le vele si gonfiarono, dopo avere palpitato un
istante. La Trinità si mosse nella direzione di Solta. Dopo due ore di
buona rotta, passò lo stretto.
La luna illuminava le rive. Il mare aveva quasi una tranquillità
lacustre. Dal porto di Spálato uscivano due navigli, e venivano
incontro alla Trinità. Le due ciurme cantavano.
Udendo la canzone, Cirù disse:
— Toh! So' di Piscare.
Vedendo le figure e le cifre delle vele, Ferrante disse:
— So' li trabaccule di Raimonde Callare.
E gittò la voce.
I marinai paesani risposero con grandi clamori. Uno dei navigli era
carico di fichi secchi, e l'altro di asinelli.
Come il secondo dei navigli passò a dieci metri dalla Trinità, varii
saluti corsero. Una voce gridò:
— Oh Giallù! Addó sta Gialluche?
Massacese rispose:
— L'avéme pirdute a mare, 'n mezz'a lu furtunale. Dicétele a la
mamme.
Alcune esclamazioni allora sorsero dal trabaccolo degli asinelli; poi gli
addii.
— Addie! Addie! A Piscare! A Piscare!
E allontanandosi le ciurme ripresero la canzone, sotto la luna.
INDICE.

Pag.
La vergine Orsola 1
La vergine Anna 86
Gli idolatri 165
L'eroe 186
La veglia funebre 194
La contessa d'Amalfi 209
La morte del duca d'Ofena 255
Il traghettatore 276
Agonia 307
La fine di Candia 319
La fattura 337
I marenghi 364
La madia 374
Mungià 383
La guerra del Ponte 397
Turlendana ritorna 421
Turlendana ebro 437
Il cerusico di mare 448
OPERE di GABRIELE D'ANNUNZIO
I romanzi della Rosa:

Il Piacere L. 5 —
L'Innocente 4—
Trionfo della Morte 5—

I romanzi del Giglio:

Le Vergini delle Rocce 5—


La Grazia *.
L'Annunziazione *.

I romanzi del Melagrano:

Il Fuoco 5—
La Vittoria dell'Uomo *.
Trionfo della Vita *.

Le Novelle della Pescara 4—

Poesie:

Canto novo; Intermezzo 4—


L'Isottéo; la Chimera 4—
Poema paradisiaco; Odi navali 4—
La Canzone di Garibaldi: La
Notte di Caprera 1 50
In morte di Giuseppe Verdi.
Canzone preceduta da una
Orazione ai giovani 1—
Nel primo centenario della
nascita di Vittor Hugo —
mdcccii-mcmii — ode 1—
Laudi del Cielo, del Mare, della
Terra e degli Eroi
Vol. I: Laus Vitæ. Legato in
finta pergamena 8—
— Legato in vera pergamena 12 —
Vol. II: Elettra — Alcione.
Legato in finta pergamena 10 —
— Legato in vera pergamena 14 —
L'Allegoria dell'Autunno 1—

Drami:

Francesca da Rimini, tragedia


in 5 atti 7 50
— Legata in vera pergamena
con fregi e nastri di stile
antico 12 —
Francesca da Rimini. Edizione
econom. 4—
La Città morta, tragedia in 5
atti 4—
La Gioconda, tragedia in 4 atti 4—
La Gloria, tragedia in 5 atti 4—
La Figlia di Iorio, tragedia in 3
atti 4—
I Sogni delle Stagioni

Sogno d'un mattino di


primavera 2—
* Sogno d'un meriggio
d'estate.
Sogno d'un tramonto
d'autunno 2—
* Sogno d'una notte d'inverno.
Nota del Trascrittore

Ortografia e punteggiatura originali sono state


mantenute, correggendo senza annotazione minimi errori
tipografici.
*** END OF THE PROJECT GUTENBERG EBOOK LE NOVELLE DELLA
PESCARA ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying
copyright royalties. Special rules, set forth in the General Terms of
Use part of this license, apply to copying and distributing Project
Gutenberg™ electronic works to protect the PROJECT GUTENBERG™
concept and trademark. Project Gutenberg is a registered trademark,
and may not be used if you charge for an eBook, except by following
the terms of the trademark license, including paying royalties for use
of the Project Gutenberg trademark. If you do not charge anything
for copies of this eBook, complying with the trademark license is
very easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund
from the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law
in the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name associated
with the work. You can easily comply with the terms of this
agreement by keeping this work in the same format with its attached
full Project Gutenberg™ License when you share it without charge
with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears,
or with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning
of this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1
with active links or immediate access to the full terms of the Project
Gutenberg™ License.

1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt
that s/he does not agree to the terms of the full Project
Gutenberg™ License. You must require such a user to return or
destroy all copies of the works possessed in a physical medium
and discontinue all use of and all access to other copies of
Project Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for


the “Right of Replacement or Refund” described in paragraph 1.F.3,
the Project Gutenberg Literary Archive Foundation, the owner of the
Project Gutenberg™ trademark, and any other party distributing a
Project Gutenberg™ electronic work under this agreement, disclaim
all liability to you for damages, costs and expenses, including legal
fees. YOU AGREE THAT YOU HAVE NO REMEDIES FOR
NEGLIGENCE, STRICT LIABILITY, BREACH OF WARRANTY OR
BREACH OF CONTRACT EXCEPT THOSE PROVIDED IN PARAGRAPH
1.F.3. YOU AGREE THAT THE FOUNDATION, THE TRADEMARK
OWNER, AND ANY DISTRIBUTOR UNDER THIS AGREEMENT WILL
NOT BE LIABLE TO YOU FOR ACTUAL, DIRECT, INDIRECT,
CONSEQUENTIAL, PUNITIVE OR INCIDENTAL DAMAGES EVEN IF
YOU GIVE NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving
it, you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or
entity that provided you with the defective work may elect to provide
a replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation,


the trademark owner, any agent or employee of the Foundation,
anyone providing copies of Project Gutenberg™ electronic works in
accordance with this agreement, and any volunteers associated with
the production, promotion and distribution of Project Gutenberg™
electronic works, harmless from all liability, costs and expenses,
including legal fees, that arise directly or indirectly from any of the
following which you do or cause to occur: (a) distribution of this or
any Project Gutenberg™ work, (b) alteration, modification, or
additions or deletions to any Project Gutenberg™ work, and (c) any
Defect you cause.

Section 2. Information about the Mission


of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many
small donations ($1 to $5,000) are particularly important to
maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.
Project Gutenberg™ eBooks are often created from several printed
editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

ebookultra.com

You might also like