Skip to content

Comments: Keep the form nonce out of the page HTML - #53547

Merged
arcangelini merged 6 commits into
trunkfrom
fix/comments-spam-nonce
Oct 13, 2026
Merged

arcangelini merged 6 commits into
trunkfrom
fix/comments-spam-nonce

Conversation

@arcangelini

@arcangelini arcangelini commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Proposed changes

  • Since launch, spam on Simple jumped from about 10k a day to about 300k+. The page now holds a full core-shaped fallback form (textarea, name, email, website), which spam bots post straight from the HTML. Verbum's page had no fields.
  • The form nonce is no longer printed as a form field. A small inline ES5 script, printed with window.JetpackComments, adds it to the form, so a bot posting the form's fields has none. It's inline rather than in the bundle so a reader whose bundle fails to load or parse can still post.
  • That reader also gets the plain form now. It stayed hidden until the bundle ran, so a blocked or broken bundle left no form at all. After the page's load event, the inline script shows any form the bundle never mounted.
  • Logged-out comments now need that nonce present. It doesn't have to be valid: it's the same for everybody and a page cache serves it stale, which is why Comments: Skip the nonce for logged-out readers #53390 dropped the check. Logged-in readers still need a valid one.
  • A logged-out guest with JavaScript off can't post the plain form any more, so they get a short "Turn on JavaScript to leave a comment." note instead of fields that would be refused. Logged-in readers and must-log-in sites keep the plain form, whose posts get through on Comments: Accept a stale nonce from the site's own page #53532's same-site Origin fallback. Verbum never worked without JavaScript.
  • The guest dialog no longer loads for logged-in readers. It started on the guest step with their own WordPress.com email filled in, so hovering over the form fired jetpack_comments_email_has_account and an email check.
  • Interacts with Comments: Accept a stale nonce from the site's own page #53532. Its same-site Origin fallback must stay logged-in only, or a logged-out bot with no nonce gets in by sending a forged Origin header.

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

jetpack_comments_email_has_account no longer fires for logged-in readers. It only fired for them by mistake.

Testing instructions

  • Turn Jetpack Comments on (add_filter( 'jetpack_comments_new_hotness', '__return_true' );) and build the package.
  • Logged out, view a post's source. The form has no jetpack_comments_form_nonce input. In DevTools, it has one.
  • Block the comments.js bundle in DevTools (Network request blocking) and reload. The form still has the nonce input, and the plain form posts.
  • Post a comment logged out. It posts.
  • Replay that POST with curl and without the jetpack_comments_form_nonce field. It's refused with "Sorry, this comment could not be posted."
  • Replay it with jetpack_comments_form_nonce=stale. It posts.
  • Logged out, turn JavaScript off and reload. The note shows in place of the form.
  • Logged in, post a comment. It posts. Change the nonce to bad in DevTools and post again. It's refused.
  • Logged in, hover over the comment form with the Network tab open. No modal chunk and no email check request load.

@github-actions

github-actions Bot commented Oct 13, 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 fix/comments-spam-nonce branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/comments-spam-nonce
bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/comments-spam-nonce

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

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!

@jp-launch-control

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

@arcangelini
arcangelini merged commit 4ee971f into trunk Oct 13, 2026
83 checks passed
@arcangelini
arcangelini deleted the fix/comments-spam-nonce branch October 13, 2026 16:22
@github-actions github-actions Bot added [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. and removed [Status] Needs Review This PR is ready for review. labels Oct 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Comments [Status] UI Changes Add this to PRs that change the UI so documentation can be updated. [Type] Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant