News for hackers. Stuff that matters.
Re:The collapse of the IRON stable coin by aazaa on Thursday June 17, 2021 @07:06PM (#27545475)
> _share_price here refers to the price of TITAN, as provided by an oracle, which is correctly reporting it as… 0 (somewhere in the distance, you can hear a room full software engineers burst into laughter ).

Aside from the amusing programming error, the main problem with much of the "smart contract" activity today is that doing anything remotely interesting requires an oracle. An oracle is basically a server that reports the outcome of an event. And servers can be attacked in ways that systems like Ethereum can't.

So a lot of the hype around Ethereum and its "smart contracts" is really people just misunderstanding the security model. The weakest link is a server in a dorm room or data center reporting a number.

Here the oracle is doing the right thing. But it could easily go the other way.

Re:The collapse of the IRON stable coin by BrissyCoder on Thursday June 17, 2021 @09:30PM (#27546458)
And without an oracle smart contracts are useless for anything that relates to the real world. And guess what folks... we live and spend our money in the real world.

This has been the problem with smart contracts since day one. It is that simple.

Re:The collapse of the IRON stable coin by snak on Friday June 18, 2021 @08:51AM (#27549755)
> Aside from the amusing programming error, the main problem with much of the "smart contract" activity today is that doing anything remotely interesting requires an oracle. An oracle is basically a server that reports the outcome of an event. And servers can be attacked in ways that systems like Ethereum can't.

Thank you! I've tried to put it into words before but I think this is as close to perfection as one can get while describing why smart contracts are not what people believe them to be.

Re:The collapse of the IRON stable coin by ikeboy on Thursday June 17, 2021 @09:44PM (#27546555)
For prices you can use Uniswap's oracle which is time weighted average price and can't be manipulated unless you buy a ton of the token over the entire time period. In this case it was using a Sushi swap oracle (uniswap clone that's on matic) with very liquid pools so it was accurate, just lagged a bit when titan was dropping rapidly.
Re:The collapse of the IRON stable coin by 3np on Thursday June 17, 2021 @10:17PM (#27546730)
The general consensus is that it's a terrible idea to rely on Uniswap (or any other dex) as a price oracle for valuation/pricing for other on-chain defi applications/dexes. With enough capital (which can be acquired through flash loans) you can absolutely perform economic attacks though atomic transaction chains involving moving the dex price. Uniswap, Kyber, and others will tell you the same thing. This makes me think that even things like DAI/MakerDAO (and anything that relies oracles like Chainlink) can start to get brittle when/if the major price discovery and liquidity are on Dexes.

This has been seen in practice, for example in the Fulcrum hack:

https://gist.github.com/alexvansande/edcc9fe935b61526766c956...

https://dappradar.com/blog/defi-flash-loan-attack-what-just-...

Re:The collapse of the IRON stable coin by ikeboy on Thursday June 17, 2021 @10:35PM (#27546815)
Flash loans are not relevant to the uniswap TWAP oracle, which ignore any transactions in the current block. That oracle was written specifically to be resistant to manipulation and I don't think there's any consensus not to use it.
Re:The collapse of the IRON stable coin by 3np on Thursday June 17, 2021 @11:57PM (#27547208)
It's definitely an improvement. Still, I would advise against it in general, especially for arbitrary pairs. This category of attacks can be difficult to foresee and even arise after deployment due to new incentives outside of the system.

While Chainlink has its own host of issues and risks, there are still valid reasons why companies are paying them and their node operators good money to feed price contracts for ERC-20 token pairs.

Re:The collapse of the IRON stable coin by acjohnson55 on Friday June 18, 2021 @01:13AM (#27547567)
Could you not still use flash loans in attacks that take longer than one block? You'd have to pay the loan back within each block, but it seems like you could still shift markets enough to take advantage, if you were willing enough to take on some risks.
Re:The collapse of the IRON stable coin by nadahalli on Friday June 18, 2021 @03:49AM (#27548268)
That'd be quite expensive. And as you manipulate prices across blocks, arbitrageurs would arb it back to "market price". Uniswap V3 allows for a 3rd party smart contract to ask its Uniswap V3 Oracle to employ a 9 day moving average price - which is of course, not very useful as a "spot price", but is super hard to manipulate.
Re:The collapse of the IRON stable coin by fogof on Friday June 18, 2021 @02:38AM (#27547930)
This actually surprising and doesn't make a lot of sense to me. If the oracle is just an AMM, then presumably one could get the oracle to register a nonzero value by just putting a small amount of money in the contract. As long as there aren't an infinite amount of TITAN tokens (are there?), even if all of the TITAN in existence were put into this AMM, there would still be a little money left to give TITAN a positive price and fix the issue.
Re:The collapse of the IRON stable coin by RhodoGSA on Monday June 21, 2021 @03:16AM (#27577014)
There's a bit more to what happened than the article lets on. The contract mints to provide liquidity (supposedly). There was 1.8m tokens at the time of the crash, now theres 26Trillion. you would need all the capital in the world to get it to .1 now.
Re:The collapse of the IRON stable coin by ikeboy on Friday June 18, 2021 @07:07AM (#27549216)
The oracle calculated the price to a certain precision, so it rounded down to 0.
Re:The collapse of the IRON stable coin by bikamonki on Thursday June 17, 2021 @07:42PM (#27545714)
Oracle is a fancy name for an API, right?
Re:The collapse of the IRON stable coin by nly on Thursday June 17, 2021 @08:02PM (#27545847)
In cryptography an oracle is someone or something you can query that returns an answer that you cannot know from just the math.

It doesn't have to be an API. Side channel attacks can provide unintentional oracles. For example, if you have a password checking function that takes longer to return a false result for "close" inputs, then it leaks information that can be used to crack passwords (simple O(n) string comparison would be an example)

https://en.wikipedia.org/wiki/Oracle_attack

Re:The collapse of the IRON stable coin by lmm on Thursday June 17, 2021 @09:19PM (#27546383)
An oracle is not just an API, but specifically one that your system trusts unconditionally.
Re:The collapse of the IRON stable coin by el_dev_hell on Thursday June 17, 2021 @07:53PM (#27545792)
I've been wondering the same for a few weeks but can't be bothered checking.

My uneducated inference is that an oracle is a data source and you can hook into it from the smart contract. The oracle seems to live off-chain and live on a traditional server/DB.

Please correct me if the above is way off!

Re:The collapse of the IRON stable coin by chrisco255 on Thursday June 17, 2021 @08:54PM (#27546173)
An oracle is a source of truth for information about the outside world to a smart contract. The smart contract doesn't actually call the oracle. This is because smart contracts don't self-execute and can't make external http calls. So a smart contract pauses, and waits for an oracle to trigger an update function. Because oracles have a lot of power over a smart contract (not all smart contracts need them, by the way), they have to be done in a secure way. The market leader in decentralized oracles is Chainlink. They power hundreds of DeFi applications.
Re:The collapse of the IRON stable coin by nieve on Thursday June 17, 2021 @09:23PM (#27546404)
At that point can they really be considered purely code contracts anymore? If their execution requires a trusted third party some of the rhetoric goes out the window.
Re:The collapse of the IRON stable coin by chrisco255 on Friday June 18, 2021 @02:35AM (#27547913)
They're sort of hybrid networks at that point, but Chainlink oracles are decentralized: each function is run by several nodes (31 for the BTC/USD or ETH/USD price feed, for example). The nodes have to come to consensus and individual nodes are slashed if they produce bad or late data. You can see an example of a LINK feed here: https://data.chain.link/ethereum/mainnet/crypto-usd/eth-usd

Decentralization is a spectrum. But I would argue this approach is far more secure than naive oracle implementations.

Not all applications need oracles. It depends on whether your smart contract needs information about the world outside of the blockchain.

Re:The collapse of the IRON stable coin by ric2b on Monday June 21, 2021 @05:40PM (#27584886)
Who owns those 31 nodes? Who gets to choose which nodes are part of the calculation?
Re:The collapse of the IRON stable coin by lifeformed on Thursday June 17, 2021 @11:50PM (#27547181)
I think they're just other smart contacts that use many data sources. Like if you wanted an oracle that returned the result of a baseball game, you'd have it check various newspaper websites and have it make sure the results were all the same. To attack it, you'd have to attack all the newspaper sources. It's still a weak point, but not quite a single point of failure.
Re:The collapse of the IRON stable coin by detaro on Thursday June 17, 2021 @08:12PM (#27545911)
Specifically for something that feeds data from an API (or really any other data source) into a blockchain so it is available from smart contracts.
Re:The collapse of the IRON stable coin by DennisP on Thursday June 17, 2021 @07:28PM (#27545609)
I'd say Uniswap is interesting. That doesn't use an oracle.
Re:The collapse of the IRON stable coin by acjohnson55 on Friday June 18, 2021 @01:08AM (#27547547)
But it also only works with on-chain cryptoassets.
Re:The collapse of the IRON stable coin by DennisP on Friday June 18, 2021 @08:50AM (#27549743)
If you want to work with off-chain things then necessarily your system is going to include off-chain things. I'm not sure of your point here.

However, I can think of an exception. Augur is a prediction market that doesn't use a trusted source to resolve bets. It doesn't get a lot of use these days, and probably won't before scaling resolves gas prices, but the bets that have been live on the system have resolved correctly.

Re:The collapse of the IRON stable coin by youdumbaf on Thursday June 17, 2021 @07:53PM (#27545791)
no, an oracle is another smart contract that is called by the main contract, the oracle smart contract logs an event, this event triggers sources of truth (servers), each source of truth provides information for the oracle contract by modifying its state, the oracle contract decides if the data is reliable and calls the main contract if so
Re:The collapse of the IRON stable coin by polytely on Friday June 18, 2021 @06:03AM (#27548902)
But there must always be a point where the oracle interacts with the real world, right? Which immediately becomes a point of centralization, which -seems to me- kinda defeats the purpose of having a decentralized system
Re:The collapse of the IRON stable coin by RhodoGSA on Monday June 21, 2021 @03:13AM (#27577000)
Oracles have come a long way and very interesting work is being done to solve this problem. You don't always have to rely on one oracle and the amount of capital you'd need to 'trick' an oracle is too high to be economically advantageous. There is a possibility with very low-volume tokens, but good luck not getting eaten alive by arbitrage trying to trick a popular coin.
Re:The collapse of the IRON stable coin by aqme28 on Thursday June 17, 2021 @09:42PM (#27546543)
There are a lot of systems now that don't use oracles. Prices are maintained by people arbitraging any significant difference.
Re:The collapse of the IRON stable coin by trophycase on Thursday June 17, 2021 @08:01PM (#27545837)
I love your rhetoric of "server in a dorm room" to make it sound way sketchier and amateur than it is.