agents/skills/solana/temporal-parameter-staleness/SKILL.md
Trigger Pattern interval|epoch|period|duration|delay|cooldown|lock_period|timelock|unbonding|claim_delay|withdraw_delay|maturity - Inject Into Breadth agents, depth-state-trace
npx skillsauth add plamentsv/plamen temporal-parameter-stalenessInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Trigger Pattern:
interval|epoch|period|duration|delay|cooldown|lock_period|timelock|unbonding|claim_delay|withdraw_delay|maturityInject Into: Breadth agents, depth-state-trace Finding prefix:[TPS-N]Rules referenced: R2, R8, R10, R13, R14
Cached parameters in multi-step operations become stale when authority changes them mid-operation. On Solana, timing has unique properties: 400ms slot time, Clock sysvar shared across all instructions in a transaction, Solana epoch boundaries (~2-3 days, 432k slots), and leader schedule predictability.
Find all operations that span multiple transactions:
| Operation | Step 1 (Initiate) | Wait Condition | Step N (Complete) | Clock Source | |-----------|-------------------|----------------|-------------------|-------------| | {op_name} | {initiate_ix}() | {wait_condition} | {complete_ix}() | slot / unix_timestamp / epoch |
For each multi-step operation:
Clock::get()?.unix_timestamp, Clock::get()?.slot, Clock::get()?.epoch)| Clock Field | Resolution | Monotonicity | Accuracy | Use Case |
|-------------|-----------|-------------|----------|----------|
| slot | ~400ms | Strictly increasing | Exact (validator-produced) | Short-duration timing, cooldowns |
| unix_timestamp | ~400ms | Mostly increasing (can drift +-1-2s) | +/- 1-2 seconds (estimated by validator) | Human-readable delays, longer durations |
| epoch | ~2-3 days (432k slots) | Strictly increasing | Exact | Staking epoch boundaries, long cycles |
Critical property: Within a single transaction, ALL instructions see the same Clock values. Unlike EVM where multi-block operations have timing variation per block, a Solana transaction's instructions share identical timing. Multi-step timing attacks require separate transactions.
For each parameter used across steps:
| Parameter | Account Stored In | Read At Step | Cached in User Account? | Authority-Changeable? | Re-Validated At Completion? | |-----------|------------------|-------------|------------------------|----------------------|----------------------------| | {param} | {config_account} | initiate() | YES/NO | YES/NO (which authority) | YES/NO |
Solana caching patterns:
request.fee_rate = config.fee_rate)Red flags: Parameter is cached in a user account at Step 1 AND authority can change the source account AND Step N does NOT re-read from source.
For each cached parameter that can become stale:
Scenario A: Parameter INCREASES between steps
1. User initiates at Step 1 - user PDA stores param = X (read from config account)
2. Authority updates config account: param = X + delta
3. User completes at Step N - uses cached X from user PDA
4. Impact: {what happens with stale value X when current is X + delta}
Scenario B: Parameter DECREASES between steps
1. User initiates at Step 1 - user PDA stores param = X
2. Authority updates config account: param = X - delta
3. User completes at Step N - uses cached X
4. Impact: {what happens with stale value X when current is X - delta}
BOTH directions are mandatory - increase and decrease often have different impacts.
| Vector | Description | Severity Modifier |
|--------|-------------|-------------------|
| Epoch boundary crossing | Operation initiated in epoch N, completed in epoch N+1. Staking yields, validator rewards, inflation rate change at epoch boundary. | Higher if protocol depends on epoch-specific rates |
| Slot leader timing | Leader schedule known ~2 epochs ahead. Authority can time parameter changes to specific slots with high precision. | Increases likelihood for timing-sensitive parameters |
| Same-tx guarantee | Within one tx, Clock is constant. Cannot have intra-tx staleness. Multi-instruction composition is safe from timing drift. | Reduces severity for single-tx operations |
| Clock drift | unix_timestamp can drift +-1-2s from wall clock. If protocol uses tight timestamp comparisons (<5s), drift can cause unexpected behavior. | Medium if tight comparisons used |
For each parameter updated from an external source (oracle account, other program's state):
refresh or crank instruction? If yes, who calls it and when? Can staleness occur if the crank is not called?For fee/rate parameters that apply to existing state:
| Parameter | Stored In | Applies To | Retroactive? | Impact | |-----------|----------|-----------|--------------|--------| | {fee_param} | {config PDA} | {what it affects} | YES/NO | {if retroactive: who is harmed} |
Solana retroactive patterns:
fee_bps in a global config account. All pending claims calculated at completion time using new rate - retroactively changes expected returns.close_fee changes, users with pending close requests pay different amount than expected.Rule 2 direction check: Can the authority's parameter change make a user-facing instruction behave unexpectedly? (e.g., setting cooldown_slots = 0 removes timing protection, setting max_deviation = 0 disables oracle bounds). Does the change retroactively affect users in active positions?
For each staleness issue:
Use worst realistic operational state, not current on-chain snapshot:
Severity assessed at: pending_claims=MAX_USERS, fee_delta=MAX_FEE-MIN_FEE, tvl=$XXM
Rationale: Protocol designed for up to {N} concurrent pending operations per documentation
slot or unix_timestamp for timing? If unix_timestamp, is the +-1-2s drift handled?{CONTRACTS} - Programs to analyze
{MULTI_STEP_OPS} - Identified multi-step operations
{CACHED_PARAMS} - Parameters cached at initiation (stored in user PDAs/accounts)
{AUTHORITY_PARAMS} - Authority-changeable parameters
{DELAY_PARAMS} - Delay/cooldown parameters (in slots, timestamps, or epochs)
{FEE_PARAMS} - Fee/rate parameters that may apply retroactively
{CLOCK_SOURCE} - Clock field used (slot/unix_timestamp/epoch)
| Field | Required | Description | |-------|----------|-------------| | multi_step_ops | yes | List of multi-step operations found | | cached_params | yes | Parameters cached across steps (stored in which account) | | staleness_vectors | yes | How cached params can become stale | | retroactive_fees | yes | Fees applied retroactively | | clock_source_audit | yes | Which Clock field is used and whether appropriate | | epoch_boundary_effects | yes | Operations spanning epoch boundaries | | finding | yes | CONFIRMED / REFUTED / CONTESTED | | evidence | yes | Code locations with line numbers | | step_execution | yes | Status for each step |
| Step | Required | Completed? | Notes | |------|----------|------------|-------| | 1. Enumerate Multi-Step Operations | YES | | | | 2. Identify Cached Parameters | YES | | | | 3. Model Staleness Impact (both directions) | YES | | | | 3b. Update Source Audit | YES | | | | 4. Retroactive Application Analysis | YES | | | | 5. Assess Severity | YES | | |
After Step 2: If cached parameters are authority-changeable -> MUST complete Step 3 with BOTH increase and decrease scenarios.
After Step 4: Cross-reference with SEMI_TRUSTED_ROLES (Solana version) for authority functions that change these parameters.
After Step 3: If protocol uses unix_timestamp for comparisons tighter than 5 seconds -> FLAG clock drift concern.
After Step 1: If any operation spans Solana epoch boundaries -> cross-reference with staking/inflation rate changes.
development
Prepare Solidity projects for a security audit — test coverage, test quality, NatSpec docs, code hygiene, dependency health, best-practice enforcement, deployment readiness, and project documentation checks. Generates a scored Audit Readiness Report and optionally runs static analysis. Trigger on: "prepare for audit", "audit readiness", "pre-audit check", "audit prep", "NatSpec check", or any request to review a Solidity codebase before a security review.
development
Launch the Plamen deterministic Web3 security audit pipeline
development
Run the Plamen smart-contract audit wizard in Codex
testing
Launch the Plamen deterministic L1 infrastructure audit pipeline