Repository navigation
Comments: Accept a stale nonce from the site's own page - #53532
Conversation
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryThis 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. 🤷 |
Proposed changes
Originis exactly this site's home or site origin: scheme, host and port. A forged cross-site post carries the other site'sOrigin, which is what the nonce guards against. A default port is ignored, as browsers leave it out;http://, another port, a sibling subdomain andnullall still fail.Checkpoint::is_same_site_request()now compares the full origin (scheme, host, port) instead of the host alone, and the nonce fallback uses it. A site stored ashttp://but served over https still matches its https origin. Sign-in codes get the same tighter check.Checkpoint::is_same_site_request()now refuses a request with noOrigin,RefererorSec-Fetch-Siteat all. It used to let it through, which left sign-in codes open to a cross-site post from browsers that send none of them. Every browser that can run the sign-in flow sendsOriginon the POST.Origincheck covers the case it handled, a logged-in reader served a page cached for nobody.Originfilter, roughly 1 in 400 logged-in comments.Origincheck keeps doing its job in every current browser.Originat all still needs a valid nonce.Originfallback only applies to logged-in readers. A bot can send anyOriginheader, so it must never stand in for the nonce on a logged-out post (see Comments: Keep the form nonce out of the page HTML #53547).record_refusal( 'nonce' ): it recorded exactly the posts this now lets through.Does this pull request change what data or activity we track or use?
jetpack_comments_comment_refusedno longer fires withreason: nonce.Testing instructions
jetpack_comments_form_noncehidden input's value tobad, then post. The comment posts.curland noOriginheader (with your cookies). It's refused with "Sorry, this comment could not be posted."-H 'Origin: https://example.com', and again with the site's own host overhttp://. Both are refused.