WordPress / WordPress/WordPress-Coding-Standards
filter_input() doesn't mean variable is sanitized
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 2.8k
- Forks
- 521
- Avg merge
- 5d 20h
- Merged PRs (30d)
- 1
Description
filter_input() is listed as an escaping function. However if the third parameter isn't set, then no sanitization takes place.
Example:
URL: http://test.dev/?test=%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E
echo filter_input( INPUT_GET, 'test' );
vs.
echo filter_input( INPUT_GET, 'test', FILTER_SANITIZE_STRING );
Should detection of filter_input require manual inspection or is it possible to check if the third parameter is set?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the rule that treats filter_input() as an escaping function and inspect how its arguments are analyzed. Compare calls with and without the third parameter, then check the rule's existing tests if available. Done means detection distinguishes unsanitized calls from calls that explicitly provide a sanitizing filter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100