Exploiting The Lightning Bug Was The Ethical Choice

1 year ago

This is an sentiment editorial by Shinobi, a self-taught pedagogue successful the Bitcoin abstraction and tech-oriented Bitcoin podcast host.

For the 2nd clip successful astir a month, btcd/LND person had a bug exploited which caused them to deviate successful statement from Bitcoin Core. Once again, Burak was the developer who triggered this vulnerability — this clip it was intelligibly intentional — and erstwhile again, it was an contented with codification for parsing Bitcoin transactions supra the statement layer. As I discussed successful my piece connected the anterior bug that Burak triggered, earlier Taproot determination were limits connected however ample the publication and witnesser information successful a transaction could be. With the activation of Taproot, those limits were removed leaving lone the limitations connected the artifact size bounds itself to bounds these parts of idiosyncratic transactions. The occupation with the past bug was that contempt the information that the statement codification successful btcd was decently upgraded to bespeak this change, the codification handling peer-to-peer transmission — including parsing information earlier sending oregon erstwhile receiving — did not decently upgrade. So the codification processing blocks and transactions earlier it really got passed disconnected to beryllium validated for statement failed the data, ne'er passed it to the statement validation logic and the artifact successful question failed to ever beryllium validated.

A precise akin happening happened this time. Another bounds successful the peer-to-peer conception of the codebase was enforcing a regularisation connected the witnesser information incorrectly, limiting it to a maximum of 1/8 of the artifact size arsenic opposed to the afloat artifact size. Burak crafted a transaction with witnesser information conscionable a azygous value portion implicit the strict bounds and erstwhile again stalled btcd and LND nodes astatine that artifact height. This transaction was a non-standard transaction, which means that adjacent though it is perfectly valid by statement rules, it is not valid according to default mempool argumentation and truthful nodes volition not relay it crossed the network. It is perfectly imaginable to get it mined into a block, but the lone mode to bash truthful is to supply it straight to a miner, which is what Burak did with the assistance of F2Pool.

This truly drives location the constituent that immoderate portion of codification whose intent is to parse and validate Bitcoin information indispensable beryllium heavy audited successful bid to guarantee it is successful enactment with what Bitcoin Core volition do. It doesn’t substance if that codification is the statement motor for a node implementation oregon conscionable a portion of codification passing transactions astir for a Lightning node. This 2nd bug was literally close supra the 1 from past month successful the codebase. It wasn’t adjacent discovered by anyone astatine Lightning Labs. AJ Towns reported it connected October 11, 2 days aft the archetypal bug was triggered by Burak’s 998-of-999 multisig transaction. It was publically posted connected Github for 10 hours earlier being deleted. A hole was past made, but not released, with the volition to softly spot the contented successful the adjacent merchandise of LND.

Now, this is beauteous modular process for a superior vulnerability, particularly with a task similar Bitcoin Core wherever specified a vulnerability tin really origin superior harm to the base-layer network/protocol. But successful this circumstantial case, it presented a superior hazard to LND users’ funds, and fixed the information that it was virtually close adjacent to the anterior bug that had the aforesaid risks, the chances that it would beryllium recovered and exploited were precise high, arsenic demonstrated by Burak. This begs the question of whether the quiet-patch attack is the mode to spell erstwhile it comes to vulnerabilities similar this that tin permission users unfastened to theft of funds (because their node is near incapable to observe aged transmission states and decently penalize them).

As I went into successful my portion connected the past bug, if a malicious histrion had recovered the bugs earlier a well-intended developer, they could person tactically opened caller channels to susceptible nodes, routed the full contents of those channels backmost to themselves and past exploited the bug. From there, they would person those funds nether their power and besides been capable to adjacent the transmission with the archetypal state, virtually doubling their money. What Burak did successful actively exploiting this contented successful an ironic mode really protected LND users from specified an attack.

Once it was exploited, users were unfastened to specified attacks from preexisting peers with whom they already had unfastened channels, but they were nary longer susceptible of being targeted specifically with caller channels. Their nodes were stalled and would ne'er admit oregon process payments done channels idiosyncratic tried to unfastened aft the artifact that stalled their node. So portion it didn’t wholly region the hazard of users being exploited, it did bounds that hazard to radical they already had a transmission with. Burak’s enactment mitigated it. Personally I deliberation this benignant of enactment successful effect to the bug made sense; it constricted the damage, made users alert of the hazard and led to it being rapidly patched.

LND was besides not the lone happening affected. Liquid’s pegging process was besides broken, requiring updates to the federation’s functionaries to hole it. Older versions of Rust Bitcoin were affected arsenic well, which caused the stall to impact immoderate artifact explorers and electrs instances (an implementation of the backend server for Electrum Wallet). Now, with the objection of Liquid’s peg yet exposing funds to the exigency betterment keys held by Blockstream aft a timelock expiry — and, realistically successful the heist-style movie crippled wherever Blockstream stole these funds, everyone knows precisely who to spell aft — these different issues ne'er enactment anyone’s funds astatine hazard astatine immoderate point. Also, Rust Bitcoin had really patched this circumstantial bug successful newer versions, which seemingly didn’t pb to immoderate connection with maintainers of different codebases to item the imaginable for specified issues. It was lone the progressive exploitation of the bug unrecorded connected the web that wide exposed that the contented existed successful aggregate codebases.

This brings up immoderate large issues erstwhile it comes to vulnerabilities similar this successful Layer 2 bundle connected Bitcoin. First, the seriousness with which these codebases are audited for information bugs and however that is prioritized versus the integration of caller features. I deliberation it is precise telling that information is not ever prioritized fixed that this 2nd bug was not adjacent recovered by the maintainers of the codebase wherever it was present, adjacent though it was virtually close adjacent to the archetypal bug discovered past month. After 1 large bug that enactment users’ funds astatine risk, was nary interior audit of that codebase done? It took idiosyncratic from extracurricular the task to observe it? That does not show a precedence to safeguard users’ funds implicit gathering caller features to gully successful much users. Second, the information that this contented was already patched successful Rust Bitcoin demonstrates a deficiency of connection crossed maintainers of antithetic codebases successful regards to bugs similar this. This is beauteous understandable, arsenic being wholly antithetic codebases doesn’t marque idiosyncratic who recovered a bug successful 1 instantly think, “I should interaction different teams penning akin bundle successful wholly antithetic programming languages to pass them astir the imaginable for specified a bug.” You don’t find a bug successful Windows and past instantly deliberation to spell study the bug to Linux kernel maintainers. Bitcoin arsenic a protocol for distributed statement crossed a planetary web is simply a precise antithetic beast, however; possibly Bitcoin developers should commencement to deliberation on those lines erstwhile it comes to vulnerabilities successful Bitcoin software. Especially erstwhile it comes to parsing and interpreting information that is statement related.

Lastly, possibly erstwhile it comes to protocols similar Lightning, which beryllium connected observing the blockchain astatine each times to beryllium capable to respond to aged transmission states successful bid to support security, autarkic parsing and verification of information should beryllium kept to an implicit minimum — if not removed wholly and delegated to Bitcoin Core oregon information straight derived from it. Core Lightning is architected successful this way, connecting to an lawsuit of Bitcoin Core and depending wholly connected that for validation of blocks and transactions. If LND worked the aforesaid way, neither of these bugs successful btcd would person affected LND users successful a mode that enactment their funds astatine risk.

Whichever mode things are handled — either outsourcing validation wholly oregon simply minimizing interior validation and approaching it with overmuch much attraction — this incidental shows that thing needs to alteration successful approaching the contented of however Layer 2 bundle handles interacting with consensus-related data. Once again, everyone is precise fortunate that this was not exploited by a malicious actor, but alternatively by a developer proving a point. That being said, Bitcoin cannot number connected getting fortunate oregon hoping that malicious actors bash not exist.

Developers and users should beryllium focused connected improving the processes to forestall incidents similar this from happening again, and not playing the crippled of tossing astir blasted similar a blistery potato.

This is simply a impermanent station by Shinobi. Opinions expressed are wholly their ain and bash not needfully bespeak those of BTC Inc oregon Bitcoin Magazine.

View source