Skip to content
Merged
Show file tree
Hide file tree
Changes from 55 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
31b2502
feat(lz-ohm-bridge): add a preliminary version
Yurii3721 Feb 26, 2026
c737109
chore: add dependency LayerZero v1 1.1.0
Yurii3721 Feb 26, 2026
e90abec
docs(lz-bridge): add current implementation plan
Yurii3721 Feb 26, 2026
1068864
feat(lz-bridge-gateway): implement a preliminary version of OHM bridging
Yurii3721 Feb 28, 2026
7ee6748
test(lz-bridge-gateway): add basic fork tests
Yurii3721 Feb 28, 2026
d4341f0
fix(lz-bridge-gw): remove unused payable from retryMessage and docume…
Yurii3721 Mar 7, 2026
ca18cfc
fix(lz-bridge,lz-bridge-gw): clean up and adjust consistency
Yurii3721 Mar 7, 2026
0fce03c
test(lz-bridge,lz-bridge-gw): add
Yurii3721 Mar 7, 2026
6669203
test(lz-bridge,lz-bridge-gw): adjust validations
Yurii3721 Mar 7, 2026
3f295d1
feat(lz-bridge-proposal,lz-bridge-ms-batches): add
Yurii3721 Mar 10, 2026
dfaa60e
docs(lz-bridge-gw): simplify the comment for `forceResumeReceive` sli…
Yurii3721 Mar 10, 2026
d199b1a
docs(lz-bridge-config): update source
Yurii3721 Mar 10, 2026
c822c9d
chore: update lz batch contracts licenses
zeroxnoodle Mar 10, 2026
b1293b1
chore(lz-bridge): add deployment scripts
Yurii3721 Mar 10, 2026
1cac29e
chore: add audit scope and docs for lz bridge upgrade
zeroxnoodle Mar 10, 2026
b6b0a2d
chore(lz-bridge): correct the audit document slightly
Yurii3721 Mar 10, 2026
35c171c
chore(lz-bridge): remove out-of-scope context from audit README
zeroxnoodle Mar 10, 2026
0ee9b7e
chore: fix formatting issue in mermaid diagrams
zeroxnoodle Mar 10, 2026
b51e332
test(lz-bridge): add basic fork tests for LayerZero configuration
Yurii3721 Mar 10, 2026
1382701
chore(lz-bridge): split L2 gateway setup into for role separation
zeroxnoodle Mar 10, 2026
391650a
Merge remote-tracking branch 'callisto/lz-bridge-security-revamp' int…
zeroxnoodle Mar 10, 2026
d07dd25
chore(lz-bridge-gw-l2-batch): adjust comments slightly and correct fo…
Yurii3721 Mar 10, 2026
20c280d
feat(lz-bridge): migrate to LayerZero V2 with updated endpoint and me…
zeroxnoodle Mar 11, 2026
e5e3a30
chore(lz-bridge): disable OCG proposal, MS batch scripts and tests te…
Yurii3721 Mar 13, 2026
6fe1f8c
chore: install LayerZero v2 dependencies
Yurii3721 Mar 13, 2026
9be119c
chore(lz-bridge): disable MS batch libs temporarily by renaming their…
Yurii3721 Mar 13, 2026
8a4b793
feat(lz-bridge): migrate to LayerZero endpoint v2 (preliminary version)
Yurii3721 Mar 13, 2026
d31a1f9
fix(lz-bridge): set `VERSION` to 1,0
Yurii3721 Mar 17, 2026
c5927e2
test(lz-bridge): add unit tests
Yurii3721 Mar 17, 2026
70ea36a
test(lz-bridge-gw): return fork tests
Yurii3721 Mar 17, 2026
7222d49
test(lz-bridge-gw): re-write fork tests
Yurii3721 Mar 17, 2026
8f46901
chore(lz-bridge-gw): return test files back
Yurii3721 Mar 18, 2026
8af1823
test(lz-bridge-gw): re-write unit and fork config tests
Yurii3721 Mar 18, 2026
2414a28
chore(lz-bridge-proposal,-batches): return files
Yurii3721 Mar 18, 2026
4fca1c2
feat(lz-bridge-proposal,-batches): re-write
Yurii3721 Mar 18, 2026
6204597
build(foundry-conf): simplify `compilation_restrictions`
Yurii3721 Mar 18, 2026
542bd44
docs(lz-bridge): remove an old document
Yurii3721 Mar 18, 2026
b3b3636
refactor(lz-bridge-gw): use original LZ rate limiter
Yurii3721 Mar 19, 2026
5b1d093
chore(lz-bridge-ms-batches): add `disableOldBridge`
Yurii3721 Mar 19, 2026
9cca55b
perf(lz-bridge-gw): use `calldata`
Yurii3721 Mar 19, 2026
b20e21d
chore(lz-bridge): clean up comments and improve clarity in scripts an…
zeroxnoodle Mar 19, 2026
272014a
chore(docs): update audit README with LayerZero V2 changes
zeroxnoodle Mar 19, 2026
b4b14c4
chore(lz-bridge): document OCG timelock roles
zeroxnoodle Mar 19, 2026
d274ad5
refactor: update comments & remove the planning doc
zeroxnoodle Mar 20, 2026
3c22f18
chore: run lint
zeroxnoodle Mar 20, 2026
e165e6a
docs(lz-bridge): adjust the audit document
Yurii3721 Mar 20, 2026
28cc4fa
docs(lz-bridge): adjust the audit document
Yurii3721 Mar 20, 2026
92008cd
refactor(lz-bridge): import original LZ structures
Yurii3721 Mar 20, 2026
ce94a3f
docs(lz-bridge-gw): describe ported LZ logic
Yurii3721 Mar 20, 2026
49385fe
chore(lz-bridge): sort imports and remove unused
Yurii3721 Mar 20, 2026
7a8d18c
perf(lz-bridge-gw): avoid an extra `SSTORE`
Yurii3721 Mar 20, 2026
13ccf84
docs(lz-bridge): clean up the audit document
Yurii3721 Mar 20, 2026
6958b24
chore(lz-bridge): clean up unused imports
Yurii3721 Mar 20, 2026
ef9e05e
docs(lz-bridge): adjust the audit document
Yurii3721 Mar 20, 2026
d950ffd
chore(docs): update README.md formatting & scopefile.txt
zeroxnoodle Mar 20, 2026
50d9ef9
docs(lz-bridge): correct branch name and diagram in the audit document
Yurii3721 Mar 20, 2026
684d8b9
fix(lz-bridge-gw): check payload len in `_decodeAndRoute` and the zer…
Yurii3721 Mar 20, 2026
bb554ac
fix(lz-bridge-proposal): bump Solidity pragma
Yurii3721 Mar 20, 2026
06705ea
chore(lz-bridge-l2-batch): pass `_owner` to `vm.startBroadcast()` for…
Yurii3721 Mar 20, 2026
33e0b4b
test(lz-bridge-gw): add `vm.expectCall` assertions to endpoint config…
Yurii3721 Mar 20, 2026
a7ba8a6
test(lz-bridge-gw): correct GUID assertion
Yurii3721 Mar 20, 2026
e5e507d
style(lz-bridge): use a versioned import for Solmate
Yurii3721 Mar 20, 2026
744a359
docs(lz-bridge): correct the audit document
Yurii3721 Mar 20, 2026
0c85db4
refactor(lz-bridge-l2-batch): re-use _runBatch and re-order imports
Yurii3721 Mar 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
199 changes: 199 additions & 0 deletions audit/2026-03_lz-bridge-upgrade/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
# Olympus LayerZero Bridge Security Upgrade Audit

## Purpose

The purpose of this audit is to review the security upgrade of the Olympus LayerZero cross-chain OHM bridge infrastructure, replacing the existing `CrossChainBridge` policy with a new two-contract architecture: `LZBridgeGateway` (infrastructure policy) and `LZCrossChainBridge` (periphery facilitator).

These contracts will be installed in the Olympus V3 "Bophades" system, based on the [Default Framework](https://palm-cause-2bd.notion.site/Default-A-Design-Pattern-for-Better-Protocol-Development-7f8ace6d263c4303b108dc5f8c3055b1).

## Design

The existing `CrossChainBridge` policy (deployed on Ethereum mainnet and Arbitrum) combines user-facing bridging, LayerZero endpoint communication, and OHM mint/burn into a single contract. This upgrade separates concerns into two contracts and introduces several security hardening measures.

The new design splits the bridge into two contracts:

1. **LZBridgeGateway** (Policy) - Infrastructure contract that handles all LayerZero V2 endpoint communication, OHM mint/burn via MINTR, peer management, enforced options, rate limiting, bridged supply tracking and cap enforcement, and proxying of LZ V2 endpoint configuration and message management functions for the `bridge_admin` role.
2. **LZCrossChainBridge** (Periphery) - User-facing facilitator contract that has no privileged access to the Olympus protocol. Users approve and send OHM through this contract, which transfers it to the gateway for burning and cross-chain messaging.

```text
User -> LZCrossChainBridge (facilitator) -> LZBridgeGateway (policy) -> LZ Endpoint V2 -> [destination]
```

On receive:

```text
LZ Endpoint V2 -> LZBridgeGateway.lzReceive -> validate peer -> mint OHM to recipient
```

Additionally, an OCG proposal and multisig batch scripts handle the on-chain migration: deployment, pre-OCG gateway wiring, OCG execution (LZ V2 config + peers + cap + options + enable gateway), old bridge disablement, bridged supply snapshot, non-canonical chain setup, and Ethereum periphery activation.

## Scope

### In-Scope Contracts

#### Core Contracts

- [src/](../../src)
- [periphery/](../../src/periphery/)
- [bridge/](../../src/periphery/bridge/)
- [LZCrossChainBridge.sol](../../src/periphery/bridge/LZCrossChainBridge.sol) - Facilitator (periphery)
- [interfaces/](../../src/periphery/interfaces/)
- [ILZCrossChainBridge.sol](../../src/periphery/interfaces/ILZCrossChainBridge.sol) - Facilitator interface
- [policies/](../../src/policies/)
- [bridge/](../../src/policies/bridge/)
- [LZBridgeGateway.sol](../../src/policies/bridge/LZBridgeGateway.sol) - Gateway infrastructure policy
- [interfaces/](../../src/policies/interfaces/)
- [ILZBridgeGateway.sol](../../src/policies/interfaces/ILZBridgeGateway.sol) - Gateway interface
- [ILZEndpointV2Admin.sol](../../src/policies/interfaces/ILZEndpointV2Admin.sol) - LZ V2 endpoint admin interface

**OApp provenance:** Peer management, endpoint send/receive, and enforced-option logic are ported inline from `@lz-oapp-evm v0.4.1` (OAppCore, OAppSender, OAppReceiver, OAppOptionsType3) because those contracts assume OZ Ownable, incompatible with Bophades Kernel RBAC. `RateLimiter` is the only OApp contract inherited directly (no Ownable dependency); its integration and `_outflow`/`_inflow` overrides are in scope, the base contract itself is not.

#### Deployment & Configuration

These contracts configure and deploy the core contracts. Misconfiguration here (wrong addresses, wrong confirmation counts, incorrect role grants, wrong migration ordering) can undermine the security properties of the core contracts.

- [src/](../../src)
- [scripts/deploy/](../../src/scripts/deploy/)
- [DeployV3.s.sol](../../src/scripts/deploy/DeployV3.s.sol) - `deployLZCrossChainBridge()` and `deployLZBridgeGateway()` deployment functions
- [libraries/](../../src/libraries/)
- [LZConfigLib.sol](../../src/libraries/LZConfigLib.sol) - Shared LZ V2 constants (endpoints, SendUln302/ReceiveUln302 libraries, DVNs, executor, confirmation counts) and encoding helpers
- [proposals/](../../src/proposals/)
- [LZBridgeSecurityUpgradeProposal.sol](../../src/proposals/LZBridgeSecurityUpgradeProposal.sol) - OCG proposal: configures gateway on Ethereum (pins V2 libraries, sets ULN/Executor config, peers, supply cap, enforced options)
- [scripts/ops/batches/](../../src/scripts/ops/batches/)
- [lib/](../../src/scripts/ops/batches/lib/)
- [LZBridgeBatchScript.sol](../../src/scripts/ops/batches/lib/LZBridgeBatchScript.sol) - Base class with shared constants, per-chain DVN addresses, and LZ V2 configuration helpers
- [LZBridgeL2BatchScript.sol](../../src/scripts/ops/batches/lib/LZBridgeL2BatchScript.sol) - Base class for non-canonical chains (skips OlympusHeart validation)
- [LZBridgeGatewayBatch.sol](../../src/scripts/ops/batches/LZBridgeGatewayBatch.sol) - Ethereum MS batch: activate gateway, set initial bridged supply
- [LZBridgeGatewayL2Batch.sol](../../src/scripts/ops/batches/LZBridgeGatewayL2Batch.sol) - L2 MS batch: deactivate old bridge, activate gateway, grant roles, configure LZ V2, set peers, set enforced options, enable
- [LZCrossChainBridgeBatch.sol](../../src/scripts/ops/batches/LZCrossChainBridgeBatch.sol) - Ethereum MS batch: `setGateway` (pre-OCG), `disableOldBridge` (post-OCG), `setup` (deactivate old + enable new)
- [LZCrossChainBridgeL2Batch.sol](../../src/scripts/ops/batches/LZCrossChainBridgeL2Batch.sol) - L2 MS batch: `disableOldBridge`, `setupL2` (set gateway ref + enable facilitator)

Branch: `lz-bridge-security-upgrade-v2`
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

### Previous Audits

You can review previous audits here:

- Spearbit (07/2022)
- [Report](https://storage.googleapis.com/olympusdao-landing-page-reports/audits/2022-08%20Code4rena.pdf)
- Code4rena Olympus V3 Audit (08/2022)
- [Repo](https://github.com/code-423n4/2022-08-olympus)
- [Findings](https://github.com/code-423n4/2022-08-olympus-findings)
- Kebabsec Olympus V3 Remediation and Follow-up Audits (10/2022 - 11/2022)
- [Remediation Audit Phase 1 Report](https://hackmd.io/tJdujc0gSICv06p_9GgeFQ)
- [Remediation Audit Phase 2 Report](https://hackmd.io/@12og4u7y8i/rk5PeIiEs)
- [Follow-on Audit Report](https://hackmd.io/@12og4u7y8i/Sk56otcBs)
- Cross-Chain Bridge by OtterSec (04/2023)
- [Report](https://storage.googleapis.com/olympusdao-landing-page-reports/audits/Olympus-CrossChain-Audit.pdf)
- Cooler V2 by Electisec (03/2025)
- [Report](https://storage.googleapis.com/olympusdao-landing-page-reports/audits/Olympus_CoolerV2-Electisec_report.pdf)
- The PolicyEnabler and PolicyAdmin mix-ins are audited here

## Implementation

### Key Security Improvements Over CrossChainBridge

1. **Bridged supply cap** (canonical chain only): Tracks outbound OHM (`bridgedSupply`) and enforces a configurable `bridgedSupplyCap` to limit exposure in case of bridge compromise. Combined with an underflow check on inbound receives, this prevents unlimited mints from non-canonical chains.
2. **`onlyEnabled` on `lzReceive`**: The original `CrossChainBridge` does not check `bridgeActive` on inbound messages. The new gateway checks `onlyEnabled`, meaning disabling the bridge blocks both inbound and outbound transfers.
3. **Elimination of custom retry mechanism**: The original `CrossChainBridge` stores failed message hashes in `failedMessages` and exposes a `retryMessage` function that does not re-validate the trusted remote. The new gateway removes this entirely in favour of native LayerZero V2 message delivery, which enforces peer validation on retry and eliminates the risk of replaying messages from removed peers.
4. **Separation of concerns**: The facilitator (`LZCrossChainBridge`) has no MINTR permissions. It merely transfers OHM to the gateway and calls `burnAndSend`. This limits the blast radius if the facilitator is compromised.
5. **Typed message encoding**: Payload format changed from `abi.encode(to, amount)` to `abi.encode(uint8 msgType, bytes data)` to support future message types.
6. **Explicit LZ V2 endpoint configuration**: Migration from default LayerZero V1 configuration to explicitly pinned V2 endpoint configuration (SendUln302/ReceiveUln302 libraries, DVN and Executor config), eliminating the drag-along vulnerability and the proof library substitution attack vector. Verification uses dual-DVN confirmation (LayerZero DVN + Google Cloud DVN).
7. **`bridge_admin` role separation**: LZ endpoint configuration (`setSendLibrary`, `setReceiveLibrary`, `setEndpointConfig`, `skip`, `nilify`, `burn`, `clear`), `setBridgedSupply`, and `setDelegate` use a dedicated `bridge_admin` role, separate from the `admin` role used for business-level configuration. The `setDelegate` function allows setting an LZ endpoint delegate as a fallback mechanism for future endpoint interface changes not yet proxied by the gateway; by default no delegate is set and all endpoint administration flows through the gateway's own functions.
8. **Enforced Type 3 options**: Replaces LayerZero V1 adapter parameters with enforced Type 3 options that guarantee minimum destination gas per message type. The gateway supports combining enforced options with caller-supplied options at send time.
9. **Per-endpoint rate limiting**: Opt-in rate limiting via `RateLimiter` inheritance. Outbound transfers are enforced against a per-EID limit; inbound transfers reduce the in-flight amount (enabling more outbound), but are not independently capped. The gateway overrides `_outflow` to skip unconfigured EIDs (where `limit == 0 && window == 0`); the base `_inflow` is safe for unconfigured EIDs without override.
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
10. **V2 message recovery primitives**: Replaces the V1 `forceResumeReceive` with native V2 recovery functions (`skip`, `nilify`, `burn`, `clear`), administered by the `bridge_admin` role.

### LZ V2 Receiver Callbacks

The gateway implements `ILayerZeroReceiver`:

- **`allowInitializePath(origin)`**: Returns `true` only if `peers[origin.srcEid] == origin.sender`. Controls which communication paths the LZ V2 endpoint can initialize for this contract.
- **`nextNonce(_, _)`**: Returns `0` — unordered (nonce-independent) delivery, the default per `OAppReceiver` (`@lz-oapp-evm-0.4.1`). Matches the original V1 CrossChainBridge, which also does not enforce message ordering.

### Bridged Supply Tracking

On the canonical chain (Ethereum, `IS_CANONICAL == true`):

- **Outbound** (`burnAndSend`): `bridgedSupply += amount`; reverts if `bridgedSupply > bridgedSupplyCap`
- **Inbound** (`_receiveBridgeOhm`): `bridgedSupply -= amount`; reverts if underflow

On non-canonical chains: supply tracking is skipped entirely.

`setBridgedSupply` is available to the `bridge_admin` role for migration bootstrapping and error recovery.

### Message Flow

#### Sending OHM (Source Chain)

```mermaid
sequenceDiagram
participant User
participant LZCrossChainBridge
participant LZBridgeGateway
participant MINTR
participant LZEndpointV2

User->>LZCrossChainBridge: sendOhm(dstEid, to, amount) + native fee
LZCrossChainBridge->>LZBridgeGateway: OHM.transferFrom(user, gateway, amount)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
LZCrossChainBridge->>LZBridgeGateway: burnAndSend{value}(dstEid, to, amount, refund, extraOptions)
LZBridgeGateway->>LZBridgeGateway: validate peer exists for dstEid
LZBridgeGateway->>LZBridgeGateway: rate limit outflow
LZBridgeGateway->>LZBridgeGateway: [canonical] bridgedSupply += amount, check cap
LZBridgeGateway->>MINTR: approve + burnOhm(gateway, amount)
LZBridgeGateway->>LZBridgeGateway: combine enforced + extra options
LZBridgeGateway->>LZEndpointV2: send(MessagingParams, refundAddr)
LZBridgeGateway-->>LZBridgeGateway: emit Sent(sender, amount, dstEid, guid)
```

#### Receiving OHM (Destination Chain)

```mermaid
sequenceDiagram
participant LZEndpointV2
participant LZBridgeGateway
participant MINTR
participant Recipient

LZEndpointV2->>LZBridgeGateway: lzReceive(origin, guid, message, executor, extraData)
LZBridgeGateway->>LZBridgeGateway: validate onlyEnabled, endpoint, peer
LZBridgeGateway->>LZBridgeGateway: decode msgType, route to _receiveBridgeOhm
LZBridgeGateway->>LZBridgeGateway: [canonical] bridgedSupply -= amount (revert on underflow)
LZBridgeGateway->>LZBridgeGateway: rate limit inflow
LZBridgeGateway->>MINTR: increaseMintApproval + mintOhm(to, amount)
MINTR->>Recipient: OHM minted
```

### Access Control Summary

#### LZBridgeGateway (Policy)

| Function | Access | Description |
|---|---|---|
| `burnAndSend` | `onlyFacilitator` + `onlyEnabled` | Burn OHM and send cross-chain |
| `lzReceive` | `onlyEnabled` + `msg.sender == LZ_ENDPOINT` + peer check | Receive LZ V2 messages |
| `setPeer` | `onlyAdminRole` | Set/clear peer gateway for a remote EID |
| `setDelegate` | `onlyRole("bridge_admin")` | Set delegate on LZ endpoint |
| `setFacilitator` | `onlyAdminRole` | Set facilitator address |
| `setBridgedSupplyCap` | `onlyAdminRole` | Set bridged supply cap (canonical only) |
| `setBridgedSupply` | `onlyRole("bridge_admin")` | Manual supply correction (canonical only) |
| `setEnforcedOptions` | `onlyAdminRole` | Set enforced Type 3 options per EID/msgType |
| `setRateLimits` | `onlyAdminRole` | Set rate limit configs per EID |
| `resetRateLimits` | `onlyRole("bridge_admin")` | Reset rate limit state (amountInFlight) |
| `setSendLibrary` | `onlyRole("bridge_admin")` | Pin send library on LZ endpoint |
| `setReceiveLibrary` | `onlyRole("bridge_admin")` | Pin receive library on LZ endpoint |
| `setReceiveLibraryTimeout` | `onlyRole("bridge_admin")` | Set receive library migration timeout |
| `setEndpointConfig` | `onlyRole("bridge_admin")` | Set ULN/Executor config on a message library |
| `skip` | `onlyRole("bridge_admin")` | Skip a nonce on the LZ endpoint |
| `nilify` | `onlyRole("bridge_admin")` | Nilify a payload on the LZ endpoint |
| `burn` | `onlyRole("bridge_admin")` | Burn a payload on the LZ endpoint |
| `clear` | `onlyRole("bridge_admin")` | Clear a message on the LZ endpoint |
| `enable` / `disable` | `onlyAdminRole` / `onlyEmergencyOrAdminRole` | PolicyEnabler |

#### LZCrossChainBridge (Periphery)

| Function | Access | Description |
|---|---|---|
| `sendOhm` | `onlyEnabled` (public) | User-facing: send OHM cross-chain |
| `setGateway` | `onlyOwner` | Set gateway address |
| `enable` / `disable` | `onlyOwner` | PeripheryEnabler |
29 changes: 29 additions & 0 deletions audit/2026-03_lz-bridge-upgrade/scopefile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# LayerZero V2 Bridge Upgrade Audit Scope

# Olympus V3 — LZ Bridge Security Upgrade

# Core Contracts

src/policies/bridge/LZBridgeGateway.sol
src/policies/interfaces/ILZBridgeGateway.sol
src/policies/interfaces/ILZEndpointV2Admin.sol
src/periphery/bridge/LZCrossChainBridge.sol
src/periphery/interfaces/ILZCrossChainBridge.sol
src/libraries/LZConfigLib.sol

# Deployment & Configuration

src/scripts/deploy/DeployV3.s.sol

# OCG Proposal

src/proposals/LZBridgeSecurityUpgradeProposal.sol

# Multisig Batch Scripts

src/scripts/ops/batches/lib/LZBridgeBatchScript.sol
src/scripts/ops/batches/lib/LZBridgeL2BatchScript.sol
src/scripts/ops/batches/LZBridgeGatewayBatch.sol
src/scripts/ops/batches/LZBridgeGatewayL2Batch.sol
src/scripts/ops/batches/LZCrossChainBridgeBatch.sol
src/scripts/ops/batches/LZCrossChainBridgeL2Batch.sol
Loading
Loading