Thorn Docs
  • Introduction
    • πŸ“ŽWhat is Thorn Protocol (Thorn)?
    • πŸ› οΈHow Thorn achieves confidentiality
    • πŸ—οΈWhy use Thorn?
  • 🌈AI Wallet
  • 🧠Thorn AI Agent: OmniFarming with Privacy
  • πŸŽ†Internal Audit
  • πŸ“A brief introduction to StableSwaps
  • πŸŽ₯Maximized confidentiality
  • βš™οΈAutomated Market Maker
  • Thorn Protocol_PitchDeck
  • πŸ“ƒOne Pager
  • OTHER RESOURCES
    • Website
    • Discord
    • Medium
    • Telegram
Powered by GitBook
On this page
  • Introduction
  • Project Summary
  • Vulnerability Summary
  • Findings
  • Detailed Results
  • ID-01: Missing zero address validation
  • ID-02: Mismatched function name
  • ID-03: Lack of comment for functions
  • Appendix
  • Severity Definitions
  • Finding Categories

Internal Audit

Introduction

This report presents the findings of the security assessment of the Thorn Stable Swap’s smart contract and its code review conducted between July 22nd, 2024 – July 26th, 2024.

Project Summary

  • Project Name: Thorn Stable Swap

  • Language: Solidity

  • Codebase:

  • Commit: f2cfa14f44b7326d514560257c2cdfb48e1be8ae

  • Audit method: Static Analysis, Manual Review

  • Scope:

    • contracts/stableSwap

    • contracts/StableSwapRouter.sol

Vulnerability Summary

Severity

# of Findings

Critical

0

Medium

0

Low

1

Informational

2

Findings

ID

Title

Type

Severity

ID-01

Missing zero address validation

Logical Issue

Low

ID-02

Mismatched function name

Coding Style

Informational

ID-03

Lack of comment for functions

Coding Style

Informational

Detailed Results

ID-01: Missing zero address validation

Type

Severity

Location

Logical Issue

Low

StableSwapRouter.sol#53

Logical Issue

Low

StableSwapRouter.sol#54

Logical Issue

Low

StableSwapLP.sol#28

Logical Issue

Low

SmartRouterHelper.sol#25

Description

Detect missing zero address validation. Transactions can be reverted in unexpected way if functions are called with invalid arguments.

At contracts/StableSwapRouter.sol#53, stableSwapFactory = _stableSwapFactory; is called without validating the _stableSwapFactory address.

At contracts/StableSwapRouter.sol#54, stableSwapInfo = _stableSwapInfo; is called without validating the _stableSwapInfo address.

At contracts/stableSwap/StableSwapLP.sol#28, minter = _newMinter; is called without validating the _newMinter address.

At contracts/libraries/SmartRouterHelper.sol#25, IStableSwapFactory.StableSwapPairInfo memory info = IStableSwapFactory(stableSwapFactory).getPairInfo(input, output); is called without validating the stableSwapFactory address.

Recommendation

Check that the address is not zero.

ID-02: Mismatched function name

Type

Severity

Location

Coding Style

Informational

TransferHelper.sol#56

Description

At TransferHelper.sol#56, function used to transfer native token (ROSE) is named safeTransferETH(address to, uint256 value).

Recommendation

Change function name to safeTransferROSE to avoid confusions.

ID-03: Lack of comment for functions

Type

Severity

Location

Coding Style

Informational

SmartRouterHelper.sol#18

Coding Style

Informational

SmartRouterHelper.sol#46

Coding Style

Informational

SmartRouterHelper.sol#66

Description

Functions without developer’s comments: getStableInfo(address, address, address, uint256); getStableAmountsIn(address, address, address[] memory, uint256[] memory, uint256); getStableAmountsOut(address, address[] memory, uint256[] memory, uint256)

Recommendation

Add comments for functionality, parameters, and return values

Appendix

Severity Definitions

Critical This level vulnerabilities could be exploited easily and can lead to asset loss, data loss, asset, or data manipulation. They should be fixed right away

Medium This level vulnerabilities are hard to exploit but very important to fix, they carry an elevated risk of smart contract manipulation, which can lead to critical-risk severity.

Low This level vulnerabilities should be fixed, as they carry an inherent risk of future exploits, and hacks which may or may not impact the smart contract execution.

Informational This level vulnerabilities can be ignored. They are code style violations and informational statements in the code. They may not affect the smart contract execution.

Finding Categories

Gas Optimization Gas Optimization findings refer to exhibits that do not affect the functionality of the code but generate different, more optimal EVM opcodes resulting in a reduction on the total gas cost of a transaction.

Logical Issue Logical Issue findings are exhibits that detail a fault in the logic of the linked code, such as an incorrect notion on how block.timestamp works.

Coding Style Coding Style findings usually do not affect the generated byte-code and comment on how to make the codebase more legible and as a result easily maintainable.

Mathematical Operations Mathematical Operation exhibits entail findings that relate to mishandling of math formulas, such as overflows, incorrect operations etc.

Dead Code Code that otherwise does not affect the functionality of the codebase and can be safely omitted.

Language Specific Language Specific findings are issues that would only arise within Solidity, i.e. incorrect usage of private or delete.

PreviousThorn AI Agent: OmniFarming with PrivacyNextA brief introduction to StableSwaps

Last updated 9 months ago

πŸŽ†