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



Download 5,76 Mb.
Pdf ko'rish
bet519/875
Sana01.01.2022
Hajmi5,76 Mb.
#293004
1   ...   515   516   517   518   519   520   521   522   ...   875
Bog'liq
3794 1008 4334

Parameterized Queries

Most databases and application development platforms provide APIs for han-

dling untrusted input in a secure way which prevents SQL injection vulnera-

bilities from arising. In parameterized queries (also known as prepared



statements), the construction of a SQL statement containing user input is per-

formed in two steps:

1. The application specifies the structure of the query, leaving placehold-

ers for each item of user input.

2. The application specifies the contents of each placeholder.

Crucially, there is no way in which crafted data that is specified at the sec-

ond step can interfere with the structure of the query specified in the first step.

Because the query structure has already been defined, the relevant API han-

dles any type of placeholder data in a safe manner, and so it is always inter-

preted as data rather than part of the statement’s structure.

The following two code samples illustrate the difference between an 

unsafe query dynamically constructed out of user data, and its safe parame-

terized counterpart. In the first, the user-supplied 

name


parameter is embed-

ded directly into a SQL statement, leaving the application vulnerable to SQL

injection:

//define the query structure

String queryText = “select ename,sal from emp where ename =’“;

//concatenate the user-supplied name

queryText += request.getParameter(“name”);

queryText += “‘“;

// execute the query

stmt = con.createStatement();

rs = stmt.executeQuery(queryText);   


Download 5,76 Mb.

Do'stlaringiz bilan baham:
1   ...   515   516   517   518   519   520   521   522   ...   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