arkeonetwork / arkeo

Arkeo - Free Market Blockchain Data Infrastructure
Other
19 stars 20 forks source link

attacker can close other people's contracts #264

Open cbarraford opened 3 months ago

cbarraford commented 3 months ago

haven't tested this, but see if this makes sense, might be missing something as usual: An attacker can close any contract.

For a CloseContract message, the delegate is used as the key for the contract via FetchSpender():

https://github.com/ArkeoNetwork/arkeo-protocol/blob/master/x/arkeo/types/message_close_contract.go#L57

If a target contract exists, an attacker can send a CloseContract message: { PubKey: , Delegate: , Client: }

This should pass ValidateBasic() and move on to the handler.

In the handler's validate, the contract is looked up using this delegate address, pulling down the target's contract. Since client is not set on the message, it then passes validation:

https://github.com/ArkeoNetwork/arkeo-protocol/blob/master/x/arkeo/keeper/msg_server_close_contract.go#L49-L55

In the handle function, the contract is again looked up by the delegate and the contract is settled, without the authorization of the target contract's client:

https://github.com/ArkeoNetwork/arkeo-protocol/blob/master/x/arkeo/keeper/msg_server_close_contract.go#L82

InnovationTheory commented 2 months ago