Skip to content

fix(escrow-native): prevent rent refund redirection#533

Open
yukikm wants to merge 1 commit intosolana-developers:mainfrom
yukikm:fix/escrow-native-rent-refund
Open

fix(escrow-native): prevent rent refund redirection#533
yukikm wants to merge 1 commit intosolana-developers:mainfrom
yukikm:fix/escrow-native-rent-refund

Conversation

@yukikm
Copy link

@yukikm yukikm commented Feb 15, 2026

Fixes two issues in tokens/escrow/native:

  1. Security: prevent taker from redirecting the offer account rent refund to an attacker-controlled payer account. The rent is now refunded to the maker (offer initializer).
  2. Correctness: fix post-transfer balance assertion (was using the wrong pre-transfer variable).

Adds a regression test proving the rent refund cannot be redirected.

Copilot AI review requested due to automatic review settings February 15, 2026 04:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses critical security vulnerabilities related to lamport manipulation in Solana programs. The primary focus is on the escrow native program, with additional security hardening in the transfer-sol anchor example.

Changes:

  • Fixed rent refund redirection vulnerability in escrow: rent from closed offer accounts now goes to the maker (initializer) instead of an arbitrary payer
  • Corrected post-transfer balance assertion bug in escrow that was checking the wrong variable
  • Enhanced transfer-sol/anchor with signer validation and overflow protection for direct lamport transfers

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tokens/escrow/native/program/src/instructions/take_offer.rs Refunds offer rent to maker instead of payer; fixes balance assertion to use correct pre-transfer variable
tokens/escrow/native/tests/instruction.ts Makes maker account writable to receive rent refund
tokens/escrow/native/tests/test.ts Adds comprehensive regression test proving rent cannot be redirected to attacker-controlled payer
basics/transfer-sol/anchor/programs/transfer-sol/src/lib.rs Adds Signer constraint, checked arithmetic for overflow protection, and explicit balance validation
basics/transfer-sol/anchor/tests/test.ts Adds required signer to match updated program constraints

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@yukikm yukikm force-pushed the fix/escrow-native-rent-refund branch from 7ae7235 to 0e0cf8b Compare February 15, 2026 08:15
@yukikm
Copy link
Author

yukikm commented Feb 15, 2026

Note: GitHub Copilot “Pull request overview” currently mentions changes under basics/transfer-sol/..., but the current PR head only touches escrow-native (3 files).

Source of truth patch (shows the actual diff):
https://github.com/solana-developers/program-examples/pull/533.patch

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.

1 participant