crytic / tealer

Static Analyzer for Teal
GNU Affero General Public License v3.0
62 stars 14 forks source link

Update detectors to check if the other transactions in the group check the transaction using absolute or relative indexes #191

Closed S3v3ru5 closed 11 months ago

S3v3ru5 commented 11 months ago

The first commit adds helper functions to retrieve the index and field a transaction access instruction pushes on to the stack. The indexes are divided into three categories:

  1. Self - Txn.field()
  2. Absolute - Gtxn[Int(x)].field()
  3. Relative - Gtxn[Txn.group_index() -/+ offset].field()

Given an instruction, the helper function returns the index of the transaction this instruction is accessing and the field it accesses.

The second commit updates the transaction field analysis to track the values of the transaction at an absolute index and at a relative index from the contract. The detectors use this information to consider the validations performed by other transactions in the group. The detectors would not report if an application in the group validates the rekeyto of the logic-sig in a different transaction.

The tests/group_transactions/basic/logicsig_1.py lists different patterns to access the fields. The detectors now identify all such patterns.

S3v3ru5 commented 11 months ago

Builds on #189