ability-analysis
Trigger Pattern Always (Aptos Move) - foundational security check - Inject Into Breadth…
Trigger Pattern Always required for Soroban audits - Inject Into Breadth agents, depth-edge-case
$ npx -y skills add PlamenTSV/plamen --skill overflow-safety --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/overflow-safetyContext preview
The summary Claude sees to decide when to auto-load this skill.
Trigger Pattern Always required for Soroban audits - Inject Into Breadth agents, depth-edge-case
name: "overflow-safety" description: "Trigger Pattern Always required for Soroban audits - Inject Into Breadth agents, depth-edge-case"
> **Trigger Pattern**: Always required for Soroban audits > **Inject Into**: Breadth agents, depth-edge-case > **Finding prefix**: `[OF-N]` > **Rules referenced**: R10, R14
Soroban contracts are compiled Rust. Rust's overflow behavior depends on the build profile: in debug builds, overflows panic; in release builds (used for deployment), overflows silently wrap by default unless `overflow-checks = true` is set. Silent wrapping in financial arithmetic is a critical vulnerability.
Before tracing any arithmetic, inspect `Cargo.toml` for the release profile overflow setting:
| File | `[profile.release]` Present? | `overflow-checks` Setting | Safe? | |------|------------------------------|--------------------------|-------| | `Cargo.toml` | YES/NO | `true` / `false` / MISSING | Only if `true` |
**Interpretation**:
**Finding threshold**: If `overflow-checks` is not `true`, the entire overflow safety of the contract depends on manual use of checked/saturating arithmetic. This is a configuration-level finding regardless of whether Section 2 finds specific overflow sites.
If the profile check from Section 1 found that overflow protection is NOT enabled, trace ALL arithmetic operations in financial paths:
| Location | Expression | Operand Types | Max Realistic Value | Overflow Possible? | Impact if Wrapped | |----------|-----------|--------------|--------------------|--------------------|------------------| | `{file:line}` | `{a + b}` | `u64 / i128 / u32` | `{estimate}` | YES/NO | `{balance wraps to 0, share inflates, etc.}` |
**Financial paths to prioritize**:
**Wrapping arithmetic consequences**:
Identify all financial arithmetic and classify whether safe arithmetic methods are used:
| Location | Operation | Method Used | Safe? | |----------|-----------|-------------|-------| | `{file:line}` | `{description}` | `+` / `checked_add` / `saturating_add` / `wrapping_add` | Only `checked_*` or `saturating_*` |
**Safe methods**:
**Unsafe methods**:
**Flag any unchecked arithmetic where**:
Soroban's native token and SEP-41 tokens frequently use `i128` for amounts. Check operations near the boundaries:
| Location | Operation | Uses `i128`? | Near-Boundary Risk | Checked? | |----------|-----------|-------------|-------------------|---------| | `{file:line}` | `{expression}` | YES/NO | YES/NO | YES/NO |
**Specific checks**:
Soroban has no floating-point arithmetic. All division truncates toward zero (integer division). Incorrect division ordering causes precision loss or incorrect results:
| Location | Expression | Division-Before-Multiplication? | Precision Loss Estimate | Impact | |----------|-----------|--------------------------------|------------------------|--------| | `{file:line}` | `{a / b * c}` | YES → FLAG | `{up to b-1 units lost}` | `{financial impact}` |
**Anti-pattern** (division before multiplication):
// BAD: (amount / total_supply) loses precision before multiplying by rewards let user_share = (user_balance / total_supply) * total_rewards;
**Correct pattern** (multiplication before division):
// GOOD: multiply first to preserve precision let user_share = (user_balance * total_rewards) / total_supply;
**Additional checks**:
Autonomous Web3 security auditor for Claude Code and OpenAI Codex CLI. Orchestrates 18-100 AI agents across 40+ phases to produce audit reports with verified PoC exploits — for smart contracts and L1 node-client infrastructure.
Repo: PlamenTSV/plamen
Trigger Pattern Always (Aptos Move) - foundational security check - Inject Into Breadth…
Trigger Pattern Always (Aptos Move) - Move VM aborts on shift = bit width - Inject Into…
Trigger Protocol has privileged roles (admin, operator, governance, resource account owner) -…
Trigger EXTERNAL_LIB flag detected (protocol uses third-party Move dependencies) - Used by…
Trigger Pattern MONETARY_PARAMETER flag (required) - Inject Into Breadth agents (merged via…