Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audit fixes [GasZipFacet v2.0.2] #910

Merged
merged 12 commits into from
Jan 11, 2025
Merged

Audit fixes [GasZipFacet v2.0.2] #910

merged 12 commits into from
Jan 11, 2025

Conversation

ezynda3
Copy link
Contributor

@ezynda3 ezynda3 commented Dec 26, 2024

Which Jira task belongs to this PR?

Why did I implement it this way?

Checklist before requesting a review

Checklist for reviewer (DO NOT DEPLOY and contracts BEFORE CHECKING THIS!!!)

  • I have checked that any arbitrary calls to external contracts are validated and or restricted
  • I have checked that any privileged calls (i.e. storage modifications) are validated and or restricted
  • I have ensured that any new contracts have had AT A MINIMUM 1 preliminary audit conducted on by <company/auditor>

Copy link
Contributor

coderabbitai bot commented Dec 26, 2024

Walkthrough

The pull request introduces modifications to the Permit2Proxy contract in src/Periphery/Permit2Proxy.sol and updates the auditLog.json file. The changes include updating the Solidity version pragma, incrementing the contract version, and enhancing error handling in the callDiamondWithEIP2612Signature function. Additionally, a new audit entry is added, and existing contract versions are updated to improve traceability.

Changes

File Change Summary
src/Periphery/Permit2Proxy.sol - Updated Solidity version pragma from 0.8.17 to ^0.8.17
- Incremented contract version from 1.0.1 to 1.0.2
- Enhanced error handling in callDiamondWithEIP2612Signature function
- Renamed permit variable to tokenPermissionsHash in getPermit2MsgHash function
audit/auditLog.json - Added new audit entry: audit20250110
- Updated contract versions for GasZipFacet to 2.0.2, GasZipPeriphery to 1.0.1, LibAsset to 1.0.2, Permit2Proxy to 1.0.1, and ReceiverAcrossV3 to 1.0.2

Possibly related PRs

Suggested reviewers

  • maxklenk

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d33b2d8 and ef12d20.

📒 Files selected for processing (2)
  • audit/auditLog.json (5 hunks)
  • src/Facets/GasZipFacet.sol (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • src/Facets/GasZipFacet.sol
🚧 Files skipped from review as they are similar to previous changes (1)
  • audit/auditLog.json
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: run-unit-tests
  • GitHub Check: enforce-min-test-coverage
  • GitHub Check: generate-tag
  • GitHub Check: analyze

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@lifi-action-bot lifi-action-bot marked this pull request as draft December 26, 2024 09:17
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/Facets/GasZipFacet.sol (1)

21-22: Consistent use of MAX_CHAINID_LENGTH_ALLOWED.
Defining the same constant in both GasZipFacet and GasZipPeriphery is beneficial if they operate independently, but consider extracting it into a shared library or a global constants file to avoid duplication.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c9e6246 and 80c68b1.

📒 Files selected for processing (5)
  • src/Facets/GasZipFacet.sol (3 hunks)
  • src/Libraries/LibAsset.sol (1 hunks)
  • src/Periphery/GasZipPeriphery.sol (2 hunks)
  • src/Periphery/Permit2Proxy.sol (2 hunks)
  • src/Periphery/ReceiverAcrossV3.sol (1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/Periphery/GasZipPeriphery.sol (3)
Learnt from: 0xDEnYO
PR: lifinance/contracts#807
File: src/Periphery/GasZipPeriphery.sol:4-14
Timestamp: 2024-11-12T09:43:10.543Z
Learning: In `GasZipPeriphery.sol`, `LibUtil` and `Validatable` are used, so ensure not to suggest their removal in future reviews.
Learnt from: 0xDEnYO
PR: lifinance/contracts#807
File: src/Periphery/GasZipPeriphery.sol:77-77
Timestamp: 2024-11-12T09:43:10.543Z
Learning: In `GasZipPeriphery.sol`, prefer to avoid making more expensive function calls like calling the contract's own functions with `msg.value` after a swap, in order to save gas.
Learnt from: 0xDEnYO
PR: lifinance/contracts#807
File: src/Periphery/GasZipPeriphery.sol:57-62
Timestamp: 2024-11-12T09:43:10.543Z
Learning: In the `GasZipPeriphery` contract, it's acceptable to let low-level calls like `liFiDEXAggregator.call` fail without explicit error handling, as failing the entire transaction is sufficient and saves gas.
🔇 Additional comments (9)
src/Periphery/GasZipPeriphery.sol (3)

17-17: Simplified inheritance may introduce reentrancy exposure.
By removing ReentrancyGuard, the contract is no longer protected against potential reentrancy attacks. If malicious contracts or untrusted external calls are possible via liFiDEXAggregator, consider reinstating reentrancy protections in high-risk functions.


23-23: Good practice: Unified constant for chain ID limitations.
Introducing MAX_CHAINID_LENGTH_ALLOWED enhances maintainability and readability and ensures consistency across the codebase.


105-105: Validate usage of new chain-length check.
The new check if (length > MAX_CHAINID_LENGTH_ALLOWED) is straightforward. Ensure that edge cases (e.g., exactly 32 chain IDs) are covered by your tests.

src/Periphery/ReceiverAcrossV3.sol (1)

108-108: Improved token approval logic.
Using safeApproveWithRetry helps circumvent non-zero allowance errors. This is generally efficient but verify that the executor contract does not rely on any leftover approval after execution.

src/Facets/GasZipFacet.sol (3)

27-27: Renamed constant clarifies non-EVM usage.
Changing NON_EVM_RECEIVER_IDENTIFIER to NON_EVM_ADDRESS is clearer. Confirm that references in tests and other contracts have been updated accordingly.


109-109: Receiver address validation for EVM vs. non-EVM flows.
The conditional ensures EVM addresses differ from the NON_EVM_ADDRESS placeholder. Double-check that bridging to non-EVM addresses is tested thoroughly, especially for receivers with unusual address formats.


135-135: Same chain ID length check.
The logic aligns with GasZipPeriphery. Ensure consistent unit testing covers boundary conditions (e.g., 1, 32, and more than 32 chain IDs).

src/Libraries/LibAsset.sol (1)

70-70: Streamlined ERC20 approval using forceApprove.
Replacing the two-step approval process with SafeERC20.forceApprove is more gas-efficient and concise. Just confirm the underlying token adheres to expected ERC20 behaviors (e.g., some tokens do not allow setting non-zero allowances without resetting to 0 first).

src/Periphery/Permit2Proxy.sol (1)

Line range hint 204-218: Variable rename improves clarity.
Renaming permit to tokenPermissionsHash in getPermit2MsgHash accurately conveys the variable’s role, reducing potential confusion. The updated usage is consistent and clear.

@lifi-action-bot
Copy link
Collaborator

lifi-action-bot commented Dec 26, 2024

Test Coverage Report

Line Coverage: 78.74% (2200 / 2794 lines)
Function Coverage: 84.58% ( 384 / 454 functions)
Branch Coverage: 39.12% ( 214 / 547 branches)
Test coverage (78.74%) is above min threshold (76%). Check passed.

@ezynda3 ezynda3 marked this pull request as ready for review January 3, 2025 06:51
@lifi-action-bot lifi-action-bot changed the title Audit fixes Audit fixes [GasZipFacet v2.0.1,LibAsset v1.0.2,GasZipPeriphery v1.0.1,Permit2Proxy v1.0.1,ReceiverAcrossV3 v1.0.2] Jan 3, 2025
maxklenk
maxklenk previously approved these changes Jan 6, 2025
maxklenk
maxklenk previously approved these changes Jan 9, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21e9547 and 1597135.

⛔ Files ignored due to path filters (1)
  • audit/reports/report-cantinacode-lifi-1216.pdf is excluded by !**/*.pdf
📒 Files selected for processing (1)
  • audit/auditLog.json (6 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: generate-tag
  • GitHub Check: analyze
🔇 Additional comments (4)
audit/auditLog.json (4)

108-113: Note the change in auditor

The audit entry audit20250110 is performed by Cantina (security firm) while all other audits are by Sujith Somraaj. This diversity in auditors is a good practice for getting different perspectives on the codebase.


247-255: Verify RelayerCelerIM version jumps

The RelayerCelerIM shows significant version jumps and parallel versions:

  • v1.0.3 → v2.1.0 (major version jump)
  • v2.1.1 added same day as v2.1.0

This could indicate breaking changes. Ensure proper migration documentation exists.

✅ Verification successful

Version jumps are audit-driven, not functionality-breaking

The version changes (1.0.3 → 2.1.0 → 2.1.1) are all part of the same audit cycle (audit20250109) and don't represent breaking changes. The core functionality of the RelayerCelerIM contract remains consistent across versions.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Look for migration guides or breaking change documentation
fd -e md -e txt | xargs rg -l "migration|upgrade|breaking.?change" -i

# Check commit messages for breaking changes
git log --oneline -p -- "**/RelayerCelerIM.sol" | grep -B 5 -A 5 "BREAKING"

Length of output: 155


Script:

#!/bin/bash
# Find RelayerCelerIM implementation files
fd RelayerCelerIM

# Look for any docs or comments mentioning RelayerCelerIM versions
rg -i "RelayerCelerIM.*(1\.0\.3|2\.1\.[01])" -A 5 -B 5

# Check if there are any version tags
git tag | grep -i "relayer.*celer"

Length of output: 262


Script:

#!/bin/bash
# Check documentation content
cat docs/RelayerCelerIM.md

# Look for version-related comments or changes in implementation
cat src/Periphery/RelayerCelerIM.sol

# Check test file for version-specific tests
cat test/solidity/Periphery/RelayerCelerIM.t.sol

Length of output: 32239


209-215: Verify Permit2Proxy version sequence

Multiple versions of Permit2Proxy were audited in close succession:

  • v1.0.1 by Cantina (audit20250110)
  • v1.0.2 by Sujith (audit20250109_3)

Ensure that v1.0.2 incorporates the findings from both audits.


193-199: Verify version ordering for LiFiDEXAggregator

The version sequence for LiFiDEXAggregator appears unusual:

  • v1.5.0 → v1.6.0 (expected)
  • v1.5.1 added after v1.6.0 (potential concern)

This could indicate a hotfix (v1.5.1) to the v1.5.x branch while v1.6.0 development continued separately.

✅ Verification successful

Version ordering for LiFiDEXAggregator is valid

The audit IDs (audit20250109_2 and audit20250109_3) show these versions were audited sequentially on January 9, 2025, indicating an intentional hotfix pattern where v1.5.1 was created to address issues in the v1.5.x branch while v1.6.0 development continued separately. This is a common and valid versioning practice.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check git history to understand the version sequence
git log --oneline -p -- "**/LiFiDEXAggregator.sol" | grep -B 5 -A 5 "version"

Length of output: 0


Script:

#!/bin/bash
# First, find the LiFiDEXAggregator file
fd LiFiDEXAggregator.sol

# Then check the audit logs for version information
cat audit/auditLog.json | jq '.[] | select(. | tostring | contains("1.5")) as $item'

# Look for version-related commits
git log --oneline | grep -i "version\|1.5\|1.6"

Length of output: 381


Script:

#!/bin/bash
# Check the current version in the file
cat src/Periphery/LiFiDEXAggregator.sol | grep -A 1 -B 1 "version"

# Get a better view of the audit log structure
cat audit/auditLog.json | jq '."LiFiDEXAggregator"'

# Look at the file history
git log --oneline src/Periphery/LiFiDEXAggregator.sol

Length of output: 249

audit/auditLog.json Outdated Show resolved Hide resolved
@lifi-action-bot lifi-action-bot changed the title Audit fixes [GasZipFacet v2.0.1,LibAsset v1.0.2,GasZipPeriphery v1.0.1,Permit2Proxy v1.0.1,ReceiverAcrossV3 v1.0.2] Audit fixes Jan 11, 2025
@lifi-action-bot lifi-action-bot changed the title Audit fixes Audit fixes [GasZipFacet v2.0.2] Jan 11, 2025
@ezynda3 ezynda3 enabled auto-merge (squash) January 11, 2025 12:00
@ezynda3 ezynda3 requested a review from maxklenk January 11, 2025 12:00
@ezynda3 ezynda3 merged commit 307207f into main Jan 11, 2025
18 checks passed
@ezynda3 ezynda3 deleted the audit-fixes branch January 11, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants