Agent skill
share-allocation-fairness
Trigger SHARE_ALLOCATION flag detected in pattern scan - Used by Breadth agents, depth-edge-case
Install this agent skill to your Project
npx add-skill https://github.com/PlamenTSV/plamen/tree/main/agents/skills/evm/share-allocation-fairness
SKILL.md
Skill: SHARE_ALLOCATION_FAIRNESS
Trigger: SHARE_ALLOCATION flag detected in pattern scan Used by: Breadth agents, depth-edge-case
Purpose
Analyze fairness of share/token allocation mechanisms where users receive shares proportional to deposits, contributions, or participation -- checking for late-entry advantages, queue-position gaming, and time-weighting omissions.
Methodology
STEP 1: Classify Allocation Mechanism
Identify which pattern the protocol uses:
| Type | Pattern | Key Risk |
|---|---|---|
| Pro-rata snapshot | Shares minted at fixed ratio at deposit time | Late depositors dilute early depositors' accrued value |
| Time-weighted | Shares accrue value based on duration held | Checkpoint manipulation, discrete vs continuous accrual |
| Queue-based | Deposits processed in batch/queue order | Queue position gaming, front-running batch processing |
| Epoch-based | Shares valued per epoch/period boundary | Cross-epoch timing arbitrage |
STEP 2: Late Entry Attack Model
For each allocation entry point:
- Identify accrual source: What generates value for existing share holders? (yield, fees, rewards, appreciation)
- Trace timing: When does accrued value become claimable vs when can new shares enter?
- Check for time-weighting: Does allocation account for HOW LONG shares were held, or only THAT shares are held?
- Model attack: Can a depositor enter AFTER value accrues but BEFORE distribution, capturing value they did not earn?
| Entry Function | Accrual Source | Time-Weighted? | Late Entry Possible? | Impact |
|---|
STEP 2c: Cross-Address Deposit Model
For each entry function accepting an address beneficiary parameter (e.g., stake(address to, uint256 amount)):
Check: what is the DEFAULT state for a never-before-seen to address? Can depositing for to where to has zero-initialized accounting unlock historical rewards, bypass cooldowns, or inherit accrued value?
| Entry Function | Accepts Beneficiary? | Default State for New Address | Exploitable? | Impact |
|---|
If to != msg.sender enables reward capture the recipient did not earn -> FINDING (late-entry variant).
STEP 2d: Pre-Setter Timing Model
For each admin-settable reward/rate parameter: model the sequence user_stakes -> admin_sets_rate -> rewards_accrue. Does the user receive retroactive rewards for the period BEFORE the rate was set? Does a staker after rate-setting receive the same, more, or less?
| Parameter Setter | Staked-Before-Set? | Retroactive Rewards? | Fair? |
|---|
If staking before rate-setting yields unearned rewards or causes reward loss for post-set stakers -> FINDING (timing fairness).
2e. Pre-Configuration State Analysis
For the allocation mechanism identified in Step 1:
| Configuration Step | Parameter Set | Functions Available Before Set | Exploitable Default? |
|---|
- What is the deployment/initialization sequence? List all configuration steps in order.
- For each step: what functions are callable BEFORE this configuration completes?
- Are there reward/share calculations that use unconfigured (zero/default) values?
- Can a user deposit/stake before full configuration and receive outsized rewards/shares?
- Is there a
pausemechanism that prevents interaction before configuration completes?
If users can interact during partial configuration AND default values create unfair advantage → FINDING (minimum Medium, Rule 13: design gap).
STEP 3: Queue Position and Batch Processing
For protocols with batch/queue processing:
- Ordering fairness: Is queue order FIFO, arbitrary (operator-chosen), or manipulable?
- Partial processing: Can operator process some deposits but not others within a batch?
- Cross-batch state: Does processing order within a batch affect allocation ratios?
- Deposit splitting: Can a user split one large deposit into many small ones for queue advantage?
STEP 4: Share Redemption Symmetry
Check that entry and exit use consistent valuation:
- Mint vs burn ratio: Are shares minted at the same exchange rate they can be burned?
- Pending claims: Can unredeemed shares dilute active shares' value?
- Withdrawal queue: Does withdrawal ordering create unfair priority?
STEP 4b: Aggregate Constraint Coherence (Rule 14)
For independently-settable allocation rates/shares (e.g., per-pool weights, fee splits, distribution %): Is the sum constraint enforced ON-CHAIN in the setter? Can each rate be changed independently without validating the aggregate?
| Rate/Weight Setter | Aggregate Constraint | Enforced On-Chain? | What if Sum Exceeds/Falls Short? |
|---|
If aggregate constraint NOT enforced and rates independently settable -> FINDING (Rule 14).
Output
For each finding, specify:
- Allocation mechanism type
- Whether time-weighting is present or missing
- Concrete attack sequence with numerical example
- Who benefits and who is harmed
Step Execution Checklist (MANDATORY)
| Step | Required | Completed? | Notes |
|---|---|---|---|
| 1. Classify Allocation Mechanism | YES | ✓/✗/? | |
| 2. Late Entry Attack Model | YES | ✓/✗/? | |
| 2c. Cross-Address Deposit Model | YES | ✓/✗/? | Check beneficiary != msg.sender patterns |
| 2d. Pre-Setter Timing Model | YES | ✓/✗/? | Model deposit-before-rate-set sequence |
| 2e. Pre-Configuration State Analysis | YES | ✓/✗/? | Deployment window + unconfigured defaults |
| 3. Queue Position and Batch Processing | IF queue/batch detected | ✓/✗(N/A)/? | |
| 4. Share Redemption Symmetry | YES | ✓/✗/? | |
| 4b. Aggregate Constraint Coherence | IF multiple settable weights | ✓/✗(N/A)/? | Rule 14 enforcement check |
If any step skipped, document valid reason (N/A, no queue, single pool, no settable weights).
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
integration-hazard-research
Protocol Type Trigger NAMED_EXTERNAL_PROTOCOL (detected when recon finds import/interface for an identifiable external protocol — not standard libraries). Researches known integration hazards of the target protocol.
outcome-determinism
Protocol Type Trigger outcome_determinism - detected when EITHER of these code patterns are present - - Selection from finite depletable pool with fallback behavior (while(full)...
governance-attack-vectors
Protocol Type Trigger governance (detected when Governor, Timelock, voting, proposal, quorum, delegate patterns found) - Inject Into Breadth agents, depth-external, depth-edge-case
vault-accounting
Protocol Type Trigger vault (detected in recon TASK 0 Step 1) - Inject Into Core state agent OR economic design agent (merge via M4 hierarchy)
lending-protocol-security
Protocol Type Trigger lending (detected when recon finds liquidate|borrow|repay|collateral|lend|loan|LTV|healthFactor|interestRate|debtToken) - Inject Into Breadth agents, depth...
dex-integration-security
Protocol Type Trigger dex_integration (detected when recon finds swap|addLiquidity|removeLiquidity|IUniswapV2Router|ISwapRouter|amountOutMin|amountOutMinimum|slippage - AND the...
Didn't find tool you were looking for?