The Web Application Hacker’s Handbook Discovering and Exploiting Security Flaws



Download 5,76 Mb.
Pdf ko'rish
bet601/875
Sana01.01.2022
Hajmi5,76 Mb.
#293004
1   ...   597   598   599   600   601   602   603   604   ...   875
Bog'liq
3794 1008 4334

344

Chapter 10 



Exploiting Path Traversal

70779c10.qxd:WileyRed  9/14/07  3:14 PM  Page 344



entirely unnecessary for an application to do this. For most files that are not

subject to any access control, the files can simply be placed within the web root

and accessed via a direct URL. If this is not possible, the application can main-

tain a hard-coded list of image files that may be served by the page, and use a

different identifier to specify which file is required, such as an index number.

Any request containing an invalid identifier can be rejected, and there is no

attack surface for users to manipulate the path of files delivered by the page.

In some cases, as with the workflow functionality that allows file uploading

and downloading, it may be desirable to allow users to specify files by name,

and developers may decide that the easiest way to implement this is by pass-

ing the user-supplied filename to file system APIs. In this situation, the appli-

cation should take a defense-in-depth approach to place several obstacles in

the way of a path traversal attack.

Here are some examples of defenses that may be used; ideally, as many of

these as possible should be implemented together:

■■

After performing all relevant decoding and canonicalization of the user-



submitted filename, the application should check whether this contains

either of the path traversal sequences (using backward or forward

slashes) or any null bytes. If so, the application should stop processing

the request. It should not attempt to perform any sanitization on the

malicious filename.

■■

The application should use a hard-coded list of permissible file types



and reject any request for a different type (after the preceding decoding

and canonicalization has been performed).

■■

After performing all of its filtering on the user-supplied filename, the



application should use suitable file system APIs to verify that nothing is

amiss, and that the file to be accessed using that filename is located

within the start directory specified by the application.

In Java, this can be achieved by instantiating a 

java.io.File

object


using the user-supplied filename and then calling the 

getCanonicalPath

method on this object. If the string returned by this method does not

begin with the name of the start directory, then the user has somehow

bypassed the application’s input filters, and the request should be

rejected.

In ASP.NET, this can be achieved by passing the user-supplied filename

to the 


System.Io.Path.GetFullPath

method and checking the returned

string in the same way as described for Java.

■■

The application can mitigate the impact of most exploitable path traver-



sal vulnerabilities by using a 

chrooted


environment to access the direc-

tory containing the files to be accessed. In this situation, the 

chrooted


Download 5,76 Mb.

Do'stlaringiz bilan baham:
1   ...   597   598   599   600   601   602   603   604   ...   875




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish