[WOOMOB-3799] Verify cookie authentication endpoints before sending credentials (1/3) - #16396
[WOOMOB-3799] Verify cookie authentication endpoints before sending credentials (1/3)#16396hichamboushaba wants to merge 4 commits into
Conversation
Generated by 🚫 Danger |
|
|
There was a problem hiding this comment.
AI Code Review - Found 1 potential issue
This is a well-constructed, security-critical hardening of the cookie-nonce authentication flow. The new preflight GET, strict WordPress-login-form detection (rejecting decoys in comments/scripts/templates, split/duplicate/hidden fields, ambiguous multi-form pages), and same-host / no-downgrade / no-userinfo / exact-port / bounded-redirect checks all combine to ensure credentials are only ever POSTed to a verified same-origin login form. The test suite is comprehensive and covers the important adversarial cases (decoys, unsafe actions/redirects, HTTP→HTTPS upgrade, redirect cap, nonce-URL lookalikes, manual admin recovery).
Backwards compatibility looks good: the existing requestNonce(SiteModel) / requestNonce(siteUrl, username, password) signatures are preserved, and the new loginEntryVerified fields on Nonce.FailedRequest / Nonce.Unknown are additive with defaults. The only feedback is a minor readability nit on a security-sensitive boolean below.
Automatic review · claude-opus-4-8 · Workflow run
How to reply to a finding
Reply on this review (or inline at the line the finding refers to) with one of:
@claude addressed- I made the change. Bot verifies against the next diff before marking resolved.@claude rejected: <reason>- Will not fix; reason gets quoted on the next review.@claude not-applicable- Finding does not apply (wrong file, already covered elsewhere, etc.).
The bot honours these on the next review pass.
|
@claude review |
There was a problem hiding this comment.
AI Code Review - Follow-up
- Readability nit on a security-sensitive boolean (
NonceRestClient/CookieNonceAuthenticationEndpoints): still-open — the authentication code is unchanged since the previous review (this pass was re-triggered via@claude reviewwith no new commits), so the earlier non-blocking style suggestion still stands.
New issues: 0
Re-reviewed the full diff: the preflight-based cookie-nonce hardening remains sound. Credentials are only POSTed to a same-host, no-userinfo, no-downgrade, exact-port target derived from a rendered WordPress login form (with comments/scripts/templates stripped and split/duplicate/hidden/ambiguous forms rejected), the preflight and admin-dashboard redirect chains are bounded, and the post-credential redirect is matched exactly against the derived nonce URL. Backwards compatibility is preserved: the existing requestNonce(SiteModel) / requestNonce(siteUrl, username, password) overloads are intact and the new loginEntryVerified fields on Nonce.FailedRequest / Nonce.Unknown are additive with defaults. The test suite continues to cover the key adversarial cases.
Automatic review (follow-up) · claude-opus-4-8 · Workflow run
How to reply to a finding
Reply on this review (or inline at the line the finding refers to) with one of:
@claude addressed- I made the change. Bot verifies against the next diff before marking resolved.@claude rejected: <reason>- Will not fix; reason gets quoted on the next review.@claude not-applicable- Finding does not apply (wrong file, already covered elsewhere, etc.).
The bot honours these on the next review pass.
|
I'm not sure what's wrong with Claude, the issue it complains was in previous commit ( ), but it's not present anymore. |
AdamGrzybkowski
left a comment
There was a problem hiding this comment.
Great work! All manuall tests pass ✅
![]()

Description
Fixes WOOMOB-3799
Part 1 of 3. Followed by #16397 and #16398.
Note
The PR is a bit big, but the bulk is just tests.
This is one direct-site-credentials fix split into three PRs for review; the parts are not intended to ship independently. Merge order is 1 → 2 → 3, once the whole stack is approved.
Cookie/nonce authentication assumed that every store exposed
/wp-login.phpand/wp-admin/. It also posted credentials without first establishing that the destination was a WordPress login form. That prevents login on stores where a security plugin moves either endpoint and makes redirect handling too permissive for a credential-bearing transaction.This PR adds a validated endpoint model containing the canonical store origin plus optional login-entry and admin-base overrides, then rebuilds nonce acquisition around it.
flowchart LR A["GET login entry<br/>up to 3 safe redirects"] --> B{"Verified WordPress<br/>login form?"} B -->|No| X["Fail before sending credentials"] B -->|Yes| C["POST credentials to the<br/>validated form action"] B -->|Already signed in at<br/>the expected admin base| D C -->|Redirect must exactly match<br/>the derived nonce URL| D["GET REST nonce<br/>without following redirects"]The important constraints are:
loginform, with one enabled username field and one enabled password field. Its form action is resolved against the final preflight URL and validated before use.log,pwd, andredirect_toonly./login→/wp-admin/path is handled without posting credentials to the dashboard; a valid nonce still has to prove the session.The form check intentionally fails closed. A store whose theme or plugin substantially changes WordPress's form identity or field semantics may be rejected rather than receiving credentials. Rejection is not limited to the login form itself: malformed form markup elsewhere on the page, or a comment/script marker that survives stripping, rejects the page with the same non-diagnostic invalid-response result. Supporting interactive 2FA, CAPTCHA, SSO, or arbitrary custom form markup is outside this stack.
This PR also introduces optional authenticated-dashboard verification for a supplied admin base; the user-facing recovery flow activates it in PR3. QR login, XML-RPC, and Application Password architecture are unchanged.
Review map:
CookieNonceAuthenticationEndpoints.kt: endpoint validation and same-origin policy.NonceRestClient.kt: preflight, form-action selection, redirect rules, dashboard/nonce checks, and cache identity.Nonce.kt: verified-login-entry provenance.NonceRestClientTest.kt: the safety and compatibility matrix.Test Steps
This PR has no custom-endpoint UI. Use the top-of-stack (PR3) build for step 4.
/wp-login.phpand/wp-admin/paths. Confirm the store opens normally.http://address and valid credentials. Confirm login succeeds normally.Images/gif
N/A — this PR changes the networking layer; the transaction diagram above is the relevant visual.
RELEASE-NOTES.txtif necessary. Use the "[Internal]" label for non-user-facing changes.The stack's single user-facing release note is owned by PR3.