Ensure the default state for new installs is more secure#290
Merged
Ensure the default state for new installs is more secure#290
Conversation
…hy this is the case and how to utilize filters to get around this
…on't have that stored yet and also aren't configured yet. Use this value to determine what our default set of trusted headers is. This allows us to keep backwards compatibility with existing sites that are configured
peterwilsoncc
approved these changes
Dec 6, 2023
Contributor
There was a problem hiding this comment.
This looks good to me.
Testing notes:
- Activate on develop branch
- Using the mod header extension, set an
X-Forwarded-Forheader to another, faked, IP address - In RSA settings, allow unrestricted access to the fake IP address
- In a private window, confirm I was able to access the site.
- Update the activation option via wp cli:
wp option update rsa_activation_version 7.5.0 - Switch to this branch
- Confirm I was restricted from accessing the site in the private window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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_proxiesfilter 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_versionto 7.5.0 on whatever site you're testing onrsa_activation_versionoption 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: