Ensure the default state for new installs is more secure #290
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the Change
In #198 we introduced some new filters that can be used to make RSA more secure. These filters do two things:
The idea being that if you want to trust any HTTP headers besides
REMOTE_ADDR
, more than likely you're doing this because your site is behind a proxy. In this situation, you should only trust those additional headers if the request is coming from your proxy IP address, which can be set with that second filter.But all of this is disabled by default and has to be enabled through the use of these filters. This means for sites that use IP restriction, there is a chance of an IP spoofing attack being used.
As such, we've decided to make the core behavior more secure and allow individual sites to opt-in to additional HTTP headers using the filter, instead of the opposite approach we have now.
That said, we also want to maintain backwards compatibility so for any sites that are currently configured to use RSA, they will continue to use the existing list of HTTP headers. They can use the filter to change that list (and are recommended to do so), for instance removing those headers entirely by doing:
add_filter( 'rsa_trusted_headers', '__return_empty_array' );
But any new installs or newly configured installs will have to use that filter to set additional headers as needed. And as mentioned above, if trusting any additional headers, ideally you should be using the
rsa_trusted_proxies
filter to set a list of trusted proxy IP addresses, so the additional headers will only be used if one of those IP addresses matches.Closes #195
How to test the Change
curl --location --request POST 'https://rsa.test' --header 'CF-Connecting-Ip: 127.0.0.2'
rsa_activation_version
to 7.5.0 on whatever site you're testing onrsa_activation_version
option and and the code added above and run through the steps again. This simulates an existing install. Note you should be able to access the site when spoofingChangelog Entry
Credits
Props @dkotter, @peterwilsoncc, @dustinrue, @mikhail-net
Checklist: