Skip to content
Access control Audit finding Intermediate

VaultFactory allows deployment of vaults with non-authentic TwabController and PrizePool

The VaultFactory contract allows anyone to deploy a vault that references arbitrary TwabController and PrizePool contracts, and the factory only records the vault's own address as authentic. An attacker could deploy a vault through the official factory but supply malicious TwabController and PrizePool contracts that misreport balances, favour specific addresses in prize draws, or steal prize tokens.

Jeiwan Follow with jaraxxus, 0xSmartContract and 9 others

Originally disclosed on Code4rena

Submitted by Jeiwan, also found by dev0cloo (1, 2), jaraxxus, 0xSmartContract, oxchsyston, 0xStalin (1, 2, 3), keccak123, dirk_y, btk, neumo, grearlake, 3docSec, rvierdiiev, and ABAIKUNANBAEV

A malicious vault can be deployed via the official VaultFactory contract. Users may lose funds while interacting with such vaults.

Proof of Concept

The VaultFactory.deployVault function allows deploying Vault contracts. The factory contract maintains a mapping to verify that a vault has been deployed via the factory. This allows users to check the authenticity of a vault to ensure the that implementation of a vault is authentic (i.e. not altered/malicious).

However, the business logic of vaults is split into multiple contracts: Vault, TwabController, and PrizePool. TwabController tracks the historical balances of users to determine their chances of winning prizes. PrizePool runs regular draws and distributes prizes among winners. Thus, it’s critical that in every authentic Vault contract, the implementations of TwabController and PrizePool are also authentic. Otherwise, a malicious actor could deploy an authentic vault via the official VaultFactory and provide malicious TwabController and PrizePool contracts; which can incorrectly determine user balances, favors some specific addresses when determining winners, or steals the prize token. In the current implementation, users are be able to check the authenticity of a vault contract, but not the authenticity of the TwabController and the PrizePool contracts that a vault integrates with.

Recommended Mitigation Steps

Consider implementing TwabController and PrizePool factory contracts. In the contracts, consider tracking the addresses of the deployed TwabController and PrizePool contracts. In the VaultFactory.deployVault function, consider checking that the passed _twabController and _prizePool address were deployed via the respective factory contracts.

Picodes (judge) commented:

See Issue #324.

asselstine (PoolTogether) acknowledged and commented via duplicate issue #324:

This the point of V5: we are replacing protocol gatekeeping with curation by front-ends.

The responsibility of curation will rest on front-ends, who will curate which vaults they show their users.


The original report as published on Code4rena, by Jeiwan. 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 VaultFactory records only the deployed Vault address as authentic and does not verify that the supplied TwabController and PrizePool addresses were themselves deployed through trusted factories.

Impact

Users interacting with such a vault could lose funds because the malicious TwabController and PrizePool could incorrectly determine balances, favour specific addresses in prize draws, or steal the prize token.

What the attacker needed

Attacker can call deployVault; user interacts with the malicious vault

The fix

The report recommends creating factory contracts for TwabController and PrizePool that track deployed addresses, and having VaultFactory.deployVault check that the passed addresses were deployed via those factories; the project acknowledged the issue but stated that curation by front-ends is…

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 vault is a contract where users deposit funds. It relies on two helper contracts: one tracks balances to decide prize chances, the other runs draws and pays prizes. The factory that creates vaults only checks the vault itself, not these helpers, so an attacker can create a vault that looks official but uses fake helpers to cheat users.

What is Access control?

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.

More by Jeiwan

View all

69 more disclosed reports, best first.

More from PoolTogether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.