The VoterUpgradeableV2.createV3Gauge function incorrectly uses v2GaugeFactory instead of v3GaugeFactory
The createV3Gauge function used the v2 gauge factory instead of the v3 gauge factory, so V3 pool gauges were created by the wrong factory. The project stated that the implementations were identical at the time, so no immediate harm occurred, but future updates could cause issues.
Submitted by KupiaSec
The gauges for the V3 pool are managed incorrectly by v2GaugeFactory rather than v3GaugeFactory.
Proof of Concept
In the VoterUpgradeableV2.createV3Gauge function, v2GaugeFactory is used instead of the appropriate v3GaugeFactory.
File: contracts\core\VoterUpgradeableV2.sol
323: externalBribe = IBribeFactory(bribeFactoryCache).createBribe(token0, token1, string.concat("Fenix Bribes: ", symbol));
324: gauge = IGaugeFactory(v2GaugeFactory).createGauge(
325: token,
326: votingEscrow,
327: pool_,
328: address(this),
329: internalBribe,
330: externalBribe,
331: true,
332: feeVault
333: );
As a result, v2GaugeFactory manages the gauges for the V3 pool instead of v3GaugeFactory. The GaugeFactoryUpgradeable contract includes the defaultBlastGovernor and merklGaugeMiddleman variables, and the createGauge function initializes the gauge using these variables.
File: contracts\gauges\GaugeFactoryUpgradeable.sol
function createGauge(
address _rewardToken,
address _ve,
address _token,
address _distribution,
address _internal_bribe,
address _external_bribe,
bool _isDistributeEmissionToMerkle,
address _feeVault
) external virtual override returns (address) {
require(msg.sender == voter || msg.sender == owner(), "only voter or owner");
address newLastGauge = address(new GaugeProxy());
IGauge(newLastGauge).initialize(
defaultBlastGovernor,
_rewardToken,
_ve,
_token,
_distribution,
_internal_bribe,
_external_bribe,
_isDistributeEmissionToMerkle,
merklGaugeMiddleman,
_feeVault
);
last_gauge = newLastGauge;
return newLastGauge;
}
Recommended Mitigation Steps
It is recommended to change the code in the createV3Gauge function as follows:
- gauge = IGaugeFactory(v2GaugeFactory).createGauge(
+ gauge = IGaugeFactory(v3GaugeFactory).createGauge(
token,
votingEscrow,
pool_,
address(this),
internalBribe,
externalBribe,
true,
feeVault
);
b-hrytsak (Fenix) confirmed and commented:
The problem is valid. Although there are some mitigations, as the implementations of v2/v3 factories, gauges are the same and it would not have led to any consequences at first. It is more of a flexibility for the future, regarding possible updates.
This submission is valid, it also seems to be Overseverity to the C4 description of problem severity.
alcueca (judge) decreased severity to Medium
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 a copy-paste or oversight error where the variable v2GaugeFactory was used instead of v3GaugeFactory in the createV3Gauge function.
Impact
The project stated that the implementations were the same and it would not have led to any consequences at first, but it is more of a flexibility for the future regarding possible updates.
What the attacker needed
None
The fix
The code should be changed to use v3GaugeFactory instead of v2GaugeFactory in the createV3Gauge function.
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 gauge is a smart contract that distributes rewards to people who provide liquidity. The code that creates a new gauge for version 3 pools accidentally called the factory for version 2 pools. Because both factories worked the same way at that moment, nothing broke, but using the wrong one could cause problems later if the factories are changed.
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.