Dataset Viewer
Auto-converted to Parquet Duplicate
source
stringclasses
1 value
protocol
stringclasses
111 values
report_title
stringclasses
111 values
report_date
stringdate
2023-03-13 00:00:00
2023-04-11 00:00:00
finding_id
stringclasses
150 values
severity
stringclasses
6 values
title
stringlengths
10
284
full_content
stringlengths
103
34.2k
description
stringlengths
46
14.4k
proof_of_concept
stringclasses
438 values
impact
stringlengths
0
4.93k
recommended_mitigation
stringlengths
2
10.6k
code_block_count
int64
0
32
has_poc
bool
2 classes
has_mitigation
bool
2 classes
content_length
int64
103
34.2k
severity_normalized
stringclasses
5 values
severity_raw
stringclasses
6 values
category
stringclasses
16 values
primary_code
stringlengths
0
15k
primary_code_language
stringclasses
11 values
all_code_blocks
stringlengths
0
20.8k
all_code_blocks_count
int64
0
32
solidity_code
stringlengths
0
19.9k
has_impact
bool
2 classes
has_code_in_description
bool
2 classes
content_richness_score
float64
0
10.5
quality_estimate
stringclasses
3 values
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-01
high
Attackers can steal tokens and break the protocol's invariant
Attackers can steal tokens and break the protocol's invariant ### Description The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. The function `Well::_getIJ()` is used to get the index of the `fromToken` and `toToken` in the Well's `tokens`. But the f...
The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. The function `Well::_getIJ()` is used to get the index of the `fromToken` and `toToken` in the Well's `tokens`. But the function `Well::_getIJ` is not implemented correctly. ```solidity Well.sol 566: ...
Assume a Well with two tokens `t0, t1` is deployed with `ConstantProduct2.sol` as the Well function. 1. The protocol is in a state of `(400 ether, 100 ether)` (`reserve0, reserve1`). 2. An attacker Alice calls `swapFrom(t1, t1, 100 ether, 0)`. 3. At [L148](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb...
The protocol aims for a generalized constant function AMM (CFAMM) and the core invariant of the protocol is there are always more reserved tokens than the actual token balance (`reserves[i] >= tokens[i].balanceOf(well) for all i`). The incorrect implementation of `_getIJ()` allows attackers to break this invariant and ...
- Add a sanity check to revert if `fromToken==toToken` in the function `Well::swapFrom()` and `Well::swapTo()` . - Add a sanity check to revert if `iToken==jToken` in the function `Well::_getIJ()` assuming this internal function is not supposed to used with same tokens. - We strongly recommend adding a check in the fun...
3
true
true
6,248
high
high
token
Well.sol 566: function _getIJ(//@audit returns (i, 0) if iToken==jToken while it should return (i, i) 567: IERC20[] memory _tokens, 568: IERC20 iToken, 569: IERC20 jToken 570: ) internal pure returns (uint i, uint j) { 571: for (uint k; k < _tokens.length; ++k) { 572: ...
solidity
// Code block 1 (solidity): Well.sol 566: function _getIJ(//@audit returns (i, 0) if iToken==jToken while it should return (i, i) 567: IERC20[] memory _tokens, 568: IERC20 iToken, 569: IERC20 jToken 570: ) internal pure returns (uint i, uint j) { 571: for (uint k; k < _tokens.len...
3
Well.sol 566: function _getIJ(//@audit returns (i, 0) if iToken==jToken while it should return (i, i) 567: IERC20[] memory _tokens, 568: IERC20 iToken, 569: IERC20 jToken 570: ) internal pure returns (uint i, uint j) { 571: for (uint k; k < _tokens.length; ++k) { 572: ...
true
true
9.6
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-02
high
Attacker can steal reserves and subsequent liquidity deposits due to lack of input token validation
Attacker can steal reserves and subsequent liquidity deposits due to lack of input token validation ### Description The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. If one of the parameters `fromToken/toToken` is not in `_tokens`, this causes simil...
The protocol exposes an external function `Well::swapFrom()` which allows any caller to swap `fromToken` to `toToken`. If one of the parameters `fromToken/toToken` is not in `_tokens`, this causes similar issues in `_getIJ` with an index `i/j` being returned as zero. It appears you can specify a garbage `fromToken` to ...
Beliw is a test case to show this exploit scenario. The attacker can deploy his own garbage token and call `Well::swapFrom(garbageToken, tokens[1])` that drains the `tokens[0]` balance of the Well. Note that the similar exploit is also possible for `Well::swapTo()`. ```solidity function test_exploitGarbageFromToken() ...
The insufficient sanity check on the input tokens of `swapFrom()`(and `swapTo()`) allows attackers to extract tokens and break the protocol's invariant. Because this exploit does not require any additional assumptions, we evaluate the severity to HIGH.
- Add a sanity check to revert if either `iToken` or `jToken` is not found in the `_tokens` array. - We also strongly recommend adding a check in the function `Well::_executeSwap()` to make sure the Well has enough reserves on every transaction.
2
true
true
4,727
high
high
input-validation
function test_exploitGarbageFromToken() prank(user) public { // this is the maximum that can be sent to the well before hitting ByteStorage: too large uint256 inAmount = type(uint128).max - tokens[0].balanceOf(address(well)); IERC20 garbageToken = IERC20(new MockToken("GarbageToken", "GTKN", 18)); Mock...
solidity
// Code block 1 (solidity): function test_exploitGarbageFromToken() prank(user) public { // this is the maximum that can be sent to the well before hitting ByteStorage: too large uint256 inAmount = type(uint128).max - tokens[0].balanceOf(address(well)); IERC20 garbageToken = IERC20(new MockToken("GarbageTo...
2
function test_exploitGarbageFromToken() prank(user) public { // this is the maximum that can be sent to the well before hitting ByteStorage: too large uint256 inAmount = type(uint128).max - tokens[0].balanceOf(address(well)); IERC20 garbageToken = IERC20(new MockToken("GarbageToken", "GTKN", 18)); Mock...
true
true
7.76
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-03
high
`removeLiquidity` logic is not correct for general Well functions other than ConstantProduct
`removeLiquidity` logic is not correct for general Well functions other than ConstantProduct ### Description The protocol aims for a generalized permission-less CFAMM (constant function AMM) where various Well functions can be used. At the moment, only constant product Well function types are defined but we assume s...
The protocol aims for a generalized permission-less CFAMM (constant function AMM) where various Well functions can be used. At the moment, only constant product Well function types are defined but we assume support for more generalized Well functions are intended. The current implementation of `removeLiquidity()` and...
We wrote a test case with the quadratic Well function used by Numoen. ```solidity // QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uin...
The current `removeLiquidity()` logic assumes specific conditions on the Well function (specifically, some sort of linearity). This limits the generalization of the protocol, opposed to its original purpose. Because this will lead to loss of funds for the liquidity providers for general Well functions, we evaluate the ...
We believe that it is not possible to cover all kinds of Well functions without adding some additional functions in the interface `IWellFunction`. We recommend adding a new function in the `IWellFunction` interface, possibly in the form of `function calcWithdrawFromLp(uint lpTokenToBurn) returns (uint reserve)`. The o...
2
true
true
8,193
high
high
access-control
// QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uint; uint constant PRECISION = 1e18;//@audit-info assume 1:1 upperbound for this...
solidity
// Code block 1 (solidity): // QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uint; uint constant PRECISION = 1e18;//@audit-info as...
2
// QuadraticWell.sol /** * SPDX-License-Identifier: MIT **/ pragma solidity ^0.8.17; import "src/interfaces/IWellFunction.sol"; import "src/libraries/LibMath.sol"; contract QuadraticWell is IWellFunction { using LibMath for uint; uint constant PRECISION = 1e18;//@audit-info assume 1:1 upperbound for this...
true
true
9.35
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
H-04
high
Read-only reentrancy
Read-only reentrancy ### Description The current implementation is vulnerable to read-only reentrancy, especially in the function [removeLiquidity](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/Well.sol#L296). The implementation does not conform to the [CEI pattern](https:/...
The current implementation is vulnerable to read-only reentrancy, especially in the function [removeLiquidity](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/Well.sol#L296). The implementation does not conform to the [CEI pattern](https://fravoll.github.io/solidity-patterns/ch...
Below is a test case to show the existing read-only reentrancy. ```solidity // MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool ...
Although this is not a direct risk to the protocol itself as it is, this can lead to a critical issue in the future. We evaluate the severity to HIGH.
Implement the CEI pattern in relevant functions. For example, the function `Well::removeLiquidity` can be modified as below. ```solidity function removeLiquidity( uint lpAmountIn, uint[] calldata minTokenAmountsOut, address recipient ) external nonReentrant returns (uint[] memory tokenAmountsOut) { IER...
3
true
true
4,500
high
high
reentrancy
// MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool success, bytes memory result) = msg.sender.call(abi.encodeWithSignature("getR...
solidity
// Code block 1 (solidity): // MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool success, bytes memory result) = msg.sender.call(a...
3
// MockCallbackRecipient.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.17; import {console} from "forge-std/Test.sol"; contract MockCallbackRecipient { fallback() external payable { console.log("here"); (bool success, bytes memory result) = msg.sender.call(abi.encodeWithSignature("getR...
true
true
9.26
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
M-01
medium
Insufficient support for fee-on-transfer ERC20 tokens
Insufficient support for fee-on-transfer ERC20 tokens ### Description The Well does not rely on the `balanceOf()` function from ERC20 to retrieve current reserve balances. This is a good design choice. Reserves values stored in the protocol should be equal to or less than the actual balance. The current implementati...
The Well does not rely on the `balanceOf()` function from ERC20 to retrieve current reserve balances. This is a good design choice. Reserves values stored in the protocol should be equal to or less than the actual balance. The current implementation assumes `safeTransfer()` will always increase the actual balance equa...
null
Because this vulnerability is dependent on the tokens, we evaluate the severity to MEDIUM.
- If the protocol does not intend to support these kinds of tokens, prevent them by checking the actual balance increase after calling safeTransfer. - If the protocol wants to support any kind of ERC20 tokens, use a hook method so that the caller can decide the sending amount and check the balance increase amount after...
0
false
true
1,197
medium
medium
token
0
true
false
3.83
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
M-02
medium
Some tokens revert on transfer of zero amount
Some tokens revert on transfer of zero amount ### Description Well protocol intends to be used with various ERC20 tokens. Some ERC20 tokens revert on transferring zero amount and it is recommended to transfer only when the amount is positive.([Ref](https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers)) ...
Well protocol intends to be used with various ERC20 tokens. Some ERC20 tokens revert on transferring zero amount and it is recommended to transfer only when the amount is positive.([Ref](https://github.com/d-xo/weird-erc20#revert-on-zero-value-transfers)) In several places, the current implementation does not check the...
null
For some ERC20 tokens, the protocol's important functions (e.g. `removeLiquidity`) would revert and this can lead to insolvency. We evaluate the severity to MEDIUM.
Check the transfer amount to be positive before calling transfer functions.
0
false
true
983
medium
medium
token
0
true
false
3.77
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
M-03
medium
Need to make sure the tokens are unique for ImmutableTokens
Need to make sure the tokens are unique for ImmutableTokens ### Description The current implementation does not enforce uniqueness in the `_tokens` of `ImmutableTokens`. Assuming `_tokens[0]=_tokens[1]`. An honest liquidity provider calls `addLiquidity([1 ether,1 ether], 200 ether, address)`, resulting in the reserv...
The current implementation does not enforce uniqueness in the `_tokens` of `ImmutableTokens`. Assuming `_tokens[0]=_tokens[1]`. An honest liquidity provider calls `addLiquidity([1 ether,1 ether], 200 ether, address)`, resulting in the reserves being `(1 ether, 1 ether)`. At this point, anyone can call the function `sk...
null
Assuming normal liquidity providers are smart enough to check the tokens before sending funds, the likelihood is low, hence we evaluate the severity to MEDIUM.
Enforce uniqueness of the array `_tokens` in `ImmutableTokens`. This can also be done in the function `ImmutableTokens::getTokenFromList()`.
0
false
true
874
medium
medium
token
0
true
false
3.41
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
L-01
low
Incorrect sload in LibBytes
Incorrect sload in LibBytes ### Description The function `storeUint128` in `LibBytes` intends to pack uint128 `reserves` starting at the given slot but will actually overwrite the final slot if [storing an odd number of reserves](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/sr...
The function `storeUint128` in `LibBytes` intends to pack uint128 `reserves` starting at the given slot but will actually overwrite the final slot if [storing an odd number of reserves](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibBytes.sol#L78). It is currently...
The following test case demonstrates this issue more clearly: ```solidity // NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot =...
Given that assets are not directly at risk, we evaluate the severity to LOW.
Implement the following fix to load the existing value from storage and pack in the lower bits: ```solidity sload(add(slot, mul(maxI, 32))) ``` ![Output after mitigation](Screenshot_2023-02-13_at_17.07.07.jpg)
2
true
true
3,334
low
low
token
// NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot = RESERVES_STORAGE_SLOT; uint256 maxI = (NUM_RESERVES_MAX - 1) / 2; ...
solidity
// Code block 1 (solidity): // NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot = RESERVES_STORAGE_SLOT; uint256 maxI = (NUM...
2
// NOTE: Add to LibBytes.t.sol function test_exploitStoreAndRead() public { // Write to storage slot to demonstrate overwriting existing values // In this case, 420 will be stored in the lower 128 bits of the last slot bytes32 slot = RESERVES_STORAGE_SLOT; uint256 maxI = (NUM_RESERVES_MAX - 1) / 2; ...
true
true
8.41
high
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-01
informational
Non-standard storage packing
Non-standard storage packing Per the [Solidity docs](https://docs.soliditylang.org/en/v0.8.17/internals/layout_in_storage.html), the first item in a packed storage slot is stored lower-order aligned; however, [manual packing](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/lib...
null
null
null
null
0
false
false
495
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-02
informational
EIP-1967 second pre-image best practice
EIP-1967 second pre-image best practice When calculating custom [EIP-1967](https://eips.ethereum.org/EIPS/eip-1967) storage slots, as in [Well.sol::RESERVES_STORAGE_SLOT](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/Well.sol#L37), it is [best practice](https://ethereum-magic...
null
null
null
null
0
false
false
493
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-03
informational
Remove experimental ABIEncoderV2 pragma
Remove experimental ABIEncoderV2 pragma ABIEncoderV2 is enabled by default in Solidity 0.8, so [two](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/interfaces/IWellFunction.sol#L6) [instances](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe...
null
null
null
null
0
false
false
366
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-04
informational
Inconsistent use of decimal/hex notation in inline assembly
Inconsistent use of decimal/hex notation in inline assembly For readability and to prevent errors when working with inline assembly, decimal notation should be used for integer constants and hex notation for memory offsets.
null
null
null
null
0
false
false
223
informational
informational
rounding
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-05
informational
Unused variables, imports and errors
Unused variables, imports and errors In `LibBytes`, the [`temp` variable]((https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibBytes.sol#L39)) of `storeUint128` is unused and should be removed. In `LibMath`: - OpenZeppelin SafeMath is imported but not used - `PRBMath_...
null
null
null
null
0
false
false
369
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-06
informational
Inconsistency in LibMath comments
Inconsistency in LibMath comments There is inconsistent use of `x` in comments and `a` in code within the `nthRoot` and `sqrt` [functions](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibMath.sol#L44-L147) of `LibMath`.
null
null
null
null
0
false
false
274
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-07
informational
FIXME and TODO comments
FIXME and TODO comments There are several [FIXME](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/interfaces/IWell.sol#L268) and [TODO](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibMath.sol#L36) comments that should be a...
null
null
null
null
0
false
false
329
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-08
informational
Use correct NatSpec tags
Use correct NatSpec tags Uses of `@dev See {IWell.fn}` should be replaced with `@inheritdoc IWell` to inherit the NatSpec documentation from the interface.
null
null
null
null
0
false
false
155
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-09
informational
Format for readability
Format for readability For readability, code should be formatted according to the [Solidity Style Guide](https://docs.soliditylang.org/en/v0.8.17/style-guide.html#other-recommendations) which includes surrounding operators with a single space on either side: e.g. [`numberOfBytes0 - 1`](https://github.com/BeanstalkFarms...
null
null
null
null
0
false
false
408
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
NC-10
informational
Spelling errors
Spelling errors The following spelling errors were identified: - ['configurating'](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/interfaces/IWell.sol#L110) should become 'configuration' - ['Pump'/'_pumo'](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf9...
null
null
null
null
0
false
false
383
informational
informational
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
G-1
gas
Simplify modulo operations
Simplify modulo operations In `LibBytes::storeUint128` and `LibBytes::readUint128`, `reserves.lenth % 2 == 1` and `i % 2 == 1` can be simplified to `reserves.length & 1 == 1` and `i & 1 == 1`.
null
null
null
null
0
false
false
192
informational
gas
other
0
false
false
0
low
cyfrin
2023-03-13-beanstalk_wells_v0.1
Beanstalk Wells Initial Audit Report
March 13, 2023
G-2
gas
Branchless optimization
Branchless optimization The `sqrt` function in `MathLib` and [related comment](https://github.com/BeanstalkFarms/Wells/blob/7c498215f843620cb24ec5bbf978c6495f6e5fe4/src/libraries/LibMath.sol#L136-L145) should be updated to reflect changes in Solmate's `FixedPointMathLib` which now includes the [branchless optimization]...
null
null
null
null
0
false
false
485
informational
gas
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
M-01
medium
Bad signature validation, malleability & lack of zero address protection in `updateValidatorSet`
Bad signature validation, malleability & lack of zero address protection in `updateValidatorSet` ### Description The `ecrecover` built-in will return `address(0)` if it fails to recover the signer from a message digest and corresponding signature. There is no `address(0)` check in [`Signature::recoverSigner`](https:/...
The `ecrecover` built-in will return `address(0)` if it fails to recover the signer from a message digest and corresponding signature. There is no `address(0)` check in [`Signature::recoverSigner`](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L62) or [`Bridge:...
The following forge test can be seen to demonstrate these findings: ```solidity function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = Validator...
Given the vulnerability described has a low likelihood but high impact, we evaluate the severity to MEDIUM.
As mentioned above, it is recommended to correctly validate recovered signers and protect against signature malleability by using the [OpenZeppelin ECDSA library](https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol). Additionally, add zero address validation to `Bri...
1
true
true
8,406
medium
medium
input-validation
function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = ValidatorSet(0, s_validators,s_powers); Signature[] memory sigs = _getSignatures(sende...
solidity
// Code block 1 (solidity): function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = ValidatorSet(0, s_validators,s_powers); Signature[] memory...
1
function test_signatureMalleabilityAndBadValidation() public { address sender = makeAddr("alice"); address pwner = makeAddr("pwner"); uint256 amount = 1e5; uint256 nonce = 0; ValidatorSet memory validatorSet = ValidatorSet(0, s_validators,s_powers); Signature[] memory sigs = _getSignatures(sende...
true
true
8.5
high
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
M-02
medium
Incorrect initialization of `powerThreshold` and lack of validation
Incorrect initialization of `powerThreshold` and lack of validation ### Description The `Bridge::powerThreshold` should be 2/3 the sum of the validator power across current validators at any point; however, the [calculation](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Br...
The `Bridge::powerThreshold` should be 2/3 the sum of the validator power across current validators at any point; however, the [calculation](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L94) in `Bridge2::constructor` is not correct and it's initialized to `(2 * _...
null
It is possible malicious actions that are lack of validation power are allowed due to wrong initialization of `powerThreshold`. Because the initializer is assumed to be called by an admin and there is also another admin function to change the `powerThreshold`, we evaluate the severity to MEDIUM.
- Initialize `powerThreshold` to the 2/3 the sum of the initial validator powers. - Add validation for the new `powerThreshold` in `Bridge::changePowerThreshold()` to allow only reasonable values (ranging from 2/3 to total of the current cumulative validation power).
0
false
true
2,686
medium
medium
access-control
0
true
false
5.5
medium
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
L-01
low
Prevent setting the new epoch to an arbitrary large value
Prevent setting the new epoch to an arbitrary large value ### Description In the function `Bridge::updateValidatorSet`, the new epoch is [checked](https://github.com/ChainAccelOrg/hyperliquid-audit/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L213) to be greater than the current epoch. However, there is n...
In the function `Bridge::updateValidatorSet`, the new epoch is [checked](https://github.com/ChainAccelOrg/hyperliquid-audit/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L213) to be greater than the current epoch. However, there is no check to prevent setting the new epoch to an arbitrary large value which c...
null
This is not likely to happen but we evaluate as LOW because it can freeze the protocol, locking funds and effectively make the whole protocol insolvent.
It is recommended to allow increase of epoch only to some limited extent, rather than any arbitrary large number.
0
false
true
1,169
low
low
other
0
true
false
3.35
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-01
informational
Make `minTotalValidatorPower` immutable
Make `minTotalValidatorPower` immutable Given that `Bridge::minTotalValidatorPower` is initialized once in the constructor and never modified thereafter, it can be made immutable. This also has the effect of reducing gas usage in functions which currently read its value from storage. ### `f045dbf` Resolution `minTot...
null
null
null
null
0
false
false
355
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-02
informational
Avoid using an initializer unless absolutely necessary
Avoid using an initializer unless absolutely necessary [This comment](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L85-L86) references the potential introduction of a separate initializer but it should be noted that bad initialization is the cause of many exploi...
null
null
null
null
0
false
false
435
informational
informational
initialization
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-03
informational
Use calldata for all function arguments that are not modified
Use calldata for all function arguments that are not modified If function arguments are not intended to be modified then it is best practice to pass them as calldata arguments rather than memory, for example in [https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#LL94C...
null
null
null
null
0
false
false
618
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-04
informational
`updateValidatorSet` block scope is not necessary
`updateValidatorSet` block scope is not necessary The block scope in `Bridge::updateValidatorSet` is not necessary as the contract successfully compiles without it and so can be removed. ### `f045dbf` Resolution The block scope has been removed.
null
null
null
null
0
false
false
248
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-05
informational
Emit events before interaction
Emit events before interaction To strictly conform to checks-effect-interactions, it is recommended to emit events prior to any [external interactions](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L122-L123). This is generally advised to ensure correct migration...
null
null
null
null
0
false
false
556
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-06
informational
Make USDC amount naming more verbose
Make USDC amount naming more verbose The naming of the USDC amount parameter in [`Bridge::deposit and Bridge::withdraw`](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L120-L152) is not clear, i.e. change `uint256 usdc` to `uin256 usdcAmount`. ### `f045dbf` Resol...
null
null
null
null
0
false
false
559
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-07
informational
Rename file to `Bridge2.sol` to match the contract name
Rename file to `Bridge2.sol` to match the contract name The `Bridge2` contract resides in `Bridge.sol`; however, it is best practice to follow the convention of one contract per file with the same name. ### `f045dbf` Resolution The client team has renamed the contract to `Bridge.sol` with the following comment: > W...
null
null
null
null
0
false
false
438
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-08
informational
Add missing NatSpec comments to document function parameters and behaviour
Add missing NatSpec comments to document function parameters and behaviour It is recommended to document all function behaviours and parameters, especially if they are public-facing. ### `f045dbf` Resolution The client team acknowledges this finding with the following comment: > Light comments were added to functio...
null
null
null
null
0
false
false
339
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-09
informational
No need to explicitly initialize variables to 0
No need to explicitly initialize variables to 0 Variables are initalized to 0 by default in Solidity, so a [number](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L169-L170) of [superfluous](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c0945070...
null
null
null
null
0
false
false
566
informational
informational
initialization
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-10
informational
Use addition assignment operator
Use addition assignment operator The addition assignment operator `+=` can be used when [checking new validator powers](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Bridge.sol#L238). ### `f045dbf` Resolution The addition assignment operator has been used.
null
null
null
null
0
false
false
304
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-11
informational
Localhost chain id can be 1337 or 31337
Localhost chain id can be 1337 or 31337 The default localhost chain id for some frameworks (e.g. HardHat) is `31337` rather than `1337`. For example, it is not possible to run signature tests using forge without changing `Signature::LOCALHOST_CHAIN_ID` to `31337`. ### `f045dbf` Resolution This has been resolved by t...
null
null
null
null
0
false
false
343
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-12
informational
Rename to DOMAIN_SEPARATOR and use `block.chainId` directly
Rename to DOMAIN_SEPARATOR and use `block.chainId` directly References to `*_DOMAIN_HASH` in `Signature` should be renamed to `*_DOMAIN_SEPARATOR` to be more consistent with the EIP and avoid confusion. Additionally, it is recommended to use `block.chainId` directly, caching on contract creation and only recomputing t...
null
null
null
null
0
false
false
782
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-13
informational
Rename to `EIP712_DOMAIN_TYPEHASH`
Rename to `EIP712_DOMAIN_TYPEHASH` Add an [additional underscore](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L19) for readability. ### `f045dbf` Resolution The constant has been renamed to `EIP712_DOMAIN_TYPEHASH`.
null
null
null
null
0
false
false
279
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-14
informational
Include `byte32 salt` in domain typehash
Include `byte32 salt` in domain typehash Per the [EIP](https://eips.ethereum.org/EIPS/eip-712), `bytes32 salt` should be added to the [domain separator](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L20) as a last-resort means to distinguish this application f...
null
null
null
null
0
false
false
934
informational
informational
other
0
false
false
0
low
cyfrin
hyperliquid-dex-report
Cyfrin Hyperliquid Audit Report
April 11, 2023
NC-15
informational
Verifying contract TODO
Verifying contract TODO Update the [verifying contract address](https://github.com/hyperliquid-dex/contracts/blob/e0aff464865aa98c09450702d7fb36b1fcd4508c/Signature.sol#L25). ### `f045dbf` Resolution The client team acknowledges this finding with the following comment: > Removed the TODO. Keeping the verifying addr...
null
null
null
null
0
false
false
431
informational
informational
other
0
false
false
0
low
End of preview. Expand in Data Studio

No dataset card yet

Downloads last month
7