Automattic / Automattic/VIP-Coding-Standards

WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders wrong & incomplete

Open
#477 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
261
Forks
44
Avg merge
19m
Merged PRs (30d)
1

Description

1) I get 1) WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders even when it's perfectly fine sanitized:

`$user_ip = filter_var( $_SERVER['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP );`

or with wp only functions (though I'm not sure if it really is properly sanitized then)

`sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) )`

What is the correct way of validating this this sniff expects?

2) this error doesn't make much sense, as it's limited to 3 headers. But there is an arbitrary number of HTTP headers the client could send which would not trigger this error but may be used.
E.g. when using cloudflare there's also the CF_IPCOUNTRY,... headers which would also need to be added to the check.

Contributor guide

Open the contributing guide

Research direction

Start by locating the WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders sniff and reproduce its behavior with the two PHP examples in the report. Investigate how it recognizes validation and which client headers it checks, then identify the tests or fixtures that define the expected behavior. Done means the validation guidance and header coverage are made explicit and verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, wordpress
Domain
security, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.