Acton
Linting rules

E017: unauthorized-access

Detects storage mutations (`contract.setData(...)`, `*.save()`) that are reachable without a preceding admin sender check.

Metadata

  • Code: E017
  • Rule: unauthorized-access
  • Status: Preview since v0.0.1
  • Quick fix: sometimes available

What it does

Detects storage mutations (contract.setData(...), *.save()) that are reachable without a preceding admin sender check.

Why is this bad?

State-changing operations that are not guarded by admin authorization may allow arbitrary inbound senders to mutate contract storage.

Example

fun onInternalMessage(in: InMessage) {
    val storage = lazy Storage.fromCell(contract.getData());
    storage.save();
E017: possible storage write without admin sender check
}

Use instead:

fun onInternalMessage(in: InMessage) {
    val storage = lazy Storage.fromCell(contract.getData());
    assert (in.senderAddress == storage.adminAddress) throw ERR_UNAUTHORIZED;
    storage.save();
}
Source code

Last updated on

On this page