You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The unhandled errors in the SendCoins operation can lead to the possibility of executing a CommitParticipation action without any payment. In the code referenced, the errors returned from SendCoins are not properly processed, resulting in the inability for tracking errors due to insufficient balance. Consequently, malicious users can perform CommitParticipation actions without incurring any costs.
func (kKeeper) CommitParticipation(ctx sdk.Context, participant sdk.AccAddress, msg*types.MsgCommitParticipationRequest) error {
// get IDOido, err:=k.GetIDOByID(ctx, msg.ProjectId)
iferr!=nil {
returnerr
}
// get projectproject, err:=k.launchpadKeeper.GetProjectById(ctx, msg.ProjectId)
iferr!=nil {
returnerr
}
// validatevartokenBought sdk.Coinsvarentry types.Entryiferr:=k.validateCommitParticipation(ctx, participant, &tokenBought, &entry, ido, project, msg); err!=nil {
returnerr
}
// transfer funds from user wallet to project and vice versak.bankKeeper.SendCoins(ctx, sdk.AccAddress(project.GetProjectAddress()), participant, tokenBought)
k.bankKeeper.SendCoins(ctx, participant, sdk.AccAddress(project.GetProjectAddress()), msg.GetTokenCommit())
ido.TokenForDistribution=ido.TokenForDistribution.Sub(tokenBought)
ido.TotalDistributedAmount=ido.TotalDistributedAmount.Add(tokenBought...)
// update entriesido.Entries[entry.Participant] =entry// save IDO to KV stores and register to launchpadiferr:=k.SetIDOAndRegisterLaunchpad(ctx, ido); err!=nil {
returnerr
}
returnnil
}
Intro
The unhandled errors in the SendCoins operation can lead to the possibility of executing a
CommitParticipation
action without any payment. In the code referenced, the errors returned fromSendCoins
are not properly processed, resulting in the inability for tracking errors due to insufficient balance. Consequently, malicious users can perform CommitParticipation actions without incurring any costs.Link to Code
Recommendation
Implement an error handling mechanism for the SendCoins operation.
REF
ignite/cli#2828
https://github.com/crytic/building-secure-contracts/tree/master/not-so-smart-contracts/cosmos/missing_error_handler
The text was updated successfully, but these errors were encountered: