Skip to content

fix: validate stake_vault matches pool.vault in AdminWithdrawInsurance - #58

Closed
0x-SquidSol wants to merge 1 commit into
dcccrypto:masterfrom
0x-SquidSol:fix/admin-withdraw-vault-check
Closed

fix: validate stake_vault matches pool.vault in AdminWithdrawInsurance#58
0x-SquidSol wants to merge 1 commit into
dcccrypto:masterfrom
0x-SquidSol:fix/admin-withdraw-vault-check

Conversation

@0x-SquidSol

Copy link
Copy Markdown
Contributor

Summary

  • process_admin_withdraw_insurance receives returned insurance tokens into stake_vault but never validates it matches pool.vault
  • An attacker could pass a different token account, diverting returned insurance away from the pool vault
  • This would make returned insurance unavailable for LP holder withdrawals while inflating total_returned accounting
  • Adds explicit check that stake_vault.key == pool.vault before the CPI

Test plan

  • Verify rejects stake_vault that doesn't match pool.vault
  • Verify normal AdminWithdrawInsurance still succeeds with correct vault
  • Run existing test suite to confirm no regressions

🤖 Generated with Claude Code

process_admin_withdraw_insurance receives insurance tokens into
stake_vault but never validates that stake_vault matches the pool's
stored vault address. An attacker with admin access could pass a
different token account, diverting returned insurance tokens away
from the pool's vault and making them unavailable for LP holder
withdrawals.

Adds a check that stake_vault.key matches pool.vault before the CPI.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Apr 1, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@0x-SquidSol has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 48 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 13 minutes and 48 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 15c17d6d-55c3-4520-9aa0-3146372da175

📥 Commits

Reviewing files that changed from the base of the PR and between 1881738 and ee51693.

📒 Files selected for processing (1)
  • src/processor.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dcccrypto

Copy link
Copy Markdown
Owner

Superseded by PR#95 (merged) and PR#96 (omnibus test coverage). All changes in this PR are already in master. Closing as part of PERC-8433 cleanup.

@dcccrypto

Copy link
Copy Markdown
Owner

Implemented in PR #98 and merged to master. Thank you for identifying this vulnerability — the fix was applied based on your diff after two rounds of security review.

@dcccrypto dcccrypto closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants