Scans Algorand smart contracts for 11 common vulnerabilities including rekeying attacks, unchecked transaction fees, missing field validations, and access control issues. Use when auditing Algorand projects (TEAL/PyTeal).
Systematically scan Algorand smart contracts (TEAL and PyTeal) for platform-specific security vulnerabilities documented in Trail of Bits' "Not So Smart Contracts" database. This skill encodes 11 critical vulnerability patterns unique to Algorand's transaction model.
.teal.py with PyTeal imports# PyTeal indicators
from pyteal import *
from algosdk import *
# Common patterns
Txn, Gtxn, Global, InnerTxnBuilder
OnComplete, ApplicationCall, TxnType
@router.method, @Subroutine
approval_program.py / clear_program.pycontract.teal / signature.tealuv tool install tealer (ensure uv's tool bin dir is on PATH)tealer contract.teal --detect allWhen invoked, I will:
When vulnerabilities are found, you'll get a report like this:
=== ALGORAND VULNERABILITY SCAN RESULTS ===
Project: my-algorand-dapp
Files Scanned: 3 (.teal, .py)
Vulnerabilities Found: 2
Coverage: 11/11 patterns reported
1 Rekeying Attack ................... found approval.py:45
2 Unchecked Transaction Fee ......... n/a stateful app, fees paid by sender
3 Closing Account ................... clear Assert(Txn.close_remainder_to() == Global.zero_address())
... one row per pattern, all 11 present ...
---
[CRITICAL] Rekeying Attack
File: contracts/approval.py:45
Pattern: Missing RekeyTo validation
Code:
If(Txn.type_enum() == TxnType.Payment,
Seq([
# Missing: Assert(Txn.rekey_to() == Global.zero_address())
App.globalPut(Bytes("balance"), balance + Txn.amount()),
Approve()
])
)
Issue: The contract doesn't validate the RekeyTo field, allowing attackers
to change account authorization and bypass restrictions.
I check for 11 critical vulnerability patterns unique to Algorand. For detailed detection patterns, code examples, mitigations, and testing strategies, see VULNERABILITY_PATTERNS.md.
Global.group_size() validation on atomic groupsFor complete vulnerability patterns with code examples, see VULNERABILITY_PATTERNS.md.
.teal, .py)# Run Tealer on contract
tealer contract.teal --detect all
# Or specific detectors
tealer contract.teal --detect unprotected-rekey,group-size-check,update-application-check
For each of the 11 vulnerabilities above:
Create checklist for all transaction types used:
Payment Transactions:
Asset Transfers:
Application Calls:
Inner Transactions:
For atomic transaction groups:
Global.group_size() checksReport on every pattern in §6, whether or not it turned anything up. Emit this table above the findings, with all 11 rows present:
| # | Pattern | Verdict | Evidence |
|---|---------|---------|----------|
| 1 | Rekeying Attack | found | approval.py:45 -- no Txn.rekey_to() assertion on the payment branch |
| 2 | Unchecked Transaction Fee | | |
| 3 | Closing Account (CloseRemainderTo) | | |
| 4 | Closing Asset (AssetCloseTo) | | |
| 5 | Group Size Check | | |
| 6 | Time-Based Replay Attack | | |
| 7 | Access Controls | | |
| 8 | Asset ID Verification | | |
| 9 | Denial of Service (Asset Opt-In) | | |
| 10 | Inner Transaction Fee | | |
| 11 | Clear State Transaction | | |
Each verdict is one of:
found — cite file:line and write the finding up in full below.clear — the pattern applies to this contract and the contract handles it. Name the field, opcode, or
check you searched for, so a reader can repeat the search.n/a — the pattern cannot apply here. Give the reason in one clause ("no inner transactions in this
contract"). Not having looked is not n/a.A table with fewer than 11 rows is an incomplete scan and must be reported as one. A row whose Verdict cell is empty is incomplete in the same way: row 1 above is filled in to show the shape, and every row is filled in the same way before the report is done. Eleven clear verdicts is
a result a reader can act on. A report that covers four patterns and says nothing about the other seven reads
exactly like a clean contract, and that is the failure this table exists to prevent.
## [SEVERITY] Vulnerability Name (e.g., Missing RekeyTo Validation)
**Location**: `contract.teal:45-50` or `approval_program.py:withdraw()`
**Description**:
The contract approves payment transactions without validating the RekeyTo field, allowing an attacker to rekey the account and bypass future authorization checks.
**Vulnerable Code**:
```python
# approval_program.py, line 45
If(Txn.type_enum() == TxnType.Payment,
Approve() # Missing RekeyTo check
)
```
**Attack Scenario**:
1. Attacker submits payment transaction with RekeyTo set to attacker's address
2. Contract approves transaction without checking RekeyTo
3. Account authorization is rekeyed to attacker
4. Attacker gains full control of account
**Recommendation**:
Add explicit validation of the RekeyTo field:
```python
If(And(
Txn.type_enum() == TxnType.Payment,
Txn.rekey_to() == Global.zero_address()
), Approve(), Reject())
```
**References**:
- building-secure-contracts/not-so-smart-contracts/algorand/rekeying
- Tealer detector: `unprotected-rekey`
# Add to CI/CD pipeline
tealer approval.teal --detect all --json > tealer-report.json
# Fail build on critical findings
tealer approval.teal --detect all --fail-on critical,high
building-secure-contracts/not-so-smart-contracts/algorand/Before completing Algorand audit, verify ALL items checked:
found, clear or n/a with a reasonn/a costs one
clause and makes the judgment reviewable. Silence records nothing, and a reader cannot tell it apart from
not having checked.file:line, and split-program contracts are where these checks go missing.npx skills add trailofbits/algorand-vulnerability-scanner下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
BluOS CLI (blu) for discovery, playback, grouping, and volume.
Set up and use 1Password CLI (op). Use when installing the CLI, enabling desktop app integration, signing in (single or multi-account), or reading/injecting/running secrets via op.
Use the mcporter CLI to list, configure, auth, and call MCP servers/tools directly (HTTP or stdio), including ad-hoc servers, config edits, and CLI/type generation.
Capture and automate macOS UI with the Peekaboo CLI.
Remote-control tmux sessions for interactive CLIs by sending keystrokes and scraping pane output.
Use the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com. Use when you need to fetch new skills on the fly, sync installed skills to latest or a specific version, or publish new/updated skill folders with the npm-installed clawhub CLI.
Category:developer