agents/skills/solana/semi-trusted-roles/SKILL.md
Trigger Pattern Crank/bot/operator signer checks, authority-gated instructions - Inject Into Breadth agents, depth-state-trace
npx skillsauth add plamentsv/plamen semi-trusted-rolesInstall 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: Crank/bot/operator signer checks, authority-gated instructions Inject Into: Breadth agents, depth-state-trace Finding prefix:
[STR-N]Rules referenced: S1, S3, S9, R2, R6, R10, R13
crank|bot|operator|keeper|authority|admin|has_one\s*=\s*authority|
constraint\s*=\s*.*signer|role|guardian|relayer
has_one, Signer type, or custom constraint?| Instruction | Signer Check | Mutable Accounts | CPI Calls | Parameters | |-------------|-------------|------------------|-----------|------------|
For each permitted action, ask:
Timing Abuse (400ms slots):
Parameter Abuse:
remaining_accounts?Sequence Abuse:
Omission Abuse:
Scenario A: Timing Attack (MEV Bundle)
1. {ROLE_NAME} monitors pending transactions in mempool
2. {ROLE_NAME} creates MEV bundle: [role_instruction, user_instruction]
3. Role instruction executes first within same slot, changing state
4. User instruction executes with worse conditions
5. Impact: {TIMING_IMPACT}
Scenario B: Parameter Attack
1. {ROLE_NAME} calls {ROLE_INSTRUCTION} with {MALICIOUS_PARAMS}
2. Instruction data is not validated against {EXPECTED_CONSTRAINTS}
3. Impact: {PARAM_IMPACT}
Scenario C: Key Compromise
1. {ROLE_NAME} keypair is compromised
2. Attacker can call: {ROLE_FUNCTIONS}
3. Maximum extractable value: {MAX_DAMAGE}
4. Recovery: {RECOVERY_PATH} - can authority be rotated? Timelock?
Predictability Analysis:
Scenario D: User Exploits Crank Timing
1. User observes that {ROLE_NAME} executes {ROLE_INSTRUCTION} at predictable times
2. User submits transaction with high priority fee to land BEFORE crank in same slot
3. {ROLE_INSTRUCTION} executes, changing state (e.g., reward distribution, rate update)
4. User benefits from known state change
5. Impact: {USER_EXPLOIT_IMPACT}
Scenario E: User Griefs Crank Preconditions
1. {ROLE_INSTRUCTION} requires account state: {PRECONDITION}
2. User manipulates account state to violate {PRECONDITION}
3. {ROLE_NAME} sends transaction, instruction fails
4. Protocol enters degraded state (no crank actions possible)
5. Impact: {GRIEF_IMPACT}
Scenario F: User Forces Suboptimal Crank Action
1. {ROLE_NAME} must choose between options based on on-chain state
2. User manipulates state (deposits/withdrawals) to make worst option appear best
3. {ROLE_NAME} (following honest behavior) chooses suboptimal path
4. User profits from forced suboptimal execution
5. Impact: {SUBOPTIMAL_IMPACT}
Scenario G: Same-Chain Rate Staleness via Discrete Updates
1. Protocol's exchange rate only updates when {ROLE_NAME} cranks (discrete updates)
2. Between crank calls, rate is stale (does not reflect accumulated value)
3. User monitors for {ROLE_NAME} pending transaction
4. User enters at stale rate (favorable), crank executes, rate updates
5. User exits at updated rate (or holds appreciating position)
6. Impact: {RATE_ARBIT_IMPACT}
For each instruction callable by {ROLE_NAME}:
| Instruction | Preconditions | User Can Manipulate? | Grief Impact | |-------------|--------------|---------------------|--------------| | {ix} | account balance > 0 | YES - withdraw all | Crank stuck | | {ix} | Clock timestamp > last_crank + interval | NO - time-based | N/A | | {ix} | threshold met | YES - partial withdraw | Delayed execution |
CU budget griefing: Can a user submit CU-heavy transactions to fill the leader's block and delay crank execution? Priority fee escalation can push crank costs above economic viability.
Enumerate ALL authority-gated instructions across the program:
| Instruction | Authority Type | Preconditions | User Can Manipulate? | Grief Impact | |-------------|---------------|--------------|---------------------|--------------| | {admin_ix} | {owner/admin/operator} | {preconditions} | YES/NO | {impact} |
Enumeration completeness check:
Solana-specific checks:
**ID**: [STR-N]
**Severity**: Critical/High/Medium/Low/Info
**Step Execution**: (see below)
**Rules Applied**: [S1:___, S3:___, S9:___, R2:___, R6:___, R10:___, R13:___]
**Location**: programs/{program}/src/instructions/{file}.rs:LineN
**Title**: {what role can do / what user can exploit}
**Description**: {specific abuse vector with code reference}
**Impact**: {quantified damage at worst-state parameters}
| Step | Required | Completed? | Notes | |------|----------|------------|-------| | 1. Inventory Role Permissions | YES | | | | 2. Analyze Within-Scope Abuse | YES | | | | 3. Model Attack Scenarios (A,B,C) | YES | | | | 4. Assess Mitigations | YES | | | | 5. Model User-Side Exploitation (D,E,F,G) | YES | | MANDATORY -- never skip | | 6. Precondition Griefability Check | YES | | MANDATORY -- never skip | | 6b. Admin Instruction Griefability | YES | | MANDATORY -- never skip |
After Step 4: DO NOT STOP HERE -- Steps 5-6 analyze the reverse direction. After Step 5: Cross-reference with TOKEN_FLOW_TRACING for token-related griefing vectors. IF crank actions are predictable -> document Jito MEV vectors. After Step 6: IF any precondition is user-griefable -> severity >= MEDIUM. Document protocol degradation timeline if crank is blocked.
**Step Execution**: check1,2,3,4,5,6,6b | (no skips for this skill)
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