#3842·sure

AI merchant detection lets a family's own transaction text create/enrich shared ProviderMerchant records

Author: gfr-freeCreated Sep 29, 2026Updated Sep 29, 2026

Problem

Family::AutoMerchantDetector#find_or_create_ai_merchant (app/models/family/auto_merchant_detector.rb:119) creates a globally-shared ProviderMerchant (source: "ai") using an LLM's business_name/business_url output. That output is derived from transactions_input, which is built from transaction.entry.name and transaction.entry.notes — fields a family fully controls (app/models/family/auto_merchant_detector.rb:84-92).

A family that crafts a transaction description to steer the LLM's extraction can get a ProviderMerchant created or matched with an attacker-chosen name/website, which is then visible to and can be matched/reused by every other family (via find_by(website_url:) / find_by(source: "ai", name:)), and can drive a Brandfetch-derived logo_url (build_logo_url). The related enhance_provider_merchant path (Case 2) similarly lets AI-derived website_url/logo_url fill in a blank field on an existing non-AI shared ProviderMerchant.

This is the same class of issue closed for the import and manual-edit paths in #3824 (a family's own input should not be able to mutate a merchant record shared with other families) — surfaced by @jjmata in review on that PR. It's a different subsystem (AI merchant detection, not import/edit), so it wasn't folded into that fix.

Related but distinct: #3193 proposes an "existing merchants only" mode motivated by hallucination risk from small/local models; it would also close this hole for instances that opt into it, but doesn't address the default (trusted-model) case where the attack is a deliberately crafted description rather than model hallucination.

Direction

Dedupe/reuse source: "ai" ProviderMerchants only within merchants already assigned to the family's own transactions, instead of a global find_by(name:)/find_by(website_url:) lookup — i.e. route through a family-scoped path, at the cost of losing today's cross-family reuse/enrichment of AI-detected merchants.