How do you mitigate SQL injection?
-
Hello,
I found a telltale of a SQL Injection prone code in /erp/includes/functions-people.php > erp_get_peoples. However, based on my testing it’s probably secure. I want to bring it up just to make sure that it’s indeed secure.
Here is the line of code I was concerned about in erp_get_peoples:
$type_sql = ( $type != 'all' ) ? "and name = '" . $type ."'" : '';
I thought that I could pass in anything into $type since it’s available on Accounting > Sales > Payment.
To manipulate the value being passed into $type, I ran this code:
jQuery( "#erp-ac-select-user-for-assign-contact" ).data( "type", "customer' and people.id = '2" )
However, when I test the $final_query value, it was correctly escaped even though you don’t use $wpdb->prepare or any other SQL Injection mitigation technique that I am aware of. Here is what I got as the $final_query value:
and name = 'customer\' and people.id = \'2'
So, I am curious about what you did to escape the $type variable.
Thanks,
- This topic was modified 7 years, 5 months ago by .
- This topic was modified 7 years, 5 months ago by .
- This topic was modified 7 years, 5 months ago by .
The page I need help with: [log in to see the link]
- The topic ‘How do you mitigate SQL injection?’ is closed to new replies.