Skip to content

Commit 49de9a2

Browse files
authored
fix(lazer): address evm contract audit (#2415)
1 parent 64b26bf commit 49de9a2

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

lazer/contracts/evm/src/PythLazer.sol

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ pragma solidity ^0.8.13;
33

44
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
55
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
6+
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
67

78
contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
89
TrustedSignerInfo[100] internal trustedSigners;
910
uint256 public verification_fee;
1011

12+
constructor() {
13+
_disableInitializers();
14+
}
15+
1116
struct TrustedSignerInfo {
1217
address pubkey;
1318
uint256 expiresAt;
@@ -20,10 +25,6 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
2025
verification_fee = 1 wei;
2126
}
2227

23-
function migrate() public onlyOwner {
24-
verification_fee = 1 wei;
25-
}
26-
2728
function _authorizeUpgrade(address) internal override onlyOwner {}
2829

2930
function updateTrustedSigner(
@@ -91,7 +92,7 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
9192
}
9293
payload = update[71:71 + payload_len];
9394
bytes32 hash = keccak256(payload);
94-
signer = ecrecover(
95+
(signer, , ) = ECDSA.tryRecover(
9596
hash,
9697
uint8(update[68]) + 27,
9798
bytes32(update[4:36]),

lazer/contracts/evm/src/PythLazerLib.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: UNLICENSED
22
pragma solidity ^0.8.13;
33

4-
import {console} from "forge-std/console.sol";
54
import {PythLazer} from "./PythLazer.sol";
65

76
library PythLazerLib {

lazer/contracts/evm/test/PythLazer.t.sol

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,26 @@ pragma solidity ^0.8.13;
33

44
import {Test, console} from "forge-std/Test.sol";
55
import {PythLazer} from "../src/PythLazer.sol";
6+
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
67

78
contract PythLazerTest is Test {
89
PythLazer public pythLazer;
10+
address owner;
911

1012
function setUp() public {
11-
pythLazer = new PythLazer();
12-
pythLazer.initialize(address(1));
13+
owner = address(1);
14+
PythLazer pythLazerImpl = new PythLazer();
15+
TransparentUpgradeableProxy proxy = new TransparentUpgradeableProxy(
16+
address(pythLazerImpl),
17+
owner,
18+
abi.encodeWithSelector(PythLazer.initialize.selector, owner)
19+
);
20+
pythLazer = PythLazer(address(proxy));
1321
}
1422

1523
function test_update_add_signer() public {
1624
assert(!pythLazer.isValidSigner(address(2)));
17-
vm.prank(address(1));
25+
vm.prank(owner);
1826
pythLazer.updateTrustedSigner(address(2), block.timestamp + 1000);
1927
assert(pythLazer.isValidSigner(address(2)));
2028
skip(2000);
@@ -23,19 +31,19 @@ contract PythLazerTest is Test {
2331

2432
function test_update_remove_signer() public {
2533
assert(!pythLazer.isValidSigner(address(2)));
26-
vm.prank(address(1));
34+
vm.prank(owner);
2735
pythLazer.updateTrustedSigner(address(2), block.timestamp + 1000);
2836
assert(pythLazer.isValidSigner(address(2)));
2937

30-
vm.prank(address(1));
38+
vm.prank(owner);
3139
pythLazer.updateTrustedSigner(address(2), 0);
3240
assert(!pythLazer.isValidSigner(address(2)));
3341
}
3442

3543
function test_verify() public {
3644
// Prepare dummy update and signer
3745
address trustedSigner = 0xb8d50f0bAE75BF6E03c104903d7C3aFc4a6596Da;
38-
vm.prank(address(1));
46+
vm.prank(owner);
3947
pythLazer.updateTrustedSigner(trustedSigner, 3000000000000000);
4048
bytes
4149
memory update = hex"2a22999a9ee4e2a3df5affd0ad8c7c46c96d3b5ef197dd653bedd8f44a4b6b69b767fbc66341e80b80acb09ead98c60d169b9a99657ebada101f447378f227bffbc69d3d01003493c7d37500062cf28659c1e801010000000605000000000005f5e10002000000000000000001000000000000000003000104fff8";

0 commit comments

Comments
 (0)