Cudos contest - dipp's results

Decentralised cloud computing for Web3.

General Information

Platform: Code4rena

Start Date: 03/05/2022

Pot Size: $75,000 USDC

Total HM: 6

Participants: 55

Period: 7 days

Judge: Albert Chon

Total Solo HM: 2

Id: 116

League: COSMOS

Cudos

Findings Distribution

Researcher Performance

Rank: 11/55

Findings: 3

Award: $1,251.36

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: CertoraInc

Also found by: 0x1337, AmitN, WatchPug, cccz, danb, dipp, dirk_y, hubble, jah

Labels

bug
duplicate
2 (Med Risk)

Awards

620.336 USDC - $620.34

External Links

Lines of code

Gravity.sol#L276-L358

Vulnerability details

Impact

While the voting power of the current valset is checked when the checkValidatorSignatures function is called in updateValset, the power of the new valset is not.

This could cause some functions to not work since whenever checkValidatorSignatures is called with the new valset, the function would revert because the new valset would not have enough voting power.

Proof of Concept

The updateValset function is called with a _newValset that does not have enough voting power. The _currentValset is set to this _newValset on L337 by setting the last valset checkpoint to the new valset checkpoint.

When calling checkValidatorSignatures with the newly set _currentValset that now does not have enough voting power, the function reverts since cumulativePower <= _powerThreshold.

Affected functions:

Tools Used

Add a check for the voting power of the new valset in the updateValset function, similar to the power check in the constructor.

#0 - V-Staykov

2022-05-11T11:13:53Z

Duplicate of #123

Findings Information

🌟 Selected for report: wuwe1

Also found by: Dravee, GermanKuber, GimelSec, WatchPug, cccz, defsec, dipp, jah, reassor

Labels

bug
duplicate
2 (Med Risk)

Awards

502.4722 USDC - $502.47

External Links

Lines of code

Gravity.sol#L595-L609

Vulnerability details

Impact

The documentation describes the use of tokens other than CUDOS in the Gravity.sol contract; so it is assumed that the CUDOS token will not be the only supported token. The documentation also states that validators on the Tendermint chain will use the information in the emitted event for the sendToCosmos function to determine the amount of tokens to be minted on the Tendermint side.

For transfer-on-fee/deflationary tokens, where the final _amount emitted may not be the same as the _amount in, the emitted amount value in SendToCosmosEvent could be incorrect. This could result in a mismatch of the balance between the Ethereum side and the Tendermint side for the account.

Proof of Concept

  1. Ethereum Account sends 100 tokens (transfer-on-fee tokens) to Gravity.sol using the sendToCosmos function.
  2. After the transfer, the amount of tokens actually sent to Gravity.sol is less than _amount (eg. 90 tokens).
  3. The sendToCosmos function emits the original amount (100 tokens).
  4. The validators on the Tendermint side use the emitted amount (100 tokens) value to determine how many tokens to mint instead of the actual amount received by Gravity.sol.

Tools Used

Check the balance of the Gravity contract before the transfer and again after the transfer in sendToCosmos. The emitted amount should be the difference of the 2 balances.

#0 - mlukanova

2022-05-10T14:49:32Z

Duplicate of #3

Awards

128.5517 USDC - $128.55

Labels

bug
QA (Quality Assurance)

External Links

L-01: Check _powerThreshold value in the constructor of Gravity.sol

Line References

Gravity.sol#L640-L694

Description

The power threshold should at least be more than 0 otherwise any amount of validator signatures is enough.

Add a check in the constructor for the _powerThreshold just before the voting power check for the valset on L659.

L-02: Nonce values should be limited.

Line References

Gravity.sol#L340

Gravity.sol#L448

Description

If a malicious validator calls the the submitBatch function in Gravity.sol and sets _batchNonce to the max value for uint256 then submitBatch would become unusable for that particular token since the require condition on L385 cannot be passed.

The updateValset function may be affected in a similar way with its _newValset.valsetNonce.

Add a check that the _batchNonce and the _newValset.valsetNonce values are only a certain amount more than the last nonce value.

N-02: Inconsistent emit info for ValsetUpdatedEvent

Line References

Gravity.sol#L350-L357

Description

The documentation states that the _eventNonce value should not be emitted in the ValsetUpdatedEvent, however ValsetUpdatedEvent has an _eventNonce field and the updateValset emits the state_lastEventNonce value.

Remove the _eventNonce field from ValsetUpdatedEvent and from the emitted event in updateValset.

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter