Vulnerability: tbtc - various deposit state transitions can be front-run (e.g. fraud proofs, timeouts)  Won't Fix
Severity: high

Description:
An entity that can provide proof for fraudulent ECDSA signatures or SPV proofs in the liquidation flow is rewarded with part of the deposit contract ETH value.\\nSpecification: Liquidation Any signer bond left over after the deposit owner is compensated is distributed to the account responsible for reporting the misbehavior (for fraud) or between the signers and the account that triggered liquidation (for collateralization issues).\\nHowever, the methods under which proof is provided are not protected from front-running allowing anyone to observe transactions to provideECDSAFraudProof/ `provideSPVFraudProof` and submit the same proofs with providing a higher gas value.\\nPlease note that a similar issue exists for timeout states providing rewards for calling them out (i.e. they set the `liquidationInitiator` address).\\n`provideECDSAFraudProof` verifies the fraudulent proof\\n`r,s,v,signedDigest` appear to be the fraudulent signature. `_preimage` is the correct value.\\n```\\n/// @param \\_preimage The sha256 preimage of the digest\\nfunction provideECDSAFraudProof(\\n    DepositUtils.Deposit storage \\_d,\\n    uint8 \\_v,\\n    bytes32 \\_r,\\n    bytes32 \\_s,\\n    bytes32 \\_signedDigest,\\n    bytes memory \\_preimage\\n) public {\\n    require(\\n        !\\_d.inFunding() && !\\_d.inFundingFailure(),\\n        "Use provideFundingECDSAFraudProof instead"\\n    );\\n    require(\\n        !\\_d.inSignerLiquidation(),\\n        "Signer liquidation already in progress"\\n    );\\n    require(!\\_d.inEndState(), "Contract has halted");\\n    require(submitSignatureFraud(\\_d, \\_v, \\_r, \\_s, \\_signedDigest, \\_preimage), "Signature is not fraud");\\n    startSignerFraudLiquidation(\\_d);\\n}\\n```\\n\\n`startSignerFraudLiquidation` sets the address that provides the proof as the beneficiary\\n```\\nfunction provideFundingECDSAFraudProof(\\n    DepositUtils.Deposit storage \\_d,\\n    uint8 \\_v,\\n    bytes32 \\_r,\\n    bytes32 \\_s,\\n    bytes32 \\_signedDigest,\\n    bytes memory \\_preimage\\n) public {\\n    require(\\n        \\_d.inAwaitingBTCFundingProof(),\\n        "Signer fraud during funding flow only available while awaiting funding"\\n    );\\n\\n    bool \\_isFraud = \\_d.submitSignatureFraud(\\_v, \\_r, \\_s, \\_signedDigest, \\_preimage);\\n    require(\\_isFraud, "Signature is not fraudulent");\\n    \\_d.logFraudDuringSetup();\\n\\n    // If the funding timeout has elapsed, punish the funder too!\\n    if (block.timestamp > \\_d.fundingProofTimerStart + TBTCConstants.getFundingTimeout()) {\\n        address(0).transfer(address(this).balance);  // Burn it all down (fire emoji)\\n        \\_d.setFailedSetup();\\n    } else {\\n        /\\* NB: This is reuse of the variable \\*/\\n        \\_d.fundingProofTimerStart = block.timestamp;\\n        \\_d.setFraudAwaitingBTCFundingProof();\\n    }\\n}\\n```\\n\\n`purchaseSignerBondsAtAuction` pays out the funds\\n```\\n    uint256 contractEthBalance = address(this).balance;\\n    address payable initiator = \\_d.liquidationInitiator;\\n\\n    if (initiator == address(0)){\\n        initiator = address(0xdead);\\n    }\\n    if (contractEthBalance > 1) {\\n        if (\\_wasFraud) {\\n            initiator.transfer(contractEthBalance);\\n        } else {\\n            // There will always be a liquidation initiator.\\n            uint256 split = contractEthBalance.div(2);\\n            \\_d.pushFundsToKeepGroup(split);\\n            initiator.transfer(split);\\n        }\\n    }\\n}\\n```\\n

Impact:

Recommended mitigation:
For fraud proofs, it should be required that the reporter uses a commit/reveal scheme to lock in a proof in one block, and reveal the details in another.