Skip to content

Conversation

brandonpayton
Copy link
Member

Motivation for the change, related issues

The CORS proxy shouldn't be able to target itself, so this PR rejects requests that attempt to do so.

Closes #1919

Implementation details

This PR checks the $_SERVER['HTTP_HOST' and $_SERVER['SERVER_ADDR'] and rejects the request if the target host matches either.

Testing Instructions (or ideally a Blueprint)

  • CI
@brandonpayton brandonpayton added [Type] Bug An existing feature does not function as intended [Package][@wp-playground] CORS Proxy labels Oct 23, 2024
@brandonpayton brandonpayton requested a review from a team October 23, 2024 05:22
@brandonpayton brandonpayton self-assigned this Oct 23, 2024
@brandonpayton brandonpayton merged commit acfd807 into trunk Oct 23, 2024
9 checks passed
@brandonpayton brandonpayton deleted the cors-proxy-reject-targeting-self branch October 23, 2024 15:28
( isset( $_SERVER['SERVER_ADDR'] ) &&
strcasecmp($_SERVER['SERVER_ADDR'], $host) === 0)
) {
throw new CorsProxyException("URL cannot target the CORS proxy host.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call!

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

Labels

[Package][@wp-playground] CORS Proxy [Type] Bug An existing feature does not function as intended

2 participants