Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sanitize, escape, and validate POST calls #20

Closed
digitallysavvy opened this issue Nov 18, 2019 · 2 comments
Closed

sanitize, escape, and validate POST calls #20

digitallysavvy opened this issue Nov 18, 2019 · 2 comments
Labels
bug Something isn't working
Projects

Comments

@digitallysavvy
Copy link
Contributor

digitallysavvy commented Nov 18, 2019

Please sanitize, escape, and validate your POST calls

When you include POST/GET/REQUEST/FILE calls in your plugin, it's important to sanitize, validate, and escape them. The goal here is to prevent a user from accidentally sending trash data through the system, as well as protecting them from potential security issues.

SANITIZE: Data that is input (either by a user or automatically) must be sanitized. This lessens the possibility of XSS vulnerabilities and MITM attacks where posted data is subverted.

VALIDATE: All data should be validated as much as possible. Even when you sanitize, remember that you don’t want someone putting in ‘dog’ when the only valid values are numbers.

ESCAPE: Data that is output must be escaped properly, so it can't hijack admin screens. There are many esc_*() functions you can use to make sure you don't show people the wrong data.

To help you with this, WordPress comes with a number of sanitization and escaping functions. You can read about those here:

https://developer.wordpress.org/plugins/security/securing-input/
https://developer.wordpress.org/plugins/security/securing-output/

Remember: You must use the most appropriate functions for the context. If you’re sanitizing email, use sanitize_email(), if you’re outputting HTML, use esc_html(), and so on.

Clean everything, check everything, escape everything, and never trust the users to always have input sane data.

Example(s) from your plugin:

Agora-Word-Press/public/class-wp-agora-io-public.php:84: $cid = $_POST['cid'];

Agora-Word-Press/admin/class-wp-agora-io-admin.php:246: ? (array) $_REQUEST['channel']
Agora-Word-Press/admin/class-wp-agora-io-admin.php:247: : (array) $_POST['post_ID'];

@digitallysavvy digitallysavvy added the bug Something isn't working label Nov 18, 2019
@jalamprea jalamprea added this to Done in WP Plugin via automation Nov 19, 2019
@digitallysavvy
Copy link
Contributor Author

Please sanitize, escape, and validate your POST calls

When you include POST/GET/REQUEST/FILE calls in your plugin, it's important to sanitize, validate, and escape them. The goal here is to prevent a user from accidentally sending trash data through the system, as well as protecting them from potential security issues.

SANITIZE: Data that is input (either by a user or automatically) must be sanitized. This lessens the possibility of XSS vulnerabilities and MITM attacks where posted data is subverted.

VALIDATE: All data should be validated as much as possible. Even when you sanitize, remember that you don’t want someone putting in ‘dog’ when the only valid values are numbers.

ESCAPE: Data that is output must be escaped properly, so it can't hijack admin screens. There are many esc_*() functions you can use to make sure you don't show people the wrong data.

To help you with this, WordPress comes with a number of sanitization and escaping functions. You can read about those here:

https://developer.wordpress.org/plugins/security/securing-input/
https://developer.wordpress.org/plugins/security/securing-output/

Remember: You must use the most appropriate functions for the context. If you’re sanitizing email, use sanitize_email(), if you’re outputting HTML, use esc_html(), and so on.

Clean everything, check everything, escape everything, and never trust the users to always have input sane data.

Example(s) from your plugin:

Agora-Word-Press/admin/class-agora-channels-list-table.php:86: $args['s'] = $_REQUEST['s'];
Agora-Word-Press/admin/class-wp-agora-io-admin.php:205: isset( $_GET['page'] ) ? trim( $_GET['page'] ) : '',
Agora-Word-Press/admin/class-wp-agora-io-admin.php:210: $id = isset( $_POST['post_ID'] ) ? $_POST['post_ID'] : '-1';

@digitallysavvy
Copy link
Contributor Author

New instances have been flagged by WP during the plugin review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
WP Plugin
  
Done
Development

No branches or pull requests

2 participants