Hi Poinsot,
> Could you please clearly describe the "attack" with a clear threat model? I don't think what you describe is an issue under any
> realistic threat model, much less how it would only materialize with BIP54's sigop limit but not with the existing sigop limit.
Yes, for sure. So let's say you have a Coinjoin collaborated among 10 pseudonymous peers (...they rely as much as they can on
the chain as the source of truth to preserve the overall pseudonymity so hardness to evaluate "trustworthiness" of a specific peer),
where there is a single peer randomly designated as the coordinator. Each peer contributes an input towards the common transaction.
Let says the 1st participant is the coordinator, the 2nd to 9th participant are participants only contributing P2WPKH, for which
the new MAX_TX_LEGACY_SIGOPS is not a problem at all. The 10th participant deliberately contribute a legacy input with empty junk
OP_CHECKMULTISIGs for them to be accounted at MAX_PUBKEYS_PER_MULTISIG while being space-wise efficient.
This legacy input is of minimal satoshi value (<= to inputs 1th to 9th while still > to Coinjoin protocol-defined limit),
so the cost for the malicious 10th participant is minimized. All the inputs are assembled together in the multi-party transaction,
however this transaction is now policy invalid in reason of MAX_TX_LEGACY_SIGOPS due to the single redeem script contributed by
the 10th input.
In the lack of awareness of the policy rule by the coordinator, or by any participant if the Coinkoin protocol is fully distributed
among participants, identifying the source of error can be a hard task. Unless the latest flavour of the policy rules are run, it
might be just a generic policy error caught by the coordinator, or even worst if the transaction is just flow with a raw TX message,
in the lack of REJCT msgs to discover the source of non-propagation.
Of course there is always the option to bypass the policy rules by reaching out to a miner private API, though if you''re doing
a coinjoin it is less than optimal to maximize confidentiality of the flow.
Note this threat model has been already considered in the past here:
that://
diyhpl.us/~bryan/irc/bitcoin/bitcoin-dev/linuxfoundation-pipermail/lightning-dev/2021-May/003033.txtThose are the reasons e.g for lightning only segwit inputs are accepted to be contributed for a collaborative transaction and
other limits are checked to sanitize the flow towards policy rule ("MAY fail the negotiation if `script` is non-standard" at
`tx_add_output` reception).
Currently, the problem would exist though only if the built Coinjoin transaction would have more than 80k sigops. The reduction
to MAX_TX_LEGACY_SIGOPS is somehow a corresponding reduction in the cost to mount that DoS attack for an adversary. I think it's
cheaper fee-wise to contribute an input to reach the ~2500 limit, than the upper 80k limit itself.
In my view, it's not really the responsibility of a full-node to care about that kind of issues for downstream softwares. However,
mentioning in release notes that the limit might affect tx collaborative construction for downstream softwares devs and that action
might have to be taken at their appreciation (as they're the ones with the best know-how about their protocols) can be a courteous
note. IMHO, assuming those kinds of threat models are realistic, it would be welcome to be more verbose everytime there is a
_tightening_ of the policy rules. Even if the _tightening_ is in view of a future consensus change, there are all the transitory
phase during which there are more exposures to those kinds of DoS.
> The BIP54 specifications are written from the perspective of an implementer and clearly states "count the number of [sigops] in
> the input scriptSig and previous output's scriptPubKey". Signature operations in these fields preceded Segwit (which requires the
> scriptSig to be empty and the prevout's scriptPubKey to be pushonly).
Yes, I read again BIP141 around writing my previous email. BIP141 clearly says that "a push of a version byte, plus a push of a
witness program. The scriptSig must be exactly empty or validation fails." So unless you have a different validation logic which
is introduced in an unknown future for any segwit spends (OP_01 to OP_16 version byte + a push of the witness program), I don't
see how the limit could be understood to be applied to segwit spends, and more concerning implemented by mistake to concern segwit
spends. For bitcoin core, the code is very proper here in `VerifyScript` and commented accordingly.
I'm still thinking it would be good BIP stylistic to have BIP54 making an explicit referral to BIP141 to define "legacy" inputs
by opposition to "segwit" inputs, which have a precise technical definition. Less a BIP is ambiguous, better it is.
> Any remotely sane transaction would run into the standardness size limit before running into this limit.
No, I'm not sure of that. I was having fun recently with scriptsig junking transaction leveraring OP_CHECKMULTISIG:
https://github.com/ariard/bitcoin/commit/b85a426c43cb7000788a55ea140b73a68da9ce4e#diff-a304e75247f1546b60976116a600cacfd9d020fa4d38110b07610bb74b756547R42It sounds you can generate transaction which are perfectly standard (i.e under MAX_STANDARD_TX_WEIGHT) with a very high
number of sigops stuffed within. I don't remember checking all the policy rule scenarios, but MAX_STANDAD_TX_WEIGHT is
one of the rule you _cannot_ disable or turn off on the CLI iirc.
Best,
Riard
OTS hash: 91fad050b8b9ffdc0a25f997cc6f77e701e039ba4415a9a7cfe7809f1aafac71