Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EXT-SEC-AUDIT] Failure to return error in initTotalSupply() method #2809

Closed
pro-wh opened this issue Apr 1, 2020 · 1 comment · Fixed by #2813
Closed

[EXT-SEC-AUDIT] Failure to return error in initTotalSupply() method #2809

pro-wh opened this issue Apr 1, 2020 · 1 comment · Fixed by #2813

Comments

@pro-wh
Copy link
Contributor

pro-wh commented Apr 1, 2020

Issue transferred from an external security audit report.

Severity: Informational
Difficulty: Undetermined
Type: Error Reporting
Finding ID: TOB-OL-107
Target: go/consensus/tendermint/apps/staking/genesis.go

Description

initTotalSupply() checks and logs an error if the total supply mismatches between the
expected state value and the supplied method argument, but does not actually return an
error. Instead it goes ahead and sets the total supply of the state to the supplied method
argument. Also, as a separate but co-located code quality issue,
state.SetCommonPool(&st.CommonPool) here appears to be unnecessary.

Figure TOB-OL-106.1 shows https://github.com/oasislabs/oasis-core/blob/f331a877721f44cc2412b4248d66e95f83f4cf9c/go/consensus/tendermint/apps/staking/genesis.go#L112-L122

Exploit Scenario

A typo occurs in the genesis document. totalSupply is instantiated as a zero value and has
the value of CommonPool when passed into initTotalSupply . An error is logged but the
function executes successfully. If the logged error is not noticed this leads to a corrupted
state where totalSupply ’s value is inconsistent with the genesis document.

Recommendation

Return an error corresponding to the total supply mismatch between expected (i.e. state)
and actual values (i.e. method argument) and check it at the call site. Delete
state.SetCommonPool(&st.CommonPool).

@kostko
Copy link
Member

kostko commented Apr 2, 2020

Also, as a separate but co-located code quality issue, state.SetCommonPool(&st.CommonPool) here appears to be unnecessary.

Huh? I don't see any other place that initializes the common pool, so it is very necessary. (We could move it to initCommonPool instead though.)

Also note that the total supply mismatch would actually be caught by genesis document sanity checks. But returning an error here is probably the right thing to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants