PHP architect s Guide to PHP Security Ilia Alshanetsky download
PHP architect s Guide to PHP Security Ilia Alshanetsky download
Alshanetsky download
https://ebookultra.com/download/php-architect-s-guide-to-php-
security-ilia-alshanetsky/
https://ebookultra.com/download/php-cookbook-solutions-examples-for-
php-programmers-3rd-edition-david-sklar/
https://ebookultra.com/download/php-by-example-toby-butzon/
https://ebookultra.com/download/php-mysql-novice-to-ninja-6th-edition-
edition-butler/
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/
https://ebookultra.com/download/javascript-for-php-developers-1st-
edition-stoyan-stefanov/
https://ebookultra.com/download/professional-php-design-patterns-1st-
edition-aaron-saray/
https://ebookultra.com/download/head-first-php-mysql-1st-edition-lynn-
beighley/
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.
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
Licensed to:
Blake Hartle
[email protected]
User #60389
PHP|ARCHITECT’S GUIDE TO
PHP SECURITY
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
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
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.
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
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
Index • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • • 189
Download from Wow! eBook <www.wowebook.com>
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
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—
Il Fuoco 5—
La Vittoria dell'Uomo *.
Trionfo della Vita *.
Poesie:
Drami:
Updated editions will replace the previous one—the old editions will
be renamed.
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.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.
• 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 comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
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.
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.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
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.
ebookultra.com