• XSS.stack #1 – первый литературный журнал от юзеров форума

del

grozdniyandy

White-Hat
Premium
Регистрация
11.08.2023
Сообщения
522
Реакции
677
Гарант сделки
2
del
 
Последнее редактирование:
обратный слеш является результатом функции str_replace("'", "''", $_REQUEST['new_profile_title']), которая используется для экранирования одинарных кавычек в значении new_profile_title. Функция clean_param вызывается с параметром PARAM_NOTAGS, оно уже содержит экранированные одинарные кавычки, и затем проходит через str_replace("'", "''", $_REQUEST['new_profile_title'])

Попробуй AAAAAA2' OR '1'='1, должно будет по идеи выглядить так:
INSERT INTO user_profiles (TITLE,PROFILE) VALUES('AAAAAA2' OR '1'='1','admin')
 
Пожалуйста, обратите внимание, что пользователь заблокирован
Уязвимость есть, эксплоитнуть можно, дело не в этом. Кстати обратный слеш далеко не является результатом str_replace. Эта функция просто берёт одну кавычку и заменяет её на две одинарные кавычки.

the vulnerability arises due to the incomplete sanitization of the "new_profile_title parameter" before it's used in the sql query while the code attempts to sanitize it using "clean_param()" function with "PARAM_NOTAGS" flag, it doesn't properly handle single quotes (') in the input

this is the problematic line:
Код:
$_REQUEST['new_profile_title'] = str_replace("'", "''", $_REQUEST['new_profile_title']);

with simple research we can find out that this line escapes single quotes in the "new_profile_title parameter" by doubling them up (''), however in sql, escaping a single quote usually involves using a backslash (\), not doubling the quote and this discrepancy leads to unexpected behavior when constructing the sql query
POC :

Код:
new_profile_title=AAAAAA2'; DROP TABLE user_profiles;--&new_profile_type=admin

Expected SQL Query:

INSERT INTO user_profiles (TITLE, PROFILE) VALUES ('AAAAAA2\'', 'admin')

Actual SQL Query:
INSERT INTO user_profiles (TITLE, PROFILE) VALUES ('AAAAAA2''; DROP TABLE user_profiles;--', 'admin')

in this scenario, we injects a sql payload ('; DROP TABLE user_profiles;--) into the "new_profile_title" parameter, when the vulnerable code executes the SQL query, it results in the execution of two sql statements :

the legitimate INSERT statement to insert a new user profile.
the malicious DROP TABLE statement to delete the user_profiles table

i hope this answer your question , i have used my knowladge and google search to find out some informations
 


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх