-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing Audit Findings #67
Conversation
fixed threshold finding using associated storage to store attesters to be 4337 compliant
@@ -41,7 +41,7 @@ struct TrustedAttesterRecord { | |||
uint8 attesterCount; // number of attesters in the linked list | |||
uint8 threshold; // minimum number of attesters required | |||
address attester; // first attester in linked list. (packed to save gas) | |||
mapping(address attester => address linkedAttester) linkedAttesters; // linked list | |||
mapping(address attester => mapping(address account => address linkedAttester)) linkedAttesters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: using associated storage to comply with 4337
@@ -119,7 +119,17 @@ abstract contract TrustManager is IRegistry { | |||
// use this condition to save gas | |||
else if (threshold == 1) { | |||
AttestationRecord storage $attestation = $getAttestation({ module: module, attester: attester }); | |||
$attestation.enforceValid(moduleType); | |||
if ($attestation.checkValid(moduleType)) return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: added this routine, to handle the case that threshold == 1, but the first attester doesnt have an attestation
* ⚡️ Adding msg.sender separation for factory calls
* In order to separate msg.sender context from registry, | ||
* interactions with external Factories are done with this Trampoline contract. | ||
*/ | ||
contract FactoryTrampoline { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: added factory call trampoline, so calls made to factory dont come from msg.sender == registry
if ($getAttestation(module, attesters[i]).checkValid(ZERO_MODULE_TYPE)) { | ||
address attester = attesters[i]; | ||
if (attester < _attesterCache) revert InvalidTrustedAttesterInput(); | ||
else _attesterCache = attester; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: adding check here to ensure provided list is sorted and unique. thus deduped
// if attesters array has duplicates, revert | ||
if (attestersLength == 0) revert InvalidTrustedAttesterInput(); | ||
// if attesters array has duplicates or is too large revert | ||
if (attestersLength == 0 || attestersLength > type(uint8).max) revert InvalidTrustedAttesterInput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: adding check to prevent attester length to be over uint8 thus preventing cast issue
@@ -48,7 +80,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { | |||
returns (address moduleAddress) | |||
{ | |||
ResolverRecord storage $resolver = $resolvers[resolverUID]; | |||
if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolver($resolver.resolver); | |||
if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolverUID(resolverUID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: making revert message consistent
@@ -73,7 +105,7 @@ abstract contract ModuleManager is IRegistry, ResolverManager { | |||
ResolverRecord storage $resolver = $resolvers[resolverUID]; | |||
|
|||
// ensure that non-zero resolverUID was provided | |||
if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolver($resolver.resolver); | |||
if ($resolver.resolverOwner == ZERO_ADDRESS) revert InvalidResolverUID(resolverUID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: making revert message consistent
@@ -149,12 +159,15 @@ abstract contract TrustManager is IRegistry { | |||
uint256 count = $trustedAttesters.attesterCount; | |||
address attester0 = $trustedAttesters.attester; | |||
|
|||
// return if no trusted attesters are set | |||
if (count == 0) return attesters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: prevent revert in view function if no attesters were set
…orted array, and not sort in in memory to safe gas
if (attesters.length != attestersLength) revert InvalidTrustedAttesterInput(); | ||
// revert if the first attester is the zero address | ||
// other attesters can not be zero address, as the array was sorted | ||
if (attesters[0] == ZERO_ADDRESS) revert InvalidTrustedAttesterInput(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: checking address(0)
@@ -96,7 +96,7 @@ library TrustLib { | |||
*/ | |||
|
|||
assembly { | |||
let mask := 0xffffffffffff |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: fixing bitmask
@@ -75,12 +75,12 @@ type SchemaUID is bytes32; | |||
using { schemaEq as == } for SchemaUID global; | |||
using { schemaNotEq as != } for SchemaUID global; | |||
|
|||
function schemaEq(SchemaUID uid1, SchemaUID uid) pure returns (bool) { | |||
return SchemaUID.unwrap(uid1) == SchemaUID.unwrap(uid); | |||
function schemaEq(SchemaUID uid1, SchemaUID uid2) pure returns (bool) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NOTE: fixing inconsistent param namings
Fixing Audit Findings
🚨 Report Summary
For more details view the full report in OpenZeppelin Code Inspector |
fix: inconsistencies
* fix: eip 712 according to ackee's feedback
No description provided.