diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e25a7ba7..faabbdf18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 2.0.4 + +### Security + +* (IRISHub) [\#2860](https://github.com/irisnet/irishub/pull/2860) Disable the vesting account creation to prevent contract address front-running. + ## 2.0.3 ### Improvements diff --git a/ante/handler_options.go b/ante/handler_options.go index 4dfa99353..c9d9a3f05 100644 --- a/ante/handler_options.go +++ b/ante/handler_options.go @@ -72,6 +72,7 @@ func newCosmosAnteHandler(options HandlerOptions) sdk.AnteHandler { NewValidateServiceDecorator(), ante.NewIncrementSequenceDecorator(options.AccountKeeper), ibcante.NewRedundantRelayDecorator(options.IBCKeeper), + NewRejectVestingDecorator(), ) } diff --git a/ante/vesting.go b/ante/vesting.go new file mode 100644 index 000000000..f8987e1ee --- /dev/null +++ b/ante/vesting.go @@ -0,0 +1,27 @@ +package ante + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types" +) + +// RejectVestingDecorator is responsible for rejecting the vesting msg +type RejectVestingDecorator struct{} + +// NewRejectVestingDecorator returns an instance of ValidateVestingDecorator +func NewRejectVestingDecorator() RejectVestingDecorator { + return RejectVestingDecorator{} +} + +// AnteHandle checks the transaction +func (vvd RejectVestingDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) { + for _, msg := range tx.GetMsgs() { + switch msg.(type) { + case *vestingtypes.MsgCreateVestingAccount, *vestingtypes.MsgCreatePermanentLockedAccount, *vestingtypes.MsgCreatePeriodicVestingAccount: + return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "currently doesn't support creating vesting account") + } + } + return next(ctx, tx, simulate) +}