Skip to content
Business logic Audit finding Intermediate

FixedTermLoanHook looks at block.timestamp instead of expiry

The FixedTermLoanHook contract checks block.timestamp instead of the provided expiry when validating withdrawal requests, causing users to wait an extra withdrawalBatchDuration beyond the term end. This delays withdrawals but does not allow early withdrawal or loss of funds.

deadrxsezzz Follow

Originally disclosed on Code4rena

Submitted by deadrxsezzz

The idea of FixedTermLoanHook is to only allow for withdrawals after a certain term end time. However, the problem is that the current implementation does not look at the expiry, but instead at the block.timestamp.

  function onQueueWithdrawal(
    address lender,
    uint32 /* expiry */,
    uint /* scaledAmount */,
    MarketState calldata /* state */,
    bytes calldata hooksData
  ) external override {
    HookedMarket memory market = _hookedMarkets[msg.sender];
    if (!market.isHooked) revert NotHookedMarket();
    if (market.fixedTermEndTime > block.timestamp) {
      revert WithdrawBeforeTermEnd();
    }

This creates inconsistencies such as forcing users not only to wait until term’s end, but also having to wait an extra withdrawalBatchDuration before they’re able to withdraw their funds.

Recommended Mitigation Steps

Check the expiry instead of block.timestamp.

d1ll0n (Wildcat) confirmed

laurenceday (Wildcat) acknowledged and commented:

We’ve reflected on this a little bit, and decided that we want to turn this from a confirmed into an acknowledge.

The reasoning goes as follows:

Imagine that a fixed market has an expiry of December 30th, but there’s a withdrawal cycle of 7 days.

Presumably the borrower is anticipating [and may have structured things] such that they are expecting to be able to make full use of any credit extended to them until then, and not a day sooner.

Fixing this in the way suggested would permit people to place withdrawal requests on December 23rd, with the potential to tip a market into delinquent status (depending on grace period configuration) before the fixed duration has actually met.

Net-net we think it makes more sense to allow the market to revert back to a perpetual after that expiry and allow withdrawal requests to be processed per the conditions. The expectation here would be that the withdrawal cycle would actually be quite short.

Infect3d (warden) commented:

May I comment on this issue: can we really consider this a bug rather than a feature and a design improvement, also considering sponsor comment? Expiry mechanism is known by borrower and lender, so if borrower wants lenders to be able to withdraw on time, he can simply configure fixedTermEndTime = value - withdrawalBatchDuration.

3docSec (judge) commented:

Hi @Infect3d - I agree we are close to an accepted trade-off territory. Here I lean on the sponsor who very transparently made it clear this trade-off is not something they had deliberately thought of.

Therefore, because the impact is compatible with Medium severity, “satisfactory Medium” plus “sponsor acknowledged” is a fair way of categorizing this finding.


The original report as published on Code4rena, by deadrxsezzz. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the hook ignores the expiry parameter and uses block.timestamp for the comparison, which does not account for the withdrawal batch duration.

Impact

Lenders in a fixed-term market may be forced to wait an additional withdrawalBatchDuration before they can withdraw, but the issue does not enable theft or early withdrawal.

What the attacker needed

A fixed-term market; lender initiates withdrawal

The fix

The hook should check the expiry parameter instead of block.timestamp, though the sponsor decided to keep the current behaviour as a deliberate trade-off.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract hook is supposed to enforce that lenders can only withdraw after a fixed term ends. Instead of using the term end time passed to it, it compares the current time to a stored end time, which can be later than intended. This means lenders may have to wait longer than necessary to get their money back.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by deadrxsezzz

View all

11 more disclosed reports, best first.

More from The Wildcat Protocol

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.