Skip to content
Smart contracts Audit finding Intermediate

no reentrancy guard on mint() function that has a callback

The mint() function in CollateralizedDebt.sol calls _safeMint(), which invokes a callback to the recipient address. Without a reentrancy guard, a malicious recipient could re-enter the function during that callback, potentially causing unexpected behaviour.

jayjonah8 Follow

Originally disclosed on Code4rena

Submitted by jayjonah8, also found by Fitraldys

In CollateralizedDebt.sol, the mint() function calls _safeMint() which has a callback to the “to” address argument. Functions with callbacks should have reentrancy guards in place for protection against possible malicious actors both from inside and outside the protocol.

Proof of Concept

Recommended Mitigation Steps

Add a reentrancy guard modifier on the mint() function in CollateralizedDebt.sol

Mathepreneur (Timeswap) confirmed

The original report as published on Code4rena, by jayjonah8. 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 mint() function lacks a reentrancy guard despite calling _safeMint(), which performs an external callback to the recipient.

Impact

A malicious recipient could re-enter mint() during the callback, potentially disrupting contract state or minting behaviour, though the report does not demonstrate a concrete exploit.

What the attacker needed

Attacker controls the recipient address

The fix

Add a reentrancy guard modifier to the mint() function in CollateralizedDebt.sol.

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.

When a contract sends a token to another contract, it can trigger code in the receiving contract. If the sending function does not protect itself, the receiver can call back into the same function before the first call finishes. This is called reentrancy and can lead to repeated actions or inconsistent state.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by jayjonah8

View all

18 more disclosed reports, best first.

More from Timeswap contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.