crytic / crytic/slither

slither-read-storage `--table` prints variables from imported contracts with incorrect values

Open
#1,750 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

In addition to printing the variables in the Unitroller's storage layout, `slither-read-storage 0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b --value --table --rpc-url ` is printing variables it found in other imported contracts, some of which do not belong in the Unitroller's storage.

Specifically, it is including variables from `ComptrollerV1Storage`, which technically are stored in the Unitroller's storage. So the values are correct, though the variables are not directly inherited by the Unitroller contract. It is also including variables declared in `CToken`, which is a completely separate contract with its own storage. As a result, the tool is reporting incorrect values for these variables, since it is reading from the Untroller's storage and not the CToken's.

### Code example to reproduce the issue:

https://etherscan.io/address/0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b#code

`slither-read-storage 0x3d9819210a31b4961b30ef54be2aed79b9c9cd3b --value --table --rpc-url `

### Version:

0.9.2 (current dev branch)

### Relevant log output:

```shell
+----------------------------------+-------------------------------------------------+------+------+--------+---------------------------------------------------+
| name | type_string | slot | size | offset | value |
+----------------------------------+-------------------------------------------------+------+------+--------+---------------------------------------------------+
| accountAssets | mapping(address => CToken[]) | 8 | 256 | 0 | 0 |
| maxAssets | uint256 | 7 | 256 | 0 | 20 |
| liquidationIncentiveMantissa | uint256 | 6 | 256 | 0 | 1080000000000000000 |
| closeFactorMantissa | uint256 | 5 | 256 | 0 | 500000000000000000 |
| oracle | PriceOracle | 4 | 160 | 0 | 50ce56a3239671ab62f185704caedf626352741e |
| pendingComptrollerImplementation | address | 3 | 160 | 0 | 0x0000000000000000000000000000000000000000 |
| comptrollerImplementation | address | 2 | 160 | 0 | 0xBafE01ff935C7305907c33BF824352eE5979B526 |
| accountBorrows | mapping(address => CToken.BorrowSnapshot) | 17 | 256 | 0 | 0 |
| transferAllowances | mapping(address => mapping(address => uint256)) | 16 | 256 | 0 | 0 |
| accountTokens | mapping(address => uint256) | 15 | 256 | 0 | 0 |
| totalSupply | uint256 | 14 | 256 | 0 | 176000000000000000 |
| totalReserves | uint256 | 13 | 256 | 0 | 20 |
| totalBorrows | uint256 | 12 | 256 | 0 | 0 |
| borrowIndex | uint256 | 11 | 256 | 0 | 0 |
| accrualBlockNumber | uint256 | 10 | 256 | 0 | 1073021371786102711066046704037845102107483570476 |
| reserveFactorMantissa | uint256 | 9 | 256 | 0 | 0 |
| initialExchangeRateMantissa | uint256 | 8 | 256 | 0 | 0 |
| interestRateModel | InterestRateModel | 7 | 160 | 0 | 0000000000000000000000000000000000000014 |
| comptroller | ComptrollerInterface | 6 | 160 | 0 | 0000000000000000000000000efcee47256c0000 |
| pendingAdmin | address | 1 | 160 | 0 | 0x0000000000000000000000000000000000000000 |
| admin | address | 0 | 160 | 0 | 0x6d903f6003cca6255D85CcA4D3B5E5146dC33925 |
| decimals | uint256 | 3 | 256 | 0 | 0 |
| symbol | string | 2 | 256 | 0 | 1067536846733826965994198726057517433926444496166 |
| name | string | 1 | 256 | 0 | |
| _guardCounter | uint256 | 0 | 256 | 0 | 625496822074558125566300987011552446920364603685 |
+----------------------------------+-------------------------------------------------+------+------+--------+---------------------------------------------------+
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.