Catch up on stories from the past week (and beyond) at the Slashdot story archive

 



Forgot your password?
typodupeerror
×
Bitcoin Bug Security

Really Stupid 'Smart Contract' Bug Let Hackers Steal $31 Million In Digital Coin (arstechnica.com) 55

An anonymous reader quotes a report from Ars Technica: Blockchain startup MonoX Finance said on Wednesday that a hacker stole $31 million by exploiting a bug in software the service uses to draft smart contracts. The company uses a decentralized finance protocol known as MonoX that lets users trade digital currency tokens without some of the requirements of traditional exchanges. "Project owners can list their tokens without the burden of capital requirements and focus on using funds for building the project instead of providing liquidity," MonoX company representatives say here. "It works by grouping deposited tokens into a virtual pair with vCASH, to offer a single token pool design."

An accounting error built into the company's software let an attacker inflate the price of the MONO token and to then use it to cash out all the other deposited tokens, MonoX Finance revealed in a post. The haul amounted to $31 million worth of tokens on the Ethereum or Polygon blockchains, both of which are supported by the MonoX protocol. Specifically, the hack used the same token as both the tokenIn and tokenOut, which are methods for exchanging the value of one token for another. MonoX updates prices after each swap by calculating new prices for both tokens. When the swap is completed, the price of tokenIn -- that is, the token sent by the user -- decreases and the price of tokenOut -- or the token received by the user -- increases.

By using the same token for both tokenIn and tokenOut, the hacker greatly inflated the price of the MONO token because the updating of the tokenOut overwrote the price update of the tokenIn. The hacker then exchanged the token for $31 million worth of tokens on the Ethereum and Polygon blockchains. There's no practical reason for exchanging a token for the same token, and therefore the software that conducts trades should never have allowed such transactions. Alas, it did, despite MonoX receiving three security audits this year.
"These kinds of attacks are common in smart contracts because many developers do not put in the legwork to define security properties for their code" said Dan Guido, an expert in securing smart contracts and CEO of security consultancy Trail of Bits. "They had audits, but if the audits only state that a smart person looked at the code for a given period of time, then the results are of limited value. Smart contracts need testable evidence that they do what you intend, and only what you intend. That means defined security properties and techniques employed to evaluate them."

According to Blockchain researcher Igor Igamberdiev, the drained tokens included $18.2 million in Wrapped Ethereum, $10.5 in MATIC tokens, and $2 million worth of WBTC, along with small amounts of tokens for Wrapped Bitcoin, Chainlink, Unit Protocol, Aavegotchi, and Immutable X.
This discussion has been archived. No new comments can be posted.

Really Stupid 'Smart Contract' Bug Let Hackers Steal $31 Million In Digital Coin

Comments Filter:
  • by garyisabusyguy ( 732330 ) on Thursday December 02, 2021 @06:03PM (#62041395)

    ...if it was designed to do that?

    Just askin' for a friend

    • That's actually a very legit question. There were two independent audits of the Monoswap contract; how came no one notice this (obvious) bug?

      • Maybe it was a (hidden) feature and not a bug? ;)

      • by DarkOx ( 621550 )

        Simple because of the way application audits are done.

        1) Usually the auditors customer is also the organization that wrote the software
        I am not saying this is an inherent conflict, they might legitimately want to know about as many problems as possible to reduce their own exposure but...usually they also want to be able to tell their customers hey we had an audit and it was either clean or we addressed every issue! People don't like getting reports from auditors where the issues are merely speculative thoug

        • Note that all of the three options you list just means that the auditor was unqualified for the job at hand.

          • by DarkOx ( 621550 )

            That is a viewpoint. The alternative viewpoint is auditors are generally their to determine if the evidence suggests what is being said is 'likely' to be accurate.

            You have some do a security audit of the application your team built because they told you they know what current best practices are and followed them, because they told you the architecture team carefully considered the abuse cases and designed around them.

            If you did not believe those things (hopefully) you would not be looking to go live in the

  • It's almost like (Score:5, Interesting)

    by OrangeTide ( 124937 ) on Thursday December 02, 2021 @06:21PM (#62041451) Homepage Journal

    It's almost like we should regulate and indemnify financial software. Nah, there is so much freedom and profit running this like it's the wild west. Because stage coach robberies seem really romantic, or at least make for interesting journalism.

    • Yeah, but it was Blockchain! Best thing to come down the pike since the cloud.
      • Wall Street only much much much funnier, us mortals just don't get Doh-Finance.
        • Wall Street only much much much funnier, us mortals just don't get Doh-Finance.

          So many people don't seem to understand that theft of other people's money is the core of the fake coins.

          The amazing thing to me is that banks are starting to ge a woody about the funny money.

          If you thought the housing bubble bursting was bad, just wait!

      • Satoshi Nakamoto was a very good practical coder, so Bitcoin is very solid.
        A lot of the people making alt-coins are not very good practical coders, and as a result you see these kinds of hacks.

        Note: now that Bitcoin has been modified to allow "smart contracts," we will also likely see these kinds of hacks on Bitcoin, too.

        • The bug was in the smart contract, not the coin itself.

          • The bug was in the smart contract, not the coin itself.

            Go look at how the housing bubble nearly caused the Great depression, rev 2.

            That's how we does stuff, and the pretend money digital coins are no different.

    • It's almost like we should regulate and indemnify financial software. Nah, there is so much freedom and profit running this like it's the wild west. Because stage coach robberies seem really romantic, or at least make for interesting journalism.

      Yes, I totally don't get why the government doesn't just pass a law saying that all software must be secure. End all hacking with just one signature! Next, they should mandate universal happiness.

      • They could probably end nuclear war if they made it illegal. That's just shy of world peace, but I'm willing to take it.

        You could make running a shit show IT and Dev department completely unprofitable if you open businesses up to civil penalties if they ignore some really basic oversight and standards for software development process. The really brilliant coders will hate working on heavily regulated projects, but oh well, there is plenty of fun stuff to do outside of finance and security.

        • by sjames ( 1099 )

          And then there will be no more financial software. Anyone good enough to do it will go somewhere that's less of a pain in the ass leaving only those who would create too many liabilities to let them actually write the software.

          • except there are already regulations and required processes for financial, medical devices, and automotive software. And yet I and hundreds of my coworkers are getting paid every two weeks for two out of three of these. Hmmm.

      • Nah, they just need to acknowledge perfect software is impossible, and pass legislation regulating automated contracts. For example, there should always be recourse for bugs like this one.

    • by tlhIngan ( 30335 ) <slashdot.worf@net> on Thursday December 02, 2021 @07:18PM (#62041657)

      It's almost like we should regulate and indemnify financial software. Nah, there is so much freedom and profit running this like it's the wild west. Because stage coach robberies seem really romantic, or at least make for interesting journalism.

      Well, that's why the financial system IS regulated. But some people got fed up of all the red tape they created their own decentralized currencies using Blockchain. Of course, now we end up with the exact same problems that caused us to regulate things in the first place

    • Yes let's pass a law that software can't have bugs.
      • Why not have software developers publicly canned for each bug and bring the hyperbole to full dramatic effect?

  • People are frustrated that contracts are hard to understand. Over centuries basic agreements that make up the legal framework for all the economic transaction we engage have become
    Increasingly convoluted. In part this is to address the problems that have been experienced, some of it is people trying the tilt the playing field in their favor, and also there is an element of attorneys trying to make themselves important by gobing things up with cruft that is not meant to be understood.

    So âoesome genius

    • just need to confuse 1 jury member to get hung

      • by rgmoore ( 133276 )

        This in only true in criminal cases. In civil cases, which is where contracts will most frequently wind up, the requirement may be lower. Here in California, for instance, a civil jury only needs to get a 3/4 majority to decide a case. The burden of evidence is also lower. The net result is that it's a lot harder to hang a civil jury than a criminal one.

    • Software code is mathematically precise, legal code is not. It would be an improvement if we could figure out a way to make legal code mathematically precise (arguably it's not possible).

      • by haus ( 129916 )

        Bullshit

        At best code strives to be mathematically precise, but it rarely is. Errors abound all over the place, often related to misunderstandings of the functions that are being utilized or of the actual nature of what is being computed.

        In reality this is not that different than the errors that creep into contracts and regulations.

        Just because you manage to get an output by pushing data into code does not mean that this output is valid or a true representation of the intent of the programer much less the pa

        • Technically it is mathematically precise, it just may not precisely model what the coder intended it to model.

          • Code is, more often than not , anything but "mathematically precise". Trying to predict what code will do is a variant of the Halting Problem [wikipedia.org], which Turing proved cannot be resolved.

            Ethereum smart contracts, for example, are Turing-complete.

      • by sjames ( 1099 )

        That's the thing. Code can be precise but it can require herculean effort to cover every possible corner case. And that's where the devil lives. We see daily reports where someone finds and exploits yet another corner case. Many times by doing something that nobody would ever even want to do except for the benefits from the exploit (for example, the one in TFA).

        Pretty much every contract dispute that goes to court is one of those annoying corner cases. Often a genuine mis-understanding from one or both part

  • Code is law (Score:5, Interesting)

    by crgrace ( 220738 ) on Thursday December 02, 2021 @06:35PM (#62041499)

    This has always been one of the issues with Smart Contracts.

    Software is hard, and provably correct software is harder. There will always be bugs.

    The industry is screaming for regulation.

    • I'm drawing a blank on how regulation would prevent the exploitation of logic errors in 'smart' contracts. The whole point is that they operate exactly as instructed, if you had to build in some kind of human arbitration options you would just have a regular contract. Which would be much smarter.
    • by sjames ( 1099 )

      The industry is screaming for regulation.

      By who? Someone who does NOT have a sufficient understanding of CS to see why it is impossible to ever be certain all bugs are fixed?

  • In my opinion, the bug is in the interpreter of the smart contract execution engine.

  • If you fork the blockchain to change the rules ex-post, then YOU are the thieves.

  • by FeelGood314 ( 2516288 ) on Friday December 03, 2021 @02:15AM (#62042601)
    X amount of token IN were traded for Y amount of Token OUT
    They had a function to update the prices of IN and OUT.

    calcPrice(X, IN, Y, OUT)
    {
    originalInPrice = IN.price;
    originalOtPrice = Out.price;

    //some calculations that will lower IN price and raise OUT price


    IN.price = newInPrice;
    Out.price = newOutPrice;
    }

    Now if IN==OUT the price of the tokens should be unchanged but the above code raises the price.

    This might be obvious to anyone who has dealt with atomic operations or race conditions but to most app developers it isn't. Also most audits are total crap. A good Common Criteria audit will cost you over half a million dollars, take 6 months and probably wouldn't catch this.
    • ^^^ This.

      As noted above, Monoswap had multiple independent audits, and apparently no one noticed this rather obvious issue.

  • I am sure that the company will be held liable for letting their product or service (I can't tell what they are actually providing) create this mess.

  • I'm always suspicious when something has "smart" in its name (see: smart home). This "smart" contract seems to be on par with "smart" quotes.

  • by misnohmer ( 1636461 ) on Friday December 03, 2021 @05:23AM (#62042843)

    Good for the hacker, they earned their QA fee. Defi has a choice of following strict coding standards, QA, etc, or let the public test it for them. Losing 30 million dollars every once in a while might still be cheaper than strict adherence to standards and extensive QA, not to mention time-to-market, and the fact that even following all the standards doesn't guarantee bug free software (thought it does catch or prevent a lot, at a cost).

  • by Lisandro ( 799651 ) on Friday December 03, 2021 @05:51AM (#62042873)

    Loved Schneier's take on the subject [schneier.com]:

    (...) The article goes on to talk about how common these sorts of attacks are. The basic problem is that the code is the ultimate authority — there is no adjudication protocol — so if there’s a vulnerability in the code, there is no recourse. And, of course, there are lots of vulnerabilities in code.

    To me, this is reason enough never to use smart contracts for anything important. Human-based adjudication systems are not useless pre-Internet human baggage, they’re vital.

  • by belthize ( 990217 ) on Friday December 03, 2021 @11:35AM (#62043544)

    Is once you find a loop hole and steal somebody's money you can be damned sure its your money now and there's nothing anybody can do about it.

    I like the steps taken. The first one was

    Tried to make contact with the attacker to open a dialogue through submitting a message via transaction on ETH Mainnet

    The last one was

    Additionally, we will file a formal police report

    Basically we asked nicely for the money back but that didn't work so after some hand wringing we plan to call the cops who will be able to do fuck all about it.

Get hold of portable property. -- Charles Dickens, "Great Expectations"

Working...