Skip to content

Commit 22439c5

Browse files
committed
fix: maci 8 expiration check for eas attestation
1 parent b03c709 commit 22439c5

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

packages/contracts/contracts/extensions/eas/EASChecker.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ contract EASChecker is BaseChecker {
2222
error AttesterNotTrusted();
2323
error NotYourAttestation();
2424
error InvalidSchema();
25+
error AttestationExpired(uint256 expirationTime);
2526

2627
/// @notice Initializes the contract.
2728
function _initialize() internal override {
@@ -68,6 +69,11 @@ contract EASChecker is BaseChecker {
6869
revert NotYourAttestation();
6970
}
7071

72+
// the attestation must not be expired
73+
if (attestation.expirationTime > 0 && attestation.expirationTime <= block.timestamp) {
74+
revert AttestationExpired(attestation.expirationTime);
75+
}
76+
7177
return true;
7278
}
7379
}

packages/contracts/contracts/test/extensions/mocks/MockEAS.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,21 @@ contract MockEAS is IEAS {
8181
revocable: false,
8282
data: ""
8383
});
84+
// expired attestation
85+
} else if (attestationId == 0x0000000000000000000000000000000000000000000000000000000000000005) {
86+
return
87+
Attestation({
88+
uid: "0x000000000000000000000000000001",
89+
schema: schema,
90+
time: 0,
91+
expirationTime: 1,
92+
revocationTime: 0,
93+
refUID: "0x000000000000000000000000000001",
94+
recipient: recipient,
95+
attester: attester,
96+
revocable: false,
97+
data: ""
98+
});
8499
// valid
85100
} else {
86101
return

packages/contracts/test/extensions/EAS.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@ describe("EAS", () => {
2525
const invalidSchemaAttestation = "0x0000000000000000000000000000000000000000000000000000000000000002"
2626
const invalidRecipientAttestation = "0x0000000000000000000000000000000000000000000000000000000000000003"
2727
const invalidAttesterAttestation = "0x0000000000000000000000000000000000000000000000000000000000000004"
28+
const expiredAttestation = "0x0000000000000000000000000000000000000000000000000000000000000005"
2829
// valid attestation
2930
const attestation = "0x0000000000000000000000000000000000000000000000000000000000000000"
30-
const anotherAttestation = "0x0000000000000000000000000000000000000000000000000000000000000005"
31+
const anotherAttestation = "0x0000000000000000000000000000000000000000000000000000000000000006"
3132

3233
before(async () => {
3334
;[deployer, subject, target, notSubject] = await ethers.getSigners()
@@ -122,6 +123,13 @@ describe("EAS", () => {
122123
).to.be.revertedWithCustomError(checker, "AttesterNotTrusted")
123124
})
124125

126+
it("should throw when the attestation is expired", async () => {
127+
await expect(policy.connect(target).enforce(subject, expiredAttestation)).to.be.revertedWithCustomError(
128+
checker,
129+
"AttestationExpired"
130+
)
131+
})
132+
125133
it("should enforce a user if the function is called with the valid data", async () => {
126134
const tx = await policy.connect(target).enforce(subject, attestation)
127135

0 commit comments

Comments
 (0)