3

I have deployed a dApp on a sidechain (namely xDai) and am worried about its security.

What happens if an EVM chain is compromised?

Will it be rolled back after a few hours? or what?

If the mainnet is compromised? If a sidechain (said to be less reliable than mainnet) is compromised how does this influence funds on the mainnet?

I am concerned mainly with long time security (I worry not much about fast traders).

How a "slow" user may lose money? He gets (the right to withdraw) one token per second and could lose big money only if he trades it right in the time of the compromise or during signup what isn't very important as he could just signup again after just a day of lost profit stream, right? Please describe possible scenaria of my users losing money (like when they sell their tokens on Uniswap?)

I need an answer detailed enough to make my own informed decisions.

1
  • As I understand, if the user already sent his xDai ERC-20 tokens to the mainnet, he is not compromised, if he didn't send yet and blockchain was compromised (e.g. by seizing a majority of staks) a short time before this, the xDai chain would be then rolled back and the user don't have a big trouble, too. Right? What else danger there exist?
    – porton
    Commented Feb 27, 2021 at 6:11

3 Answers 3

1

From xDai bridge docs:

The bridge uses smart contracts on both chains to process transfers, and a group of validators confirms bridge transactions. When a bridge transfer is initiated, the specified amount of Dai is locked in a smart contract on the Ethereum mainnet, and the same amount of xDai is minted on the xDai chain and sent to the user's wallet on the xDai chain. When xDai is transferred back, xDai is burned, and the corresponding amount of Dai is unlocked in the contract and released to the user's wallet on the Ethereum mainnet. The bridge mechanism ensures that the amount of xDai can never exceed the amount of Dai locked in the bridge contract.

Assume a scenario where the xDAI chain is compromised, in this case:

  • Smart Contracts that are deployed by xDai on ethereum are no more decentralized, the primary function of these contracts is to lock the assets of the caller (by changing the owner of assets from caller to xDai deployed contract(i.e itself) ). So locked assets(and unlocking of assets) can be controlled by the attacker (or unit which compromised the xDai chain)
  • same happens with Smart Contracts on the xDai chain that mints and burns mapped assets, this can also result in non-zerosum supply, unlimited minting, or total burning.

In the context of users of your dApp, they will lose control over any asset that are in mainnet smart contract (i.e your dApp) but approved (or owned) by xDai deployed contracts and any mapped asset on xDai chain

rolling back of the xDai chain is not predictable if compromised, but you can assume it to forked to the state before the attack but still, any assets that are in mainnet smart contract (i.e your dApp) but approved (or owned) by xDai deployed contracts(before attack) are lost.

8
  • Why do you say that assets that are in mainnet smart contractor are in my dApp? My dApp in on xDai not on mainnet. What is "mapped asset"?
    – porton
    Commented Mar 8, 2021 at 4:50
  • @porton your assets are mapped by xDai deployed smart contracts (rootchainManager on eth and childchainManager on xDai) only if you are using the bridge. check their FAQ for more info link
    – hack3r-0m
    Commented Mar 8, 2021 at 5:02
  • You seem to say that my dApp's assets are on mainnet and are "mapped" to xDai. But they are on xDai and may be mapped to mainnet. Please clarify.
    – porton
    Commented Mar 8, 2021 at 7:05
  • @porton mapping works both ways, if you can update your question with a smart contract i can try to elaborate my answer. but the worst consequence can be mainnet deployed contracts that send/receive data to the child chain via a consensus mechanism will be compromised and assets in that too and a fork cannot undo that so I assume fork will redeploy new contract to interact with forked child chain.
    – hack3r-0m
    Commented Mar 8, 2021 at 14:57
  • I just don't understand youL: You say "they will lose control over any asset that are in mainnet smart contract". Why a user would lose control of assets in mainnet contract if the sidechain is compromised?
    – porton
    Commented Mar 9, 2021 at 15:14
1

First point here would be to understand your goal for using a sidechain. I assume you possibly need to either increase scalability or minimise gas fees. If that is the case, then you have a number of layer 2 solutions with different pros / cons.

As mentioned by @Ismael, a PoA-based consensus blockchain will always have the underlying risk of quorum manipulation. The impact will depend on the resolution time and how this is solved afterwards (a fork is not always the best option for all parties). For a more detailed risk analysis, you probably need security consultancy for the specific sidechain (xDai).

The chart below may bring some light to understand the limitations of each L2 solution (note that sidechains are the ones with more security risks):

enter image description here

If you are looking for the highest security solution, it is likely that you need a zkRollup strategy, and most of the important DeFi platforms currently in mainnet are already migrating to this approach.

Fortunately, there are new projects to provide zkRollups, such as Loopring, zkSync, etc.

I am not necessarily suggesting you need a zkRollup instead of a sidechain, since this will depend on your requirements (# of transactions, # of users, security levels, etc), but just sharing pros/cons to make a more informed decision whether a sidechain is what you need.

5
  • This is not quite an answer: you mostly just pointed me a table for my further research rather than answering my particular questions.
    – porton
    Commented Mar 2, 2021 at 4:37
  • Agree, though the answers to your -several- questions depend on your specific implementation, the node validators and their foundational rules, the efficiency to detect and fix a potential attack, etc, so not sure you will ever get a specific answer for this besides the generic answers to any PoA attack. That's why I tried to propose alternatives if your concern is security. Commented Mar 2, 2021 at 6:04
  • I need specifics on my issue, where tokens are always allowed to be minted by 1 token per second. Is it safe enough in this case?
    – porton
    Commented Mar 2, 2021 at 6:22
  • For me, the big risk is that you are assuming that the condition to withdraw one token per second will be always accomplished, but depending on the vector attack, that won't be necessarily the case, and the whole funds from the sidechain wallets could be drained in a single transaction. Also, even funds are not sent to mainnet after an attack, these could be transferred to an attacker address in the sidechain to either withdraw progressively or just freeze them: will the nodes accept forks or rollbacks affecting other users? in essence, your security now depends on the sidechain foundations. Commented Mar 2, 2021 at 7:17
  • I don't assume this. I understand that a sidechain vulnerability can change token counts. But in the assumption that the sidechain will be rolled back (e.g. during 2 days), is there a big loss for my users? "Withdraw one token per second" is not quite exact, I mean "accumulate on a (non ERC-20) account exactly one token per second". (Accumulating 1 per second in a ERC-20 would be virtually impossible as every second would need a transaction, but we can transfer these accumulated tokens to user's wallet at any time.)
    – porton
    Commented Mar 2, 2021 at 22:28
0

xDai is a separate blockchain on their own with PoA consensus. If it is compromised then it will imply that a majority of validators were compromised.

I'd speculate if there's a serious security breach they will stop the bridge between mainnet and xdai until the chain is fixed, perhaps a fork or a rewind will be applied.

I think the more serious problem I have seen with a PoA was when rinkeby stopped generating new blocks. Several validators went offline and the weren't enough validators to keep the network running.

3
  • You didn't answer my question. I think if the bridge is stopped immediately, and xDai is rolled back, then there is no big trouble for my users (except a downtime). But will they be harmed if the the bridge is stopped immediately or the breach is noticed not immediately?
    – porton
    Commented Feb 28, 2021 at 10:53
  • @porton It is a PoA blockchain by itself, any attack that applies to PoA chains should be possible. It is unlikely that a majority of validators compromised will go unnoticed. Like any blockchain The risk of losing funds is very low but it is not zero.
    – Ismael
    Commented Feb 28, 2021 at 18:18
  • Your comment is not enough detailed to be an answer. It looks like I may need to pay to a paid consultancy to get a detailed answer. :-(
    – porton
    Commented Feb 28, 2021 at 23:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.