Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL safety when storing data using WordPress built-in functions

When I use WordPress built-in functions like

add_post_meta, update_post_meta, add_user_meta, update_user_meta

wp_insert_post, wp_insert_user

Should I do any escaping or sanitizing before passing the user-input data to these functions or these functions themselves do the trick?

here in codex Action_Reference/save_post the data is passed to update_post_meta right out of the $_POST.

like image 780
MTVS Avatar asked Apr 20 '13 16:04

MTVS


People also ask

Does WordPress protect against SQL injection?

SQL Injection in WordPress. You are secure from any SQL injection vulnerability if you are using up-to-date WordPress core files. However, when you use third-party themes and plugins, your entire application is at a risk. Your WordPress site is only as strong as its weakest link.

What specific WordPress resource is vulnerable to Sqli?

Your application can be vulnerable to SQL injection attacks anywhere your website has a form element (generic contact forms, login portals, blog comment forms, eCommerce checkout pages and search bars amongst others). One vulnerable form element can open up the entire database to attackers.


1 Answers

meta values are sanitized using sanitize_meta, post content is sanitized through wp_kses_post, etc... You can safely assume that built-in functions are secure.

like image 56
diggy Avatar answered Sep 20 '22 01:09

diggy