Skip to content
Business logic Audit finding Beginner

Malicious user can get infinite free trial by repeatedly refund and repurchase right before the freeTrial ends

The refund mechanism allows a user to cancel a purchase and receive a full refund, then repurchase and receive a new free trial period. An attacker could repeat this to obtain unlimited free trials, causing financial loss to lock owners who offer free trials.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug

The current design/implementation allows users who are refunded before to get another freeTrial. This can be exploited by malicious users to get an infinite free trial.

Proof of Concept

Given:

  • keyPrice is 1 ETH;
  • freeTrialLength is 31 days.

A malicious user can:

  1. Call purchase(), pay 1 ETH and get 31 days of freeTrial on day 1;
  2. Call cancelAndRefund() on day 30 and get 1 ETH of refund; then call purchase() again, pay 1 ETH and get 31 days of freeTrial again.

Repeat the steps above and the user can get infinite freeTrial.

Impact

A malicious third party may provide a service named freeUnlock, which will call cancelAndRefund() and purchase() automatically right before the end of the freeTrial. This can cause fund loss to all the owners that provide a freeTrial.

Recommendation

Consider adding a mapping(address => uint256) freeTrialEnds and make sure each address can only get 1 freeTrial.

julien51 (Unlock Protocol) disputed and commented:

Isn’t that the case with every free trial system? If they use the same address the lock manager could easily use the hook system to keep track of who already had received a full refund and not grant it on the 2nd cancellation. The user could still use new addresses all the time, and in that case that would be valid, but that is actually the case with a lot of systems like that :) One of my roommates in college was just subscribing to newspaper and getting the full risk-free refund by using a different name every time (but used the same address)

0xleastwood (judge) commented:

While I agree with the warden, there is potential for unlimited free trials. Limiting a free trial to a single address does not resolve the issue as an attacker can generate any number of addresses from a single seed. However, I do understand this is a tricky issue to workaround.

So I’m not sure how this should be treated as it does affect how the protocol is intended to operate. Is there any reason for users to not abuse this @julien51 ? Typically with newspapers, you have to provide credit card details, so an individual is really limited by the number of cards they hold.

julien51 (Unlock Protocol) commented:

As you noted, there is no way to prevent free trials from being abused which is why by default, locks do not have a free trial: they have to be manually explicitly configured. From there, since it’s trivial to just create an infinite number of accounts, anyone could just claim free trials over and over from new accounts.

0xleastwood (judge) decreased severity to Medium and commented:

As per sponsor, trials are not enabled by default. But seeing as this impacts protocol availability through abuse if enabled. I’ll mark this as medium.

The original report as published on Code4rena, by WatchPug. 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

The refund logic does not track whether an address has already received a free trial, so each new purchase after a refund grants a fresh trial period.

Impact

A malicious third party could automate the refund and repurchase to cause fund loss to all lock owners that provide a free trial.

What the attacker needed

A lock with a free trial enabled; ability to call purchase and cancelAndRefund

The fix

The recommendation is to track the free trial end per address and ensure each address can only receive one free trial, though the sponsor noted this does not prevent abuse via multiple addresses.

How it was found

  1. Call purchase() and pay the key price to receive a free trial.
  2. Before the free trial ends, call cancelAndRefund() to get a full refund.
  3. Call purchase() again to receive another free trial.
  4. Repeat the above steps to keep getting free trials.

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 free trial lets you use a service for a set time without paying. Here, if you pay and then cancel before the trial ends, you get your money back, but you can then pay again and get another free trial. By doing this over and over, you never actually pay for the service.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Unlock Protocol contest

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.