Skip to content

Sync: say why the dedicated-request URL check reads the request raw - #51348

Open
Nikschavan wants to merge 3 commits into
trunkfrom
stats-343-sync-sanitize-inputs
Open

Sync: say why the dedicated-request URL check reads the request raw#51348
Nikschavan wants to merge 3 commits into
trunkfrom
stats-343-sync-sanitize-inputs

Conversation

@Nikschavan

@Nikschavan Nikschavan commented Aug 18, 2026

Copy link
Copy Markdown
Member

Proposed changes

  • The two phpcs:ignore lines in Dedicated_Sender named the sniffs but not the reason. They now say it: the value is only substring-matched against a fixed literal, never output or stored.
  • No code change. The earlier commits on this branch sanitized the nonces and ran REQUEST_URI / rest_route through esc_url_raw(); the last commit reverts that — the nonce lines were a no-op and esc_url_raw() on a route path changes the value without a security gain.

Flagged by the WordPress.org plugin review tooling while the standalone Jetpack Stats plugin was under review. The current comments were added for an earlier .org review (p9dueE-8ca-p2, #37402), which approved the code; that context goes into the reply.

Related product discussion/links

  • WordPress.org plugin review of the standalone Jetpack Stats plugin, second automated round.

Does this pull request change what data or activity we track or use?

No.

Testing instructions

  • composer phpcs:lint projects/packages/sync/src/class-dedicated-sender.php passes with the reasons on the two ignores.

@Nikschavan Nikschavan self-assigned this Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack or WordPress.com Site Helper), and enable the stats-343-sync-sanitize-inputs branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack stats-343-sync-sanitize-inputs
bin/jetpack-downloader test jetpack-mu-wpcom-plugin stats-343-sync-sanitize-inputs

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions Bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Aug 18, 2026
@Nikschavan
Nikschavan requested a lite review from Copilot August 18, 2026 07:27
@jp-launch-control

jp-launch-control Bot commented Aug 18, 2026

Copy link
Copy Markdown

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@Nikschavan Nikschavan added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. [Status] In Progress labels Aug 18, 2026
@Nikschavan
Nikschavan marked this pull request as ready for review August 18, 2026 14:21
@Nikschavan
Nikschavan requested a review from a team as a code owner August 18, 2026 14:21

@coder-karen coder-karen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👋 Thanks for looking into this @Nikschavan .

The nonce sanitization looks to be safe here, and is a similar pattern as used elsewhere in the monorepo in other packages / plugins in a handful of other places (but not in far, far more instances). That said, it shouldn't be needed.

The esc_url_raw changes on the other hand have no security benefit, and can result in a real behavior change.

  • rest_route is a REST route path rather than a URL, and esc_url_raw() treats it as one, appending 'http://' if a value reaches $_GET still percent-encoded. In our case, the strpos would still work, but we're changing the behavior unnecessarily here, potentially dangerously if we then make any further changes later.

The comments could be updated to mention that the value is only substring-matched against a fixed literal; never output or stored (and that can be mentioned to the WP.org reviewers).

Noting as well that the existing comments were added due to a WP.org review itself: p9dueE-8ca-p2 (related PR: #37402)

These files already exist within WP.org for several plugins as the vendor files and have done for some time. So it would seem these were likely from AI reviews not considering the history and context, and given the current state was already approved by them it should warrant some push back here.

wp_verify_nonce() is pluggable, so its input cannot be assumed safe. The dedicated-sync URL checks now go through esc_url_raw(), which preserves the percent-encoding that the following urldecode() relies on.
These fail if the URL is passed through sanitize_text_field(), which strips the percent-encoding the following urldecode() depends on.
@Nikschavan
Nikschavan force-pushed the stats-343-sync-sanitize-inputs branch from 1d63a8e to 3f58292 Compare August 19, 2026 11:41
@Nikschavan Nikschavan changed the title Sync: sanitize nonces and request URIs read from the request Sync: say why the dedicated-request URL check reads the request raw Aug 19, 2026
@Nikschavan

Copy link
Copy Markdown
Member Author

Thank you for the context from the previous review — I did not have it, and it is the strongest point for the reply to .org. I reverted the nonce and esc_url_raw() changes in 3f58292 and kept only your suggestion: the two phpcs ignores now say the value is only substring-matched against a fixed literal and never output or stored. Could you take another look?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants