Skip to content

v0.6.11 - Fix password reset link poisoning - #161

Merged
bscott merged 2 commits into
mainfrom
v0.6.11
Nov 3, 2026
Merged

bscott merged 2 commits into
mainfrom
v0.6.11

Conversation

@bscott

@bscott bscott commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Summary

Fixes password reset link poisoning in the unauthenticated forgot-password flow.

When no Base URL was configured, ForgotPassword built the emailed reset link with buildBaseURL(). That function falls back to the request's X-Forwarded-Host, X-Forwarded-Proto and Host headers. Anyone who could reach SubTrackr could send a reset request with a forged host. The administrator would then receive a genuine reset email whose link delivered the reset token to the attacker's domain, which could lead to account takeover. The plain Host header was exploitable too, so directly exposed installs were affected as well as proxied ones. Installs with a Base URL configured were not affected.

Changes

  • The reset link is built only from the configured Base URL, never from request headers. The link is HTML-escaped.
  • Without a Base URL, the email contains the site-relative path (/reset-password?token=…) to open on your own SubTrackr address, so reset keeps working. The example address in that email deliberately omits the token so mail clients cannot auto-link it to a foreign host.
  • SMTP failures are logged instead of being shown to unauthenticated callers.
  • Email configuration is checked before a token is issued, so a request that cannot send email no longer replaces an outstanding reset token.
  • AuthHandler depends on a one-method emailSender interface so the email can be captured in tests. The constructor is unchanged.

Email header injection through notification subjects

While reviewing the open advisory GHSA-72v4-3xcj-2m8c, I found that notification email subjects include subscription names unsanitized. Any API key holder can set a name containing CR/LF, which could inject headers or replace the body and Content-Type of emails sent to the administrator. This is a phishing vector from the admin's own SubTrackr.

  • One buildEmailMessage helper is shared by the TLS and STARTTLS paths.
  • Line breaks are stripped from every header value. The subject and sender name are RFC 2047 encoded, which also fixes non-ASCII subjects.
  • Tests cover injected Bcc and body replacement, non-ASCII and long subjects, and configured addresses. Confirmed the injection test fails against the previous code.

The advisory's stored XSS (calendar and category names) was already fixed in v0.6.10 (4b05244, c787c4f) with Playwright coverage.

Test Plan

  • New end-to-end handler tests send forged Host, X-Forwarded-Host, Forwarded and X-Original-Host headers. They assert the email never contains the attacker host and that the emailed token still validates, with and without a Base URL.
  • Confirmed the main regression test fails against the previous code (the email linked to https://attacker.example/reset-password?token=…).
  • Tests for escaping, the blank Base URL fallback, hidden SMTP details, token preservation when SMTP is not configured, and a nil email sender.
  • go build ./..., go vet ./... and go test -race ./... pass locally.
  • Independent security review found no blockers. Its in-scope suggestions are included.
  • CI green.
  • Manual check: forgot-password email with and without a Base URL.

Follow-ups (not in this release)

Credit

The password reset link poisoning issue was reported by Maxim (@MaxKUlish1). Thank you for the careful report and responsible disclosure.

@claude

claude Bot commented Nov 2, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

- Build the password reset link only from the configured Base URL, never
  from Host or X-Forwarded-Host request headers
- Without a Base URL, email the site-relative reset path instead of an
  absolute link derived from the request
- Log SMTP failures instead of returning them to unauthenticated callers
- Check email configuration before issuing a reset token
- Add regression tests covering forged Host, X-Forwarded-Host, Forwarded
  and X-Original-Host headers
Notification subjects include subscription names, which any API key
holder can set. A name containing CR/LF could inject headers or replace
the body and Content-Type of emails sent to the administrator.

- Build the message in one helper shared by the TLS and STARTTLS paths
- Strip line breaks from every header value
- RFC 2047 encode the subject and sender name, which also fixes
  non-ASCII subjects
- Add tests for injected headers and body, non-ASCII subjects and
  configured addresses
@MaxKUlish1

Copy link
Copy Markdown

Hi! I'm Maxim (@MaxKUlish1), the researcher who reported this issue.

Just confirming that this is my GitHub account :)

Thank you so much for confirming the vulnerability and preparing the fix so quickly!

@bscott
bscott merged commit c854347 into main Nov 3, 2026
2 checks passed
@bscott
bscott deleted the v0.6.11 branch November 3, 2026 17:10
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.

2 participants