Skip to content

Latest commit

 

History

History
71 lines (42 loc) · 2.36 KB

024.md

File metadata and controls

71 lines (42 loc) · 2.36 KB

Innocent Turquoise Barracuda

Medium

Implementation Contract Initialization Vulnerability (Root Cause: Lack of Zero Address Validation + Impact: Irreversible Configuration)

Summary

In the constructor of DBOFactory, the address of the implementationContract is set without validating whether it is a valid non-zero address. This design flaw means that if an invalid or zero address is accidentally assigned, the contract has no mechanism to update or replace this value. This is problematic as the contract lacks a failsafe for critical misconfigurations, leading to potential contract malfunctions or the inability to deploy new borrow orders through implementationContract.

Root Cause

Without a validation mechanism, the contract lacks a failsafe for correcting such errors, which can lead to irreversible issues if an incorrect address is assigned.

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

Address would always be what was set and if address(0) then it cant changed

Impact

Having unused variables, especially ones set in the constructor, can cause confusion for future developers or auditors, who might assume it has functionality within the contract. Additionally, this variable could increase gas costs if stored without purpose

PoC

The constructor does not validate the _implementationContract parameter. Here’s the relevant snippet:

constructor(address _implementationContract) {
owner = msg.sender;
implementationContract = _implementationContract; // No check for address(0)
}

If _implementationContract is passed as address(0), there is no way to reset or correct this, and all attempts to create borrow orders will fail or behave unpredictably.

Mitigation

In the constructor, validate that the _implementationContract is a non-zero address:

constructor(address _implementationContract) {
require(_implementationContract != address(0), "Invalid implementation address");
owner = msg.sender;
implementationContract = _implementationContract;
}

This check will prevent the contract from being misconfigured with an invalid implementationContract, ensuring future borrow orders can be created correctly.

References

https://github.com/sherlock-audit/2024-11-debita-finance-v3/blob/main/Debita-V3-Contracts/contracts/DebitaBorrowOffer-Factory.sol#L53