Skip to content

Prevent HEAD requests from confirming accounts - #5880

Open
ozamasa wants to merge 1 commit into
heartcombo:mainfrom
ozamasa:fix/head-confirmation-request
Open

ozamasa wants to merge 1 commit into
heartcombo:mainfrom
ozamasa:fix/head-confirmation-request

Conversation

@ozamasa

@ozamasa ozamasa commented Nov 5, 2026

Copy link
Copy Markdown

Fixes #5312.

Summary

Rails routes HEAD requests through GET routes, so a HEAD request to the confirmation URL currently reaches ConfirmationsController#show and calls confirm_by_token, confirming the account.

This change returns 200 OK before processing the token when the original request method is HEAD. Returning a successful response lets email link scanners validate that the URL is reachable without changing account state. It also avoids a 405 Method Not Allowed response, which may cause a scanner to retry the URL with GET and trigger the same confirmation.

The existing GET confirmation flow is intentionally unchanged. Moving confirmation to a separate POST action would be a larger compatibility change and is outside the scope of this fix.

Tests

  • Added a regression test proving HEAD returns 200 and leaves the account unconfirmed
  • ruby -Itest test/integration/confirmable_test.rb (34 runs, 82 assertions)
  • rake test (879 runs, 2472 assertions)

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

HEAD requests on confirmation URL should not confirm the user

1 participant