![]() |
Is this safe?
I'm making an ajax autocomplete search and I want to make sure the server side is safe.
Is there anything wrong with this? PHP Code:
|
That script is open to SQL injection. You're not safely escaping input. Apart from that, it could possibly cause some load issues (depending on how often AJAX calls the script).
|
Doesn't $vbulletin->input->clean_gpc() prevent injection?
|
No, it does not. $db->escape_string() prevents SQL injection.
|
Oh, I would have thought vB would automatically clean up all user input by default. Kind of a security flaw for us ignorant few.
|
Not all input needs to be escaped for SQL, as not all input is used in SQL queries. The same happens for XSS. Not all input needs to be escaped for XSS.
|
But there's no harm in escaping it though right?
|
Example
PHP Code:
|
Sorry, you're right. I was presuming everything was being put in the database.
|
Not only that, the input cleaner should not "clean" variables that still are used in their raw form (calculations for example). It will clean according to the class that is used.
Some examples: TYPE_STR - Any string, including non-safe characters. TYPE_NOHTML - Same as above, but cleaned of all HTML special characters. Safe to display on page (XSS), but not SQL-safe. TYPE_INT - Non-numeric data is stripped, safe to display or use in query. TYPE_UINT - Same as above, but only positive integers allowed. |
All times are GMT. The time now is 10:34 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|