Skip to content

Detectors

camden-smallwood edited this page Nov 3, 2023 · 4 revisions

Arbitrary Asset Transfer

  • Name: arbitrary_asset_transfer
  • Severity: 🔴 High

Description

Checks for functions that transfer native assets to an arbitrary address without access restriction.

Exploit Scenario

Test scenarios

Recommendation

Ensure that an arbitrary user cannot access unauthorised funds.

Arbitrary Code Execution

  • Name: arbitrary_code_execution
  • Severity: 🔴 High

Description

Checks for functions that make use of the LDC assembly instruction without access restriction.

Exploit Scenario

Test scenarios

Recommendation

Ensure that only the contract’s owner can fetch code from a set of whitelisted addresses.

Boolean Comparison

  • Name: boolean_comparison
  • Severity: 🟢 Low

Description

Checks if an expression contains a comparison with a boolean literal, which is unnecessary.

Exploit Scenario

Test scenarios

Recommendation

Remove the redundant boolean literal.

Discarded Assignment

  • Name: discarded_assignment
  • Severity: 🔴 High

Description

Checks for variables that are assigned to without being utilized.

Exploit Scenario

Test scenarios

Recommendation

Remove the redundant code or utilize such variables.

Division Before Multiplication

  • Name: division_before_multiplication
  • Severity: 🟢 Low

Description

Checks for division operations before multiplications, which can result in value truncation.

Exploit Scenario

Test scenarios

Recommendation

Do the multiplication before the division to avoid truncating the result.

Explicit Return Statement

  • Name: explicit_return_statement
  • Severity: 🟢 Low

Description

Checks for functions that end with explicit return statements, which is unnecessary.

Exploit Scenario

Test scenarios

Recommendation

Opt for the rust-like coding style for the returned value.

External Call In Loop

  • Name: external_call_in_loop
  • Severity: 🟡 Medium

Description

Checks if any functions contain any loops which performs calls to external functions.

Exploit Scenario

Test scenarios

Recommendation

Avoid external calls in a loop, especially in one of dynamic size.

Inline Assembly Usage

  • Name: inline_assembly_usage
  • Severity: 🟡 Medium

Description

Checks functions for inline assembly usage.

Exploit Scenario

Test scenarios

Recommendation

Avoid using low-level assembly unless it’s necessary.

Large Literal

  • Name: large_literal
  • Severity: 🟢 Low

Description

Checks for expressions that contain large literal values, which may be difficult to read or interpreted incorrectly.

Exploit Scenario

Test scenarios

Recommendation

Consider delineating large literal values with underscores to improve readability, e.g: 1_234_567_890

Locked Native Asset

  • Name: locked_native_asset
  • Severity: 🔴 High

Description

Checks if a contract can withdraw potential incoming native assets.

Exploit Scenario

Test scenarios

Recommendation

Consider adding a withdraw function.

Magic Number

  • Name: magic_number
  • Severity: 🟢 Low

Description

Checks for expressions that contain irregular numerical constants that can be introduced as named constants.

Exploit Scenario

Test scenarios

Recommendation

Create named constants for magic numbers to improve code readability.

Manipulatable Balance Usage

  • Name: manipulatable_balance_usage
  • Severity: 🟡 Medium

Description

Checks if any functions contain balance usage which can potentially be manipulated.

Exploit Scenario

Test scenarios

Recommendation

Ensure that contracts do not rely on an asset's balance for critical computations.

Missing Logs

  • Name: missing_logs
  • Severity: 🟡 Medium

Description

Checks for publicly-accessible functions that make changes to storage variables without emitting logs.

Exploit Scenario

Test scenarios

Recommendation

Emit logs for critical storage variable changes.

Msg Amount In Loop

  • Name: msg_amount_in_loop
  • Severity: 🟡 Medium

Description

Checks for calls to std::context::msg_amount() or std::registers::balance() inside a while loop. In most cases, the result of the call should be stored in a local variable and decremented over each loop iteration.

Exploit Scenario

Test scenarios

Recommendation

Store the value of std::context::msg_amount() or std::registers::balance() in a local variable and decrement it over each loop iteration.

Non Zero Identity Validation

  • Name: non_zero_identity_validation
  • Severity: 🟢 Low

Description

Checks to see if functions containing Identity, Address and ContractId parameters are checked for a zero value.

Exploit Scenario

Test scenarios

Recommendation

Add the necessary require checks for all Identity, Address and ContractId parameters.

Potential Infinite Loop

  • Name: potential_infinite_loop
  • Severity: 🔴 High

Description

Checks for potentially infinite loops.

Exploit Scenario

Test scenarios

Recommendation

Ensure that loops have a defined range and exit point in order to prevent infinite loops.

Redundant Comparison

  • Name: redundant_comparison
  • Severity: 🟡 Medium

Description

Checks for functions that make redundant comparisons.

Exploit Scenario

Test scenarios

Recommendation

Avoid redundant comparisons to reduce the gas used or avoid a logical issue.

Redundant Storage Access

  • Name: redundant_storage_access
  • Severity: 🟡 Medium

Description

Checks for redundant calls to storage.x.read() and storage.x.write(x).

Exploit Scenario

Test scenarios

Recommendation

Use local variables to hold the storage lookup result.

Storage Field Mutability

  • Name: storage_field_mutability
  • Severity: 🟢 Low

Description

Checks for any storage fields that can be refactored into constants or configurable fields.

Exploit Scenario

Test scenarios

Recommendation

Consider changing such storage fields with constants or configurable fields to reduce the gas cost.

Storage Not Updated

  • Name: storage_not_updated
  • Severity: 🔴 High

Description

Checks for local variables that are read from storage, then modified without being written back to storage.

Exploit Scenario

Test scenarios

Recommendation

Write back to storage after all changes to the local variables.

Storage Read In Loop Condition

  • Name: storage_read_in_loop_condition
  • Severity: 🟢 Low

Description

Checks for loops that contain a storage read in their condition, which can increase gas costs for each iteration.

Exploit Scenario

Test scenarios

Recommendation

Use a local variable to hold the loop computation result.

Strict Equality

  • Name: strict_equality
  • Severity: 🔴 High

Description

Checks for the use of strict equalities, which can be manipulated by an attacker.

Exploit Scenario

Test scenarios

Recommendation

Avoid using strict equalities that can be manipulated by an attacker to avoid DoS attacks.

Unchecked Call Payload

  • Name: unchecked_call_payload
  • Severity: 🟢 Low

Description

Checks for functions that supply a raw_ptr argument to the CALL assembly instruction, or a Bytes argument without checking its length.

Exploit Scenario

Test scenarios

Recommendation

If the payload supplied to the CALL assembly instruction is arbitary, ensure its length is at least 32 bytes long.

Unprotected Initialization

  • Name: unprotected_initialization
  • Severity: 🔴 High

Description

Checks for initializer functions that can be called without requirements.

Exploit Scenario

Test scenarios

Recommendation

Impose access control to all initialization functions.

Unprotected Storage Variable

  • Name: unprotected_storage_variable
  • Severity: 🔴 High

Description

Checks for functions that make changes to storage variables without access restriction.

Exploit Scenario

Test scenarios

Recommendation

Impose access control to all functions that make critical storage variable changes.

Unsafe Timestamp Usage

  • Name: unsafe_timestamp_usage
  • Severity: 🟡 Medium

Description

Checks for dependence on std::block::timestamp or std::block::timestamp_of_block, which can be manipulated by an attacker.

Exploit Scenario

Test scenarios

Recommendation

Avoid relying on std::block::timestamp or std::block::timestamp_of_block.

Unused Import

  • Name: unused_import
  • Severity: 🟢 Low

Description

Checks for imported symbols that are not used.

Exploit Scenario

Test scenarios

Recommendation

Remove all unnecessary imports.

Weak Prng

  • Name: weak_prng
  • Severity: 🟡 Medium

Description

Checks for weak PRNG due to a modulo operation on a block timestamp.

Exploit Scenario

Test scenarios

Recommendation

Avoid insecure mechanisms as a source of randomness.

Clone this wiki locally