Bitcoin Forum
November 11, 2024, 04:34:02 PM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 »  All
  Print  
Author Topic: The MtGox Debacle Explained  (Read 15788 times)
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 06:56:19 PM
 #1

Currently, there's too much Fear Uncertainty and Doubt.

TL;DR version:

1) The withdrawal problems at MtGox are technical.
2) It is likely that a hacker exploit has taken place.
3) Any damage is likely to be limited.
4) Other exchanges need a heads up and could also be vulnerable.
5) MtGox is going through all erroneous transactions and will update all balances. This is the reason why BTC withdrawals are frozen.
6) Countermeasures need to be taken (for all exchanges)

BTC Withdrawal Problems
------------------------
A couple of weeks ago (around January 26-28) I noticed that things at MtGox were not the way it supposed to be. Normally, withdrawing BTC is an instant process. This time my withdrawals went stuck. MtGox provides an API so that transactions that didn't get through were available for public scrutiny: https://data.mtgox.com/api/0/bitcoin_tx.php.
I took my stuck transactions which were available in raw format and try to rebroadcast them manually. (MtGox no longer publishes the raw format; they are now redacted for a very good reason.) To my surprise it complained that some of the transaction inputs were already spent. Furthermore, this happened to many of my friends as well. I investigated their transactions as well and tried to rebroadcast them manually, but without luck due to complaints of double spending.
My immediate (now wrong) conclusion was that MtGox F-d up big time and couldn't handle a simple concurrency problem. If several people are withdrawing BTC at the same time it is important to ensure that this is counted as an atomic operation so that coins from the wallet pool are not double spent. It turns out that it was much more interesting than I've first anticipated. Another (wrong) conspiracy theory of mine that MtGox did this intentionally to cover up the fact that they were running low on BTC as they use "fractional reserve bitcoin".

Exchanges and Custom Wallet Software
--------------------------------------
Most exchanges have completely custom bitcoin software. Either they are heavily modified source code of the official client, or everything is written from scratch. To my best knowledge MtGox has written their client completely from scratch. Some people critize them for that, but the standard client is not scalable to an exchange with a million of customers. You must modify the original source so at least the wallet part is going through a more suitable database, and also the built-in security only works for a single customer.
The cons with writing your own custom bitcoin client are of course that you would from time to time become out of sync with the official client. It turns out that this is very problematic.

Erroneous Transactions and Fatal Consequences
----------------------------------------------
Suppose there's something that is inconsistent with MtGox client software with the rest of the bitcoin network. What would be the outcome of that? MtGox would broadcast the transaction to the bitcoin network and miners would reject it, so the transaction becomes stuck. After a couple of days, MtGox gives up because it can't get the transaction published in the blockchain so it returns the balance to the customer. This turns out to be VERY dangerous. BTC should not be returned to a customer without proper investigation.
You may ask why?  A hacker can exploit the erroneous transactions broadcasted by MtGox by modifying them manually (so they become consistent with the official bitcoin software) and then rebroadcast them manually her/him-self. If this happens, then the stuck transaction (at MtGox) gets actually through and at the same time the balance is returned to the customer's account. Therefore, the customer has doubled her/his BTC withdrawal attempt. If you repeat this process a couple of times then you can empty MtGox BTC vault without having to hack into their computers.
So what about all those erroneous transactions with "double spending", surely this has nothing to do with the erroneous transactions mentioned recently? At the time the hacker broadcasts the modified (correct) transaction based on MtGox erroneous one, the transaction gets through, but MtGox still thinks the coins are still unspent. After all, it is only MtGox that has the private keys, so it is impossible (in general) that someone else can spend them. Therefore, MtGox still thinks those coins are unspent and trying to reuse them as fresh coins for other transactions. This explains why we had so many transactions that tried to double spend coins.

What is MtGox Doing Now?
-------------------------
First, the hackers that tried to modify the erroneous transactions and rebroadcast them manually are likely identified (MtGox surely knows the name of every customer). Their accounts will likely to be frozen.
Second, MtGox has an accounting mess to clean up. There are many transactions registered as unsuccessful at MtGox that need to be checked whether they actually went through or not. Then MtGox needs to update all the BTC balances. This will likely take a couple of days and this is the main reason why all BTC withdrawals are blocked at this time. Once this is done MtGox will open for BTC withdrawals again.

Lessons Learned and Countermeasures
-------------------------------------
What happened at MtGox can happen at other exchanges as well.  So how do we prevent these disasters from happening again in future?  I have some proposals,
1) Try to stay close to the official bitcoin client and merge in new changes as soon as possible. Stay updated.
2) Bitcoin Foundation could setup some public servers that always run the latest official version of the bitcoin client. Exchanges should then be able to verify that the transaction is legitimate to the latest bitcoin client before broadcasting them.
3) At an exchange, when a transaction becomes stuck for whatever reason, always check if some other transaction with the same inputs and outputs has already been accepted by the network before returning the customers' balance.
smoothie
Legendary
*
Offline Offline

Activity: 2492
Merit: 1474


LEALANA Bitcoin Grim Reaper


View Profile
February 09, 2014, 07:01:38 PM
 #2

You failed to mention the possibility that they are lying about it being a technical problem and that they do not have all the funds they claim to (I.e. Solvency).

Don't be naive to think that this is not a possibility.

Ponzi operators work in the exact same manner. They try to buy more time with vague excuses.

███████████████████████████████████████

            ,╓p@@███████@╗╖,           
        ,p████████████████████N,       
      d█████████████████████████b     
    d██████████████████████████████æ   
  ,████²█████████████████████████████, 
 ,█████  ╙████████████████████╨  █████y
 ██████    `████████████████`    ██████
║██████       Ñ███████████`      ███████
███████         ╩██████Ñ         ███████
███████    ▐▄     ²██╩     a▌    ███████
╢██████    ▐▓█▄          ▄█▓▌    ███████
 ██████    ▐▓▓▓▓▌,     ▄█▓▓▓▌    ██████─
           ▐▓▓▓▓▓▓█,,▄▓▓▓▓▓▓▌          
           ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌          
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓─  
     ²▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╩    
        ▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀       
           ²▀▀▓▓▓▓▓▓▓▓▓▓▓▓▀▀`          
                   ²²²                 
███████████████████████████████████████

. ★☆ WWW.LEALANA.COM        My PGP fingerprint is A764D833.                  History of Monero development Visualization ★☆ .
LEALANA BITCOIN GRIM REAPER SILVER COINS.
 
steadymobbin
Newbie
*
Offline Offline

Activity: 25
Merit: 0


View Profile
February 09, 2014, 07:29:31 PM
 #3

Currently, there's too much Fear Uncertainty and Doubt.

TL;DR version:

1) The withdrawal problems at MtGox are technical.
2) It is likely that a hacker exploit has taken place.
3) Any damage is likely to be limited.
4) Other exchanges need a heads up and could also be vulnerable.
5) MtGox is going through all erroneous transactions and will update all balances. This is the reason why BTC withdrawals are frozen.
6) Countermeasures need to be taken (for all exchanges)

BTC Withdrawal Problems
------------------------
A couple of weeks ago (around January 26-28) I noticed that things at MtGox were not the way it supposed to be. Normally, withdrawing BTC is an instant process. This time my withdrawals went stuck. MtGox provides an API so that transactions that didn't get through were available for public scrutiny: https://data.mtgox.com/api/0/bitcoin_tx.php.
I took my stuck transactions which were available in raw format and try to rebroadcast them manually. (MtGox no longer publishes the raw format; they are now redacted for a very good reason.) To my surprise it complained that some of the transaction inputs were already spent. Furthermore, this happened to many of my friends as well. I investigated their transactions as well and tried to rebroadcast them manually, but without luck due to complaints of double spending.
My immediate (now wrong) conclusion was that MtGox F-d up big time and couldn't handle a simple concurrency problem. If several people are withdrawing BTC at the same time it is important to ensure that this is counted as an atomic operation so that coins from the wallet pool are not double spent. It turns out that it was much more interesting than I've first anticipated. Another (wrong) conspiracy theory of mine that MtGox did this intentionally to cover up the fact that they were running low on BTC as they use "fractional reserve bitcoin".

Exchanges and Custom Wallet Software
--------------------------------------
Most exchanges have completely custom bitcoin software. Either they are heavily modified source code of the official client, or everything is written from scratch. To my best knowledge MtGox has written their client completely from scratch. Some people critize them for that, but the standard client is not scalable to an exchange with a million of customers. You must modify the original source so at least the wallet part is going through a more suitable database, and also the built-in security only works for a single customer.
The cons with writing your own custom bitcoin client are of course that you would from time to time become out of sync with the official client. It turns out that this is very problematic.

Erroneous Transactions and Fatal Consequences
----------------------------------------------
Suppose there's something that is inconsistent with MtGox client software with the rest of the bitcoin network. What would be the outcome of that? MtGox would broadcast the transaction to the bitcoin network and miners would reject it, so the transaction becomes stuck. After a couple of days, MtGox gives up because it can't get the transaction published in the blockchain so it returns the balance to the customer. This turns out to be VERY dangerous. BTC should not be returned to a customer without proper investigation.
You may ask why?  A hacker can exploit the erroneous transactions broadcasted by MtGox by modifying them manually (so they become consistent with the official bitcoin software) and then rebroadcast them manually her/him-self. If this happens, then the stuck transaction (at MtGox) gets actually through and at the same time the balance is returned to the customer's account. Therefore, the customer has doubled her/his BTC withdrawal attempt. If you repeat this process a couple of times then you can empty MtGox BTC vault without having to hack into their computers.
So what about all those erroneous transactions with "double spending", surely this has nothing to do with the erroneous transactions mentioned recently? At the time the hacker broadcasts the modified (correct) transaction based on MtGox erroneous one, the transaction gets through, but MtGox still thinks the coins are still unspent. After all, it is only MtGox that has the private keys, so it is impossible (in general) that someone else can spend them. Therefore, MtGox still thinks those coins are unspent and trying to reuse them as fresh coins for other transactions. This explains why we had so many transactions that tried to double spend coins.

What is MtGox Doing Now?
-------------------------
First, the hackers that tried to modify the erroneous transactions and rebroadcast them manually are likely identified (MtGox surely knows the name of every customer). Their accounts will likely to be frozen.
Second, MtGox has an accounting mess to clean up. There are many transactions registered as unsuccessful at MtGox that need to be checked whether they actually went through or not. Then MtGox needs to update all the BTC balances. This will likely take a couple of days and this is the main reason why all BTC withdrawals are blocked at this time. Once this is done MtGox will open for BTC withdrawals again.

Lessons Learned and Countermeasures
-------------------------------------
What happened at MtGox can happen at other exchanges as well.  So how do we prevent these disasters from happening again in future?  I have some proposals,
1) Try to stay close to the official bitcoin client and merge in new changes as soon as possible. Stay updated.
2) Bitcoin Foundation could setup some public servers that always run the latest official version of the bitcoin client. Exchanges should then be able to verify that the transaction is legitimate to the latest bitcoin client before broadcasting them.
3) At an exchange, when a transaction becomes stuck for whatever reason, always check if some other transaction with the same inputs and outputs has already been accepted by the network before returning the customers' balance.


Hey thanks for the update!  How do you have access to this info? 
notig
Sr. Member
****
Offline Offline

Activity: 294
Merit: 250


View Profile
February 09, 2014, 07:36:59 PM
 #4

You failed to mention the possibility that they are lying about it being a technical problem and that they do not have all the funds they claim to (I.e. Solvency).

Don't be naive to think that this is not a possibility.

Ponzi operators work in the exact same manner. They try to buy more time with vague excuses.

So the proper way to run a ponzi scheme is to broadcast failed transactions for all the world to see? Thanks that is good to know. The brilliance of people here is staggering.
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 07:39:31 PM
 #5

Thanks for your support. Unfortunately, I cannot reveal my sources.
steadymobbin
Newbie
*
Offline Offline

Activity: 25
Merit: 0


View Profile
February 09, 2014, 07:56:44 PM
 #6

Thanks for your support. Unfortunately, I cannot reveal my sources.

Understood.  Is it safe to say that for someone with some BTC in Gox, they should be somewhat comforted in the fact that the problem is identified and being worked on and they will receive their coins back in the near future?
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 08:04:09 PM
 #7

Thanks for your support. Unfortunately, I cannot reveal my sources.

Understood.  Is it safe to say that for someone with some BTC in Gox, they should be somewhat comforted in the fact that the problem is identified and being worked on and they will receive their coins back in the near future?

I'm pretty sure that this is the case. Once they resolved all the transactions everything will return to normal. However, I fully understand people who lost faith in MtGox; it's a very natural reaction.
 
smoothie
Legendary
*
Offline Offline

Activity: 2492
Merit: 1474


LEALANA Bitcoin Grim Reaper


View Profile
February 09, 2014, 08:39:15 PM
 #8

You failed to mention the possibility that they are lying about it being a technical problem and that they do not have all the funds they claim to (I.e. Solvency).

Don't be naive to think that this is not a possibility.

Ponzi operators work in the exact same manner. They try to buy more time with vague excuses.

So the proper way to run a ponzi scheme is to broadcast failed transactions for all the world to see? Thanks that is good to know. The brilliance of people here is staggering.

If it buys them time why not?

They just claim the issue is "technical" which is vague BS for saying we need more time.

███████████████████████████████████████

            ,╓p@@███████@╗╖,           
        ,p████████████████████N,       
      d█████████████████████████b     
    d██████████████████████████████æ   
  ,████²█████████████████████████████, 
 ,█████  ╙████████████████████╨  █████y
 ██████    `████████████████`    ██████
║██████       Ñ███████████`      ███████
███████         ╩██████Ñ         ███████
███████    ▐▄     ²██╩     a▌    ███████
╢██████    ▐▓█▄          ▄█▓▌    ███████
 ██████    ▐▓▓▓▓▌,     ▄█▓▓▓▌    ██████─
           ▐▓▓▓▓▓▓█,,▄▓▓▓▓▓▓▌          
           ▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌          
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓─  
     ²▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓╩    
        ▀▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▀       
           ²▀▀▓▓▓▓▓▓▓▓▓▓▓▓▀▀`          
                   ²²²                 
███████████████████████████████████████

. ★☆ WWW.LEALANA.COM        My PGP fingerprint is A764D833.                  History of Monero development Visualization ★☆ .
LEALANA BITCOIN GRIM REAPER SILVER COINS.
 
HairyMaclairy
Legendary
*
Offline Offline

Activity: 1414
Merit: 2174


Degenerate bull hatter & Bitcoin monotheist


View Profile
February 09, 2014, 09:49:22 PM
 #9

Have you considered that Gox could be turned into a Ponzi scheme by the technique described above. 
infoman
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
February 09, 2014, 09:57:28 PM
 #10

Hi OP, I was told there wasa software could hack into gox account and "create" BTCs on the fly using fractions of micro transactions other users are doing.
there was a video of it online some time ago.

is there any connection or that is just hoax?
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 09:59:06 PM
 #11

Have you considered that Gox could be turned into a Ponzi scheme by the technique described above. 

It's not impossible of course, but I believe that the hacker attacks have caused limited damage. The main reason is that MtGox only allows 100 BTC withdrawals per day. Each unsuccessful withdrawal takes a week (before the balance is returned). This started two weeks ago and MtGox got warned early enough and took countermeasures before everything got out of control. This is the reason why they frozen all BTC withdrawals. I believe they'll be able to clean up everything, but it will take some time. It's certainly a very interesting situation. There are multiple different problems that magnifies the situation. Again, other exchanges could suffer from the same problem. As far as I understand, all the exchanges are currently being contacted and warned about the current situation.
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 10:00:30 PM
 #12

Hi OP, I was told there wasa software could hack into gox account and "create" BTCs on the fly using fractions of micro transactions other users are doing.
there was a video of it online some time ago.

is there any connection or that is just hoax?


I don't have any information on that. Even if that's true this particular issue is unrelated to that.
infoman
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
February 09, 2014, 10:12:59 PM
 #13

thanks for the reply!

seemed hoax to me, glad it is not related
aahzmundus
Hero Member
*****
Offline Offline

Activity: 644
Merit: 500


Invest & Earn: https://cloudthink.io


View Profile
February 09, 2014, 10:19:00 PM
 #14

How could the transaction be changed without needing to be re-signed?  I lack the technical knowledge to understand how what you describe is possible.

thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 10:22:55 PM
 #15

How could the transaction be changed without needing to be re-signed?  I lack the technical knowledge to understand how what you describe is possible.

You don't touch the actual signature, but there are meta-data around it. In a recent version of the official bitcoin client the format of that meta-data has been tightened so the transaction data provided by MtGox is now being rejected by the latest official version. A hacker can then take the rejected raw txdata provided from MtGox, patch it and rebroadcast it. It will get through, but MtGox still thinks it is invalid and returns balance.
Nagle
Legendary
*
Offline Offline

Activity: 1204
Merit: 1002


View Profile WWW
February 09, 2014, 10:35:53 PM
 #16

Thanks for your support. Unfortunately, I cannot reveal my sources.
He's just posting a garbled rewrite of this post on Reddit.

thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 10:43:40 PM
 #17

Thanks for your support. Unfortunately, I cannot reveal my sources.
He's just posting a garbled rewrite of this post on Reddit.



nullc has access to the same facts as me. His post is more into the actual technical details of the exploit. The intention of my post is to bring this topic to higher level because the concept itself is a real problem that exchanges should be aware of.
flower1024
Legendary
*
Offline Offline

Activity: 1428
Merit: 1000


View Profile
February 09, 2014, 10:47:25 PM
 #18

Thanks for your support. Unfortunately, I cannot reveal my sources.
He's just posting a garbled rewrite of this post on Reddit.



nullc has access to the same facts as me. His post is more into the actual technical details of the exploit. The intention of my post is to bring this topic to higher level because the concept itself is a real problem that exchanges should be aware of.


not really.
its just that mtgox instead of looking at their coins just looks if the tx they have created goes through - and only in that case subtracts some kind of internal balance.

i dont think any other service works this way. just crappy coders there.

but you may be right that this could be used to steal btc from gox. but i dont know if mtgox actually refunded tx which they think did not get through (but did because of the changed txid).
Fred Montagnon
Newbie
*
Offline Offline

Activity: 1
Merit: 0


View Profile
February 09, 2014, 10:48:42 PM
 #19

Thanks for your post. I share the same conviction about a hack and the fact it's certainly limited.

Bitcoin exchanges are an easy and not risky target for hackers. Exchanges don't have the ressources to sue hackers. It's a miracle there is not more problems everyday!

On the other hand, I don't expect a lot from their tomorrow's announcement...
thecomputerscientist (OP)
Newbie
*
Offline Offline

Activity: 48
Merit: 0


View Profile
February 09, 2014, 10:52:48 PM
 #20

Thanks for your support. Unfortunately, I cannot reveal my sources.
He's just posting a garbled rewrite of this post on Reddit.



nullc has access to the same facts as me. His post is more into the actual technical details of the exploit. The intention of my post is to bring this topic to higher level because the concept itself is a real problem that exchanges should be aware of.


not really.
its just that mtgox instead of looking at their coins just looks if the tx they have created goes through - and only in that case subtracts some kind of internal balance.

i dont think any other service works this way. just crappy coders there.

but you may be right that this could be used to steal btc from gox. but i dont know if mtgox actually refunded tx which they think did not get through (but did because of the changed txid).

You may be right as I cannot be sure how other exchanges work, but I do know MtGox has a problem with "double refunding." This is the reason why they halted all BTC withdrawals. They are currently going through all the transactions to check which ones did go through.
Pages: [1] 2 3 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!