Omniscia Kinza Finance Audit
ProtectedERC20Gateway Static Analysis Findings
ProtectedERC20Gateway Static Analysis Findings
PEC-01S: Redundant Function Implementations
Type | Severity | Location |
---|---|---|
Gas Optimization | ProtectedERC20Gateway.sol:L128-L130, L134-L136 |
Description:
The referenced ProtectedERC20Gateway::receive
and ProtectedERC20Gateway::fallback
function implementations are redundant as Solidity's behaviour is to not include them if they are not explicitly specified in the version utilized.
Example:
128receive() external payable {129 revert('Receive not allowed');130}131/**132 * @dev Revert fallback calls133 */134fallback() external payable {135 revert('Fallback not allowed');136}
Recommendation:
We advise them to be safely omitted, optimizing the contract's deployment gas cost as well as the legibility of the codebase.
Alleviation:
Both function implementations have been removed as advised.
PEC-02S: Inexistent Sanitization of Input Address
Type | Severity | Location |
---|---|---|
Input Sanitization | ProtectedERC20Gateway.sol:L26-L32 |
Description:
The linked function accepts an address
argument yet does not properly sanitize it.
Impact:
The presence of zero-value addresses, especially in constructor
implementations, can cause the contract to be permanently inoperable. These checks are advised as zero-value inputs are a common side-effect of off-chain software related bugs.
Example:
26constructor(27 IPool pool28) {29 POOL = pool;30 31 32}
Recommendation:
We advise some basic sanitization to be put in place by ensuring that the address
specified is non-zero.
Alleviation:
The input pool
address of the ProtectedERC20Gateway::constructor
is now adequately sanitized via a newly introduced UtilLib
and specifically its UtilLib::checkNonZeroAddress
function.
PEC-03S: Improper Invocations of EIP-20 transferFrom
Type | Severity | Location |
---|---|---|
Standard Conformity | ProtectedERC20Gateway.sol:L41, L72, L107 |
Description:
The linked statements do not properly validate the returned bool
of the EIP-20 standard transferFrom
function. As the standard dictates, callers must not assume that false
is never returned.
Impact:
If the code mandates that the returned bool
is true
, this will cause incompatibility with tokens such as USDT / Tether as no such bool
is returned to be evaluated causing the check to fail at all times. On the other hand, if the token utilized can return a false
value under certain conditions but the code does not validate it, the contract itself can be compromised as having received / sent funds that it never did.
Example:
41token.transferFrom(msg.sender, address(this), amount);
Recommendation:
Since not all standardized tokens are EIP-20 compliant (such as Tether / USDT), we advise a safe wrapper library to be utilized instead such as SafeERC20
by OpenZeppelin to opportunistically validate the returned bool
only if it exists in each instance.
Alleviation:
The Kinza Finance team has stated that they wish to not sanitize the yielded bool
values as the tokens they intend to integrate with will either revert
or yield true
.
We consider the gas overhead of evaluating the yielded bool
to be minimal and as such will mark this exhibit as acknowledged.