Phi

The identity layer for onchain.

  • Start date22 Aug 2024
  • End date3 Sep 2024
  • Total awards$30,000 in USDC
  • Duration12 days

Phi audit details

  • Total Prize Pool: $30,000 in USDC
    • HM awards: $24,000 in USDC
    • QA awards: $900 in USDC
    • Judge awards: $2,800 in USDC
    • Validator awards: $1,800 USDC
    • Scout awards: $500 in USDC
  • Read our guidelines for more details
  • Starts August 22, 2024 20:00 UTC
  • Ends September 3, 2024 20:00 UTC

Automated Findings / Publicly Known Issues

The 4naly3er report can be found here.

Note for C4 wardens: Anything included in this Automated Findings / Publicly Known Issues section is considered a
publicly known issue and is ineligible for awards.

  1. updateArtSettings allows setting the startTime to a past timestamp, potentially opening the minting window earlier
    than intended
  2. Setting sellRoyalty higher than buyRoyalty may reduce market demand possibly leading to decreased liquidity
  3. Lack of upper bound check for mintFee
  4. User can claim multiple NFT (not check claimed status)
  5. creatorFee to be always zero when supply == 0
  6. Solady ECDSA.recover(), which does not reject malleable signature. For this issue, we use expiresIn
  7. The credMerkleRoot[credChainId][credId] stores the merkleRootHash, but there is no way to update the merkleRootHash.
  8. OZ EnumerableMap is not gas efficiency

Overview

Phi Protocol is an open credentialing protocol to help users form, visualize, showcase their onchain identity. It
incentivizes individuals to index blockchain transaction data as onchain credential blocks, curate them, host the
verification process, and mint onchain credential contents.

Links


Scoping Q & A

General questions

QuestionAnswer
ERC20 used by the protocolNone
Test coverage55%
ERC721 used by the protocolNone
ERC777 used by the protocolNone
ERC1155 used by the protocolAny
Chains the protocol will be deployed onBase, Optimism, BeraChain, and Other EVM chain

ERC20 token behaviors in scope

External integrations (e.g., Uniswap) behavior in scope

QuestionAnswer
Enabling/disabling fees (e.g. Blur disables/enables fees)No
Pausability (e.g. Uniswap pool gets paused)No
Upgradeability (e.g. Uniswap gets upgraded)No

EIP compliance checklist

QuestionAnswer
src/art/PhiNFT1155.solERC1155

Additional context

Main invariants

Attack ideas (where to focus for bugs)

  1. Security: Identify and mitigate vulnerabilities to prevent exploits and attacks.

2.a. Function Reliability: Ensure the contract behaves consistently under various conditions.

2.b. Function Correctness: Ensure the smart contract logic correctly implements the intended functionality without
errors.

  1. Gas Efficiency

Security Concerns - Access Control, Signature Verification, Reply Protection, Data integrity

  • Does the access control mechanism correctly restrict access to sensitive functions?
  • Can the signature verification function correctly verify the required signatures?
  • Does the function handling signature proofs properly reject invalid or malicious proofs?

Functional Reliability/Correctness Concerns

  • Are there any issues arising when claiming multiple amounts or performing batch processing?
  • Is there any unnecessary accumulation of ETH in the contract
  • Does the contract emit all necessary events correctly and include appropriate data?
  • Are there any potential issues or concerns when utilizing different bonding curves with CRED
  • Are there any potential issues with emitting events or executing functions when using Decent or relayer protocols?
  • Does the contract have proper error handling and revert statements for invalid inputs, unauthorized access, and other
    potential failure scenarios?
  • Is it possible to intentionally target a halt when using loops?

Gas Efficiency: Verify that the contract performs optimally without unnecessary gas consumption.

  • Can the contract be optimized for gas efficiency, particularly in loops and storage access patterns?

All trusted roles in the protocol

RoleDescription
OwnerSignature Signer
User GroupsLink to doc

Describe any novel or unique curve logic or mathematical models implemented in the contracts

Running tests

git clone --recurse https://github.com/code-423n4/2024-08-phi.git
git 2024-08-phi
git submodule update --init --recursive
bun install
forge test -vvv
  • forge coverage's output:

Scope

See scope.txt

Files in scope

FileLogic ContractsnSLOCLibraries used
/src/Cred.sol1507@openzeppelin/contracts/utils/structs/EnumerableMap.sol<br>@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol<br>@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol<br>solady/utils/ECDSA.sol<br>solady/utils/SafeTransferLib.sol<br>solady/utils/LibString.sol
/src/PhiFactory.sol1454@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol<br>@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol<br>solady/utils/ECDSA.sol<br>solady/utils/LibClone.sol<br>solady/utils/LibString.sol<br>solady/utils/SafeTransferLib.sol<br>solady/utils/LibZip.sol<br>solady/utils/MerkleProofLib.sol
/src/abstract/Claimable.sol148
/src/abstract/CreatorRoyaltiesControl.sol139@openzeppelin/contracts/interfaces/IERC2981.sol
/src/abstract/RewardControl.sol183solady/utils/EIP712.sol<br>solady/utils/SignatureCheckerLib.sol<br>solady/utils/SafeTransferLib.sol
/src/art/PhiNFT1155.sol1182@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol<br>@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155SupplyUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardUpgradeable.sol<br>@openzeppelin/contracts-upgradeable/access/Ownable2StepUpgradeable.sol<br>solady/utils/SafeTransferLib.sol<br>solady/utils/LibString.sol<br>@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol<br>@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol<br>@openzeppelin/contracts/utils/introspection/IERC165.sol
/src/curve/BondingCurve.sol170@openzeppelin/contracts/access/Ownable2Step.sol<br>@openzeppelin/contracts/access/Ownable.sol<br>forge-std/console2.sol
/src/reward/CuratorRewardsDistributor.sol182solady/utils/SafeTransferLib.sol<br>@openzeppelin/contracts/access/Ownable2Step.sol<br>@openzeppelin/contracts/access/Ownable.sol<br>forge-std/console2.sol
/src/reward/PhiRewards.sol181solady/utils/SafeTransferLib.sol<br>@openzeppelin/contracts/access/Ownable2Step.sol<br>@openzeppelin/contracts/access/Ownable.sol
Totals91546

Files out of scope

See out_of_scope.txt

File
./script/Base.s.sol
./script/Deploy.s.sol
./script/DeployWoCred.s.sol
./script/UpgradeCred.s.sol
./src/interfaces/IBondingCurve.sol
./src/interfaces/IContributeRewards.sol
./src/interfaces/ICreatorRoyaltiesControl.sol
./src/interfaces/ICred.sol
./src/interfaces/ICuratorRewardsDistributor.sol
./src/interfaces/IOwnable.sol
./src/interfaces/IPhiFactory.sol
./src/interfaces/IPhiNFT1155.sol
./src/interfaces/IPhiNFT1155Ownable.sol
./src/interfaces/IPhiRewards.sol
./src/interfaces/IRewards.sol
./src/lib/ContributeRewards.sol
./src/lib/FixedPriceBondingCurve.sol
./src/lib/Logo.sol
./src/lib/MerkleProof.sol
./test/Claimable.t.sol
./test/ContributeRewards.t.sol
./test/Cred.t.sol
./test/CuratorRewardsDistributor.t.sol
./test/DeployAndUpgradeTest.t.sol
./test/PhiFactory.t.sol
./test/RewardControl.t.sol
./test/helpers/CredV2.sol
./test/helpers/Settings.sol
./test/helpers/TestUtils.sol
Totals: 29

Miscellaneous

Employees of PHI and employees' family members are ineligible to participate in this audit.

Code4rena's rules cannot be overridden by the contents of this README. In case of doubt, please check with C4 staff.