Skip to content

Security: 0xSidius/cairo-contracts

Security

docs/Security.md

Security

The following documentation provides context, reasoning, and examples of methods and constants found in openzeppelin/security/.

Expect this module to evolve.

Table of Contents

Reentrancy Guard

A reentrancy attack occurs when the caller is able to obtain more resources than allowed by recursively calling a target’s function.

Since Cairo does not support modifiers like Solidity, the reentrancy_guard library exposes two methods ReentrancyGuard_start and ReentrancyGuard_end to protect functions against reentrancy attacks. The protected function must call ReentrancyGuard_start before the first function statement, and ReentrancyGuard_end before the return statement, as shown below:

from openzeppelin.security.reentrancy_guard import (
    ReentrancyGuard_start,
    ReentrancyGuard_end
)

func test_function{
        syscall_ptr : felt*, 
        pedersen_ptr : HashBuiltin*,
        range_check_ptr
    }():
   ReentrancyGuard_start()
   # function body
   ReentrancyGuard_end()
   return ()
end

There aren’t any published security advisories