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

Casting to an integer should be considered input sanitization #179

Closed
JDGrimes opened this issue Jun 25, 2014 · 1 comment · Fixed by #205 or #292
Closed

Casting to an integer should be considered input sanitization #179

JDGrimes opened this issue Jun 25, 2014 · 1 comment · Fixed by #205 or #292

Comments

@JDGrimes
Copy link
Contributor

I think this is true in the XSS sniff, but not in WordPress.VIP.ValidatedSanitizedInput.

For example:

$var = (int) $_GET['some_var'];

This will be flagged, but it shouldn't be.

@JDGrimes
Copy link
Contributor Author

It looks like #205 fixed this when the case is similar to my original example:

$var = (int) $_GET['some_var'];

However, the cast is ignored when the value is in a function call:

$var = some_func( $some_arg, (int) $_GET['some_var'] );

In a case like this I get the non-sanitized input var error.

JDGrimes added a commit to JDGrimes/WordPress-Coding-Standards that referenced this issue Dec 24, 2014
There are two different sanitization checks in this sniff. Only one of
them was considering that casting is a form of input sanitization. I’ve
moved the casting check out of the conditional it was in, and now the
`$is_casted` value is being checked for all sanitization checking paths.

Includes unit tests.

Fixes WordPress#179
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants