Repository navigation
fix: password reset delivery, captcha bypass, and map races - #80
Merged
Merged
Conversation
…utexes verifyCaptcha shadowed its "found" flag when looking up an invite captcha, so an unknown captcha ID left the outer flag true and fell through to comparing a zero-value Captcha. Submitting an unknown ID with empty text matched that empty answer and passed verification, bypassing the signup captcha entirely. pwrCaptchas and internalPWRs were plain maps written from both request handlers and the housekeeping daemon with no synchronisation, which can overwrite a captcha answer mid-flight or trip Go's fatal concurrent map write and take the process down. Both now go through locked accessors, matching how ConfirmationKeys is already handled. Also returns after rendering the 404 page in GetCaptcha and GenCaptcha, which previously carried on and wrote a second response.
…ng success sendByID reassigned err on every contact method and had all of its error checks commented out, so one method's failure was masked by the next, and a user with no contact method at all returned nil. Callers took that as success, so ResetMyPassword logged a reset as sent when nothing had gone out. Errors are now collected per method and a missing contact method returns ErrNoContactMethod. validatePWR dropped resets silently when Jellyfin's file was read before it had finished flushing, because the parse failure only logged at debug level and the RetryCount and RetryInterval constants were never wired up. It now retries, logs at error level once it gives up, and says so when the user has no contact method configured.
mj-raw is not processed inside mj-button, so the tag survived MJML compilation and reached mail clients wrapping the button label. Clients strip unknown elements, which left the reset button with no text on it.
5 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three related bug classes found while investigating a user whose password reset never arrived, plus a broken button in the reset email.
verifyCaptchashadowed its found-flag when looking up an invite captcha, so an unknown captcha ID left the outer flagtrueand fell through to comparing a zero-valueCaptcha. Submitting an unknown ID with empty text compared"" == ""and passed, bypassing the signup captcha entirely.pwrCaptchasandinternalPWRswere plain maps written from both request handlers and the housekeeping daemon with no locking. That can overwrite a captcha answer mid-flight (a correctly typed answer gets rejected) or trip Go's fatal concurrent map write, which no recover() can catch. Both now use locked accessors, matching the existingConfirmationKeystreatment.validatePWRlogged parse failures at debug level and returned, and theRetryCount/RetryIntervalconstants were never wired up, so a file read before Jellyfin finished flushing it was dropped with no trace. It now retries and logs at error level once it gives up.sendByIDreassignederrper contact method with every error check commented out, and returnednilwhen a user had no contact method at all. Callers treated that as success, so a reset was logged as sent when nothing went out. Errors are now collected per method and a missing contact method returnsErrNoContactMethod.mj-rawis not processed insidemj-button, so the tag survived MJML compilation and reached mail clients wrapping the button label. Clients strip unknown elements, leaving the button with no text.Test plan
go build ./...cleango test ./...passing, including the email construction testscaptcha_test.gocovering the bypass, invite and PWR paths, and concurrent map accessverifyCaptchaand pass with the fixgo test -raceclean on the captcha testsmj-tags survive in the outputKnown and not fixed here
Go's
html/templatestrips HTML comments, and MJML relies on Outlook conditional comments. Onpassword-reset.htmlthat removes all 24 conditional blocks (18.2 KB to 13.3 KB), so MSO layout is broken in every email. This is upstream jfa-go behaviour, not a regression, and Gmail is unaffected. Fixing it means parsing HTML emails withtext/templateand escaping injected data by hand.