Skip to content

Audit fixes#156

Merged
abresas merged 7 commits intomainfrom
audit-fixes
Jan 30, 2026
Merged

Audit fixes#156
abresas merged 7 commits intomainfrom
audit-fixes

Conversation

@abresas
Copy link
Copy Markdown
Contributor

@abresas abresas commented Jan 27, 2026

No description provided.

@abresas abresas force-pushed the audit-fixes branch 5 times, most recently from d316d23 to 311e428 Compare January 27, 2026 14:59
Bridge Audit Report finding (1) recommended inheriting AccessControlUpgradeable for forward-compatibility.

In case in the future we update the openzeppelin contract versions, in order to be forward compatible we also:

* call AccessControl_init even if it is just an empty function
* inherit Initializer from the openzeppelin upgradeable contracts even though its just a re-export of the non-upgradeable version.
… one function

This was (1) finding of the Informational Findings of the Bridge Audit Report.

Parameter names were kept in order to produce the least amount of diff.

A new test suite was added with a harness contract that allows directly calling
the new internal function.

Additionally, fuzz tests were implemented to cover more cases.
The Bridge Audit Report finding (2) of informational findings recommended
changing the behabiour of checkInLimits so that splitting an action does not
lead to a different result.

This was achieved by setting the remaining capacity equal to the excess amount.

As a result of this, larger that limit amounts where allowed to be posted,
so that again, splitting a large amount into many small amounts does not make a difference.

Unit tests and fuzz tests were added as well.
Per Bridge Audit Report informational finding #3.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses audit findings by fixing critical issues in the Bridge contract's limit checking logic and updating to upgradeable OpenZeppelin contracts. The changes prevent a vulnerability where splitting deposits across period resets could reduce limit usage, and ensure proper initialization of upgradeable contracts.

Changes:

  • Fixed daily limit logic to properly handle deposits spanning reset periods by tracking excess separately
  • Migrated from standard OpenZeppelin contracts to upgradeable versions with proper initialization
  • Added comprehensive test coverage for validator set updates and limit checking edge cases

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
solidity-sdk/lib/openzeppelin-contracts-upgradeable Added OpenZeppelin upgradeable contracts submodule
protocol/test/Bridge.t.sol Added tests for deposit limit boundary conditions and validator set management
protocol/test/Bridge.fork.sol Reformatted code for consistency
protocol/src/Bridge.sol Fixed limit checking logic and migrated to upgradeable contracts
protocol/script/DeployBridge.s.sol Reformatted deployment script
protocol/foundry.toml Updated remappings for upgradeable contracts
.gitmodules Added upgradeable contracts submodule reference

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread protocol/src/Bridge.sol
uint256 _version,
bytes32 _merkleRoot
) external initializer {
__AccessControl_init();
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The __AccessControl_init() function is called without the _init_unchained pattern, which could lead to duplicate initialization if this contract is inherited. Consider using __AccessControl_init_unchained() instead, or verify that the initialization pattern is correct for your inheritance hierarchy.

Suggested change
__AccessControl_init();
__AccessControl_init_unchained();

Copilot uses AI. Check for mistakes.
Comment thread protocol/src/Bridge.sol
mstore(add(ptr, 0x44), to)

dataHash := keccak256(ptr, 0x64)
dataHash := keccak256(ptr, lenData)
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

The variable lenData is used but not defined in this assembly block. Based on the context, this should be 0x64 (100 bytes) to match the data structure being hashed. This will cause compilation failure.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

this is obviously untrue since the code compiles

Finding (3.1.1) from the Bridge Audit Report recommended that we specify
the version of the transactions being claimed. Otherwise, the merkle tree
should be based on resigning all the transactions that havent been claimed
so far from the previous round, and would force us to make sure that no transaction
that has been claimed is part of the merkle tree.
@abresas abresas merged commit 6c93241 into main Jan 30, 2026
9 checks passed
@abresas abresas deleted the audit-fixes branch January 30, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants