-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wire: remove erroneous witness size check in wire parsing #1896
Conversation
Pull Request Test Coverage Report for Build 3216248240
💛 - Coveralls |
tACK |
In this commit, we fix a bug that would cause nodes to be unable to parse a given block from the wire. The block would be properly accepted if fed in via other mechanisms. The issue here is that the old checks for the maximum witness size, circa segwit v0 where placed in the wire package _as well_ as the tx engine. This check should only be in the engine, since it's properly gated by other related scrip validation flags. The fix itself is simple: limit witnesses only based on the maximum block size in bytes, or ~4MB.
7fdaf69
to
f523d4c
Compare
@@ -586,8 +587,9 @@ func (msg *MsgTx) BtcDecode(r io.Reader, pver uint32, enc MessageEncoding) error | |||
// item itself. | |||
txin.Witness = make([][]byte, witCount) | |||
for j := uint64(0); j < witCount; j++ { | |||
txin.Witness[j], err = readScript(r, pver, | |||
maxWitnessItemSize, "script witness item") | |||
txin.Witness[j], err = readScript( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering why we do not enforce the different size limits for the different segwit version here ? For v_0 we stay with 11kb and for v_1 4MB ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So that check is deeper in the consensus validation logic, this is a wire level DDoS defense limit/value.
We need a fast update to the newest lnd version as there was a security issue detected. lightningnetwork/lnd#7002 As the bug was part of the btcd dependencies the fix applied in btcsuite/btcd#1896 brings a long tail of dependency updates. This commit updates the dependencies and adapts for all changes that are introduced by this new dependencies.
In this commit, we fix a bug that would cause nodes to be unable to parse a given block from the wire. The block would be properly accepted if fed in via other mechanisms.
The issue here is that the old checks for the maximum witness size, circa segwit v0 where placed in the wire package as well as the tx engine. This check should only be in the engine, since it's properly gated by other related scrip validation flags.
The fix itself is simple: limit witnesses only based on the maximum block size in bytes, or ~4MB.