Skip to content

Mergeback PR from private to public. - #30284

Merged
edx-pipeline-bot merged 1 commit into
masterfrom
private_to_public_a251d18
Apr 20, 2022
Merged

Mergeback PR from private to public.#30284
edx-pipeline-bot merged 1 commit into
masterfrom
private_to_public_a251d18

Conversation

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

Merge private changes back to the public repo post-PR-merge.

Please review and tag appropriate parties.

Previously, our rate-limiting code trusted the entire `X-Forwarded-For`
header, allowing a malicious client to spoof that header and evade
rate-limiting. This commit introduces a new module and setting
allowing us to make a more conservative choice of IPs.

- Create new `openedx.core.djangoapps.util.ip` module for producing
  the IP "external chain" for requests based on the XFF header and the
  REMOTE_ADDR.
- Include a function that gives the safest choice of IPs.
- Add new setting `CLOSEST_CLIENT_IP_FROM_HEADERS` for configuring how
  the external chain is derived (i.e. setting the trust
  boundary). Currently has a default, but we may want to make it
  mandatory in the future.
- Change `django-ratelimit` code to use the proximate IP in the external
  chain -- the one just outside the trust boundary.

Also:

- Change `XForwardedForMiddleware` to use more conservative choice for
  its `REMOTE_ADDR` override
- Other adjustments to `XForwardedForMiddleware` as needed in order to
  initialize new module and support code that needs the real
  `REMOTE_ADDR` value
- Metrics for observability into the change (and XFF composition)
- Feature switch to restore legacy mode if needed

This also gives us a path forward to removing use of the django-ipware
package, which is no longer maintained and has a handful of bugs that make it
difficult to use safely.

Internal ticket: ARCHBOM-2056
@edx-pipeline-bot
edx-pipeline-bot merged commit 6eda9b6 into master Apr 20, 2022
@edx-pipeline-bot
edx-pipeline-bot deleted the private_to_public_a251d18 branch April 20, 2022 14:56
@edx-secure
edx-secure restored the private_to_public_a251d18 branch April 20, 2022 15:00
@edx-pipeline-bot
edx-pipeline-bot deleted the private_to_public_a251d18 branch April 20, 2022 15:00
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor Author

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor Author

EdX Release Notice: This PR has been deployed to the production environment.

1 similar comment
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor Author

EdX Release Notice: This PR has been deployed to the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants