Skip to content

Latest commit

 

History

History
31 lines (21 loc) · 717 Bytes

non-private-callback.md

File metadata and controls

31 lines (21 loc) · 717 Bytes

Lack of #[private] macro in callback functions

Configuration

  • detector id: non-private-callback
  • severity: high

Description

The callback function should be decorated with #[private] to ensure that it can only be invoked by the contract itself.

Without this macro, anyone can invoke the callback function, which is against the original design.

Sample code

pub fn callback_stake(&mut self) { // this is a callback function
    // ...
}

Function callback_stake should be decorated with #[private]:

#[private]
pub fn callback_stake(&mut self) { // this is a callback function
    // ...
}

With this macro, only the contract itself can invoke callback_stake.