Background: An adversary can create a fake SP address reusing another owner's scan public key. If such an address is batched together with that owner's address, the owner's output may be ordered after the adversary's (resulting in an output with a k value > 0) and is then not found by the BIP352 scanning algorithm. This PR adds an API doc comment on the SP sending function to raise awareness of this issue.
Independently of Silent Payments, the general observation that it's the senders responsibility to ensure the recipient addresses belong to the owner seems trivial; if a recipient doesn't control the keys behind the provided address, the payment obviously fails. The crucial difference in the BIP-352 scenario with shared scan public keys is that the presence of incorrect recipient addresses could make payments to correct recipient addresses unfindable for the owner (not unspendable though), so this is worth to point out explicitly.
Note that the issue only exists if the incorrect addresses have a lower k value than the correct ones, so we could e.g. recommend to to put all recipients that are known to be correct in an earlier recipient position, but that might be a level of detail that is creating even more confusion. At the moment the SP ecosystem seems to be far away from multi-party sending, so it seems reasonable to give a conservative recommendation and possibly re-evaluate that at a later point.
A very restrictive alternative could be to limit the group size to 1 (i.e. effectively only ever creating k=0 outputs) to be on the safe side, but this suggestion didn't have consensus for the BIP-352 authors, and I don't think the libsecp256k1 implementation should be more restrictive than the BIP. An in-between solution could be to e.g. introduce a "dangerous" flag parameter that has to be set to allow group sizes of > 1, or introduce a safer variant of _sender_create_outputs with that limitation, but I'm not sure if it's worth it to extend/change the API at this point.
See also Ruben's write-up for a more detailed description of the problem and potential future mitigations. The various AI scanner findings are included as a comment below there for additional context.
Thanks to l0rinc for first finding this issue (PRed in Bitcoin Red Team's bitcoin-security-council/secp256k1 repository on Sep. 19th). Similar vulnerability reports were later submitted by the Anthropic OSS scanner (Oct. 16th) and Project Loupe (Oct. 29th).