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

QA Report #78

Open
code423n4 opened this issue Mar 9, 2022 · 0 comments
Open

QA Report #78

code423n4 opened this issue Mar 9, 2022 · 0 comments
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax

Comments

@code423n4
Copy link
Contributor

(https://github.com/code-423n4/2022-02-anchor/blob/main/contracts/anchor-bAsset-contracts/contracts/anchor_basset_hub/src/unbond.rs#L42-L49)

Within execute_unbond() If threshold and other variables are not checked (non-zero value), it will lead to loss of value

Ensure that the threshold is set to greater than zero as in the event that the exchange rate is in the lower bound, it will not be checked properly as it will always be higher than the threshold(if this value is zero) . Also, recovery_fee should be non-zero as well since it is used to calculate max_fee(output will be zero). This will have an impact on amount_with_fee as the user will not be charged with any fee since peg_fee will always return 0(since max_fee will indefinitely be returned as the minimum of the two values) on line 46..

This is also the case for current_batch.requested_with_fee.

In the call to state.update_exchange_rate(), a higher exchange rate will be returned since it's only using the amount without adding the fee. See:

(https://github.com/code-423n4/2022-02-anchor/blob/7af353e3234837979a19ddc8093dc9ad3c63ab6b/contracts/anchor-bAsset-contracts/packages/basset/src/hub.rs#L44)

store_unbond_history() will include the flawed values

This is also the case for :

(https://github.com/code-423n4/2022-02-anchor/blob/7af353e3234837979a19ddc8093dc9ad3c63ab6b/contracts/anchor-bAsset-contracts/contracts/anchor_basset_hub/src/bond.rs#L61)
get_finished_amount() will return a higher withdrawable amount.

Fix:

If recovery_fee & & threshold ==Decimal::zero() & & current_batch.requested_with_fee ==Uint128::zero{

return Err(Std::generic_err( “”)) ;

}

@code423n4 code423n4 added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax bug Something isn't working labels Mar 9, 2022
code423n4 added a commit that referenced this issue Mar 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax
Projects
None yet
Development

No branches or pull requests

1 participant