Skip to content

auth: bind activation and password reset codes to their purpose - #8472

Merged
unknwon merged 5 commits into
mainfrom
ghsa-pmfh-wh5m-gmjm
Nov 10, 2026
Merged

unknwon merged 5 commits into
mainfrom
ghsa-pmfh-wh5m-gmjm

Conversation

@unknwon

@unknwon unknwon commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Describe the pull request

Account activation codes and password reset codes were interchangeable, and completing an activation signed the holder in unconditionally. This PR:

  • Binds each emailed code to its purpose, so an activation code cannot be used as a password reset code and vice versa.
  • Rejects activation for accounts that are already active.
  • No longer signs the user in after activation when two-factor authentication is enabled.
  • Signs the codes with HMAC-SHA256 instead of SHA1 over the secret key concatenated with the data, and compares them in constant time.

Activation, email confirmation, and password reset links sent before upgrading stop working and need to be requested again.

Link to the issue: GHSA-pmfh-wh5m-gmjm

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code or have provided the test plan. (if applicable)
  • I have added an entry to CHANGELOG. (if applicable)

Test plan

On a local instance with email delivery to an SMTP sink, before and after the change:

  1. A password reset code submitted to the account activation endpoint no longer creates a session for a user with two-factor authentication enabled.
  2. An activation code is no longer accepted by the password reset endpoints.
  3. A normal password reset and a normal account activation still work, as does confirming a secondary email address.
  4. Activating an inactive account with two-factor authentication enabled no longer signs the user in. Signing in with a password then asks for the second factor.

go test ./internal/userx/ covers that the two kinds of code are not interchangeable.

AI usage

Claude Code was used to verify the report, write the fix and tests, and run the end-to-end checks above, all reviewed by the maintainer.

@unknwon unknwon added this to the 0.14.4 milestone Nov 10, 2026
@unknwon
unknwon added this pull request to stack #8479 November 10, 2026 19:24
@unknwon
unknwon merged commit c5a49f0 into main Nov 10, 2026
11 checks passed
@unknwon
unknwon deleted the ghsa-pmfh-wh5m-gmjm branch November 10, 2026 19:33
unknwon added a commit that referenced this pull request Nov 11, 2026
@unknwon unknwon mentioned this pull request Nov 11, 2026
4 of 6 tasks
appthin added a commit to appthin/gogs-plus that referenced this pull request Nov 12, 2026
Brings in the 0.14.4 security and bug fixes (gogs#8439, gogs#8472, gogs#8478, gogs#8480-gogs#8484,
gogs#8486, gogs#8488), the Highlights-based diff highlighter for the web UI (gogs#8492,
gogs#8434, gogs#8435), absolute entrypoint paths for the SPA shell (gogs#8447), Docker
workflow updates (gogs#8463, gogs#8475), and housekeeping.

Fork-specific code is preserved: CodeQL workflow, login bans, sign-in
protection, the -plus release pipeline, and the rewritten README.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant