Skip to content

fix: add method="post" to auth forms to prevent credential leak in URL#4683

Open
vikyw89 wants to merge 1 commit into
Dokploy:canaryfrom
vikyw89:fix/auth-form-post-method
Open

fix: add method="post" to auth forms to prevent credential leak in URL#4683
vikyw89 wants to merge 1 commit into
Dokploy:canaryfrom
vikyw89:fix/auth-form-post-method

Conversation

@vikyw89

@vikyw89 vikyw89 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

What

Adds method="post" to all auth <form> elements:

  • pages/index.tsx — login, 2FA, and backup-code forms
  • pages/register.tsx — signup form
  • pages/send-reset-password.tsx — reset-request form
  • pages/reset-password.tsx — new-password form

Why

These forms had no method, defaulting to method="get" with action="" (current URL). The normal path is fine — react-hook-form's handleSubmit calls preventDefault() and better-auth sends a fetch POST. But preventDefault() only runs after hydration. Submitting in the pre-hydration window (JS still loading, fast Enter press, or JS disabled/errored) triggers the browser's native default submit:

GET /?email=user@example.com&password=hunter2

…leaking credentials into the URL, browser history, server access logs, and the Referer header.

method="post" makes the native fallback a POST, so the fields go in the request body instead. The JS submit path is completely unchanged.

Verification

Reproduced and verified in a real browser (Chromium via CDP) with a JS-free copy of the form (= the no-JS / pre-hydration state):

Form Browser submit Resulting URL
no method (before) GET /submit?email=…&password=hunter2-secret 🔴 leak
method="post" (after) POST /submit (clean, creds in body) 🟢

Closes #4682

🤖 Generated with Claude Code

Auth forms (login, register, 2FA, backup-code, reset-password) had no
method attribute, defaulting to GET. react-hook-form's handleSubmit
preventDefault()s only after hydration; submitting in the pre-hydration
or no-JS window triggers a native GET to the current URL, leaking
email/password into the URL, history, access logs and Referer header.

Setting method="post" makes the native fallback a POST so credentials
go in the request body instead. Normal JS submit path is unchanged.
Verified in a browser: GET (?email&password) -> POST (clean URL).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vikyw89 vikyw89 requested a review from Siumauricio as a code owner June 22, 2026 15:43
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Credentials can leak into the URL on auth pages when forms submit before React hydration (missing method="post")

1 participant