Bitcoin Heist Explained: Transaction Malleability Attack

Bitcoin Heist Explained: Transaction Malleability Attack

Bitcoin Heist Explained: Transaction Malleability Attack

Bitcoin Heist Explained: Transaction Malleability Attack

Bitcoin Heist Explained: Transaction Malleability Attack

Read Time: 4 minutes

The infamous Mt. Gox theft stands as a significant event in the history of cryptocurrency, with a staggering loss of 850,000 bitcoins when bitcoin prices were ascending rapidly.  

But what was the attack that shattered investor confidence in BTC and posed such a high threat to crypto holdings? 

The answer lies in an intricate attack strategy known as “Transaction Malleability attack.” This blog aims to provide a comprehensive understanding of this attack, its implications, and how it compromises the integrity of system security.

What is Transaction Malleability?

‘Transaction malleability’ is a potential threat where an attacker manipulates the TX ID of a Bitcoin transaction before its validation. Such manipulation of the TXID consequently alters the hash, rendering the original TXID ineffective.

Despite all the transaction conditions being in place, the attacker can alter the scriptSig component in the transaction, making it appear that the transaction didn’t happen.

Understanding The Intricacies Of Transaction Malleability Attack

Understanding a Bitcoin transaction’s flow is critical to comprehending the scope of this attack. If a user initiates any transaction, it is recorded in the blockchain and miners in the network validate them. The transaction generally includes crucial details such as the receiver’s address, input amount, and more.

Each transaction is uniquely identifiable via its transaction ID, or TXID produced through a hashing function that encompasses all the transaction’s details. It is essential to understand that even the slightest change in the transaction details can drastically modify the hash, creating a new TX ID. But what changes can an attacker instigate in a transaction that is already signed and hashed?

Let’s look at the basics of mutating a transaction. 

Performing Transaction Malleability

The Bitcoin derivative blockchains utilize elliptic curve digital signatures wherein random value ‘r’ computes the signature ‘S’ based on the input message ‘m’. This invariably means a third party who knows the secret signing key can produce multiple valid Signatures, such as S1, S2, S3, etc. 

Even worse, without knowing the secret signing key, the party can still derive a valid signature on message ‘m’ and tweak the signature in the transaction. As a result, altering the signature of T1 results in a change in hash and reproduces an entirely different TXID for T1.

Another way is script malleability which relates to modifying the script words. The scriptSig part is not signed in a transaction allowing the attacker to add script words. Including script words leaves the stack and its execution unchanged. However, the changes in the transaction script induce the creation of a new hash and, thus, a different transaction ID.

Now, let’s look at the transaction malleability attack with an example.

  • Let’s assume Alice runs a BTC exchange and Bob, who has funds on the exchange, wants to withdraw.
  • Bob requests the withdrawal amount from Alice. 
  • Alice sends the withdrawal amount to Bob while the blockchain creates this transaction.
  • The miners must confirm the transaction to be added to the current block. 
  • But before that, Bob plans on performing transaction malleability. Therefore he modifies the transaction details, which effectively alters the hash. 
  • Thus, a new transaction ID is created, which gets validated first by the miners before the actual unchanged TXID. 
  • Bob recreated the transaction with the new ID, which is added to the blocks after the confirmation by miners.
  • Bob now claims to Alice that he did not receive the funds.
  • Alice checks the blockchain for the original TXID, but it doesn’t exist.
  • So, she again initiates the transfer of BTC to Bob for the second time.

Generally, transaction malleability uses the original content and introduces some slight and harmless mutations while retaining the transaction signature valid. The mutated transaction is then relayed back to the network with a different TX ID for it to be validated by miners in the network. 

Previous Incidents

Mt Gox Hack

As mentioned earlier, the Mt Gox hack in 2014 remains the largest crypto theft in history for the profound loss of 850k BTC (6% of all the bitcoins at the time). 

Investigations revealed the existence of a currency-wide vulnerability called “transaction malleability” is the reason for the crypto theft. For a long time, since 2011, by exploiting the vulnerability, many users altered the transaction managing to claim from the exchange the particular transaction didn’t happen and persuade to send money again. 

Bitstamp hack

Bitstamp, another Bitcoin exchange, felt the tremors of transaction malleability bug immediately after the Mt. Gox hack. The team halted all operations for an immediate bug fix. 

Some Light On Security

Do these attacks indicate the inefficiency of Bitcoin technology? Absolutely not. Such instances of attacks serve to foster further security developments in the technology.

Bitcoin derivatives such as Bitcoin, Bitcoin Cash, and Litecoin, which lack SegWit support, are highly susceptible to transaction malleability. Implementing Segregated Witness (SegWit), which separates transaction signature and script (witness data) from transaction content, can help mitigate such vulnerabilities.

Furthermore, maintaining comprehensive bookkeeping records of fund transfers from an exchange can help recover bitcoins wrongly sent twice.

About QuillAudits

QuillAudits has an extensive portfolio, securing over 850 projects and $16B in funds, positioning us as a leader in web3 industry security. Our team of experts stands ready to assist those aiming to establish a secure web3 framework.

Connect with our experts for any web3 security assistance now!

2,044 Views

Blockchain for dog nose wrinkles' Ponzi makes off ~$127M🐶

Project promised up to 150% returns on investment in 100 days, raising about 166.4 billion South Korean won — or about $127 million — from 22,000 people.

Latest blogs for this week

Understanding Fuzzing and Fuzz Testing: A Vital Tool in Web3 Security

Read Time: 5 minutes When it comes to smart contracts, ensuring the robustness and security of code is paramount. Many techniques are employed to safeguard these contracts against vulnerabilities
Read More

How EigenLayer’s Restaking Enhances Security and Rewards in DeFi

Read Time: 7 minutes Decentralized finance (DeFi) relies on Ethereum staking to secure the blockchain and maintain consensus. Restaking allows liquid staking tokens to be staked with validators in
Read More

ERC 404 Standard: Everything You Need to Know

Read Time: 7 minutes Introduction Ethereum has significantly shaped the crypto world with its introduction of smart contracts and decentralized applications (DApps). This has led to innovative developments in
Read More

DNS Attacks:  Cascading Effects and Mitigation Strategies

Read Time: 8 minutes Introduction DNS security is vital for a safe online space. DNS translates domain names to IP addresses, crucial for internet functionality. DNS ensures unique name-value
Read More

EIP-4844 Explained: The Key to Ethereum’s Scalability with Protodanksharding

Read Time: 7 minutes Introduction  Ethereum, the driving force behind dApps, has struggled with scalability. High fees and slow processing have limited its potential. They have kept it from
Read More

QuillAudits Powers Supermoon at ETH Denver!

Read Time: 4 minutes Calling all the brightest minds and leaders in the crypto world! Are you ready to build, connect, and innovate at the hottest event during ETH
Read More

Decoding the Role of Artificial Intelligence in Metaverse and Web3

Read Time: 7 minutes Introduction  Experts predict a transformative shift in global software, driven by AI and ML, marking the dawn of a new era. PwC predicts AI will
Read More

Transforming Assets: Unlocking Real-World Asset Tokenization

Read Time: 7 minutes In the blockchain, real-world assets (RWAs) are digital tokens that stand for tangible and conventional financial assets, including money, raw materials, stocks, and bonds. As
Read More
Scroll to Top

Become a Quiffiliate!
Join our mission to safeguard web3

Sounds Interesting, Right? All you have to do is:

1

Refer QuillAudits to Web3 projects for audits.

2

Earn rewards as we conclude the audits.

3

Thereby help us Secure web3 ecosystem.

Total Rewards Shared Out: $200K+