From b4dbc18b009632d4072da78df3e98bcefe9714f8 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 29 Sep 2026 14:34:11 +0000 Subject: [PATCH] Fix error handling for malformed webfinger subjects (#40731) --- app/services/activitypub/process_account_service.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb index 8da3b01d65..3c08415ba8 100644 --- a/app/services/activitypub/process_account_service.rb +++ b/app/services/activitypub/process_account_service.rb @@ -157,6 +157,7 @@ class ActivityPub::ProcessAccountService < BaseService confirmed_username, confirmed_domain = split_acct(webfinger.subject) raise Error, "Unsupported username format in webfinger response for #{@username}@#{@domain}" unless Account::USERNAME_ONLY_RE.match?(confirmed_username) + raise Error, "Malformed subject (#{webfinger.subject}) in webfinger response for #{@username}@#{@domain}" if confirmed_username.blank? || confirmed_domain.blank? if @username.casecmp(confirmed_username).zero? && @domain.casecmp(confirmed_domain).zero? raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.self_link_href != @uri @@ -172,6 +173,7 @@ class ActivityPub::ProcessAccountService < BaseService raise Webfinger::RedirectError, "Too many webfinger redirects for URI #{@uri} (stopped at #{@username}@#{@domain})" unless confirmed_username.casecmp(@username).zero? && confirmed_domain.casecmp(@domain).zero? raise Error, "Webfinger response for #{@username}@#{@domain} does not loop back to #{@uri}" if webfinger.self_link_href != @uri raise Error, "Unsupported username format in webfinger response for #{@username}@#{@domain}" unless Account::USERNAME_ONLY_RE.match?(@username) + raise Error, "Malformed subject (#{webfinger.subject}) in webfinger response for #{@uri}" if @username.blank? || @domain.blank? @webfinger_verified = true rescue Webfinger::RedirectError => e