Skip to content
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

Sig malleability protection for erc1271 only #215

Merged
merged 4 commits into from
Nov 2, 2024

Conversation

filmakarov
Copy link
Collaborator

Moved sig malleability protection to 1271 flow only as for erc4337 it is excess

  1. ERC-4337 flow has nonce protection against replays including signature malleability. So there is no need to apply this check

  2. ERC-1271 flow has no in-built protection against replays including signature malleability.
    Even reference implementation includes the 's' check: https://eips.ethereum.org/EIPS/eip-1271#reference-implementation

If one is using OZ's ECDSA, this above check is applied under the hood : https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/ECDSA.sol#L134-L145
However, in our K1Validator we use Solady ECDSA.tryRecover

import { ECDSA } from "solady/utils/ECDSA.sol";

https://github.com/Vectorized/solady/blob/45bba1221ad451289d2f54c2f7f48aea624e17aa/src/utils/ECDSA.sol#L218-L259
which, as far I can see, doesn't have such a check

Of course disallowing using n - s is not considered to be the full replay protection. However, we can not know if any additional protection is incorporated into the signed hash in 1271, at the same time we can not enforce stronger replay protection such as nonce, so we can at least protect from signature malleability and expect protocols which use 1271 to have their own replay protection (and if they decide to use full bytes signature as protection, they are covered from malleability).

Copy link

openzeppelin-code bot commented Nov 1, 2024

Sig malleability protection for erc1271 only

Generated at commit: bbe68ea106c4729019703e05aa7fc99fb7a546e8

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
1
0
6
27
35

For more details view the full report in OpenZeppelin Code Inspector

Copy link

codecov bot commented Nov 1, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 84.68%. Comparing base (0351f93) to head (bbe68ea).
Report is 6 commits behind head on dev.

Files with missing lines Patch % Lines
contracts/modules/validators/K1Validator.sol 25.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev     #215      +/-   ##
==========================================
- Coverage   85.00%   84.68%   -0.32%     
==========================================
  Files          13       13              
  Lines         847      849       +2     
  Branches      249      271      +22     
==========================================
- Hits          720      719       -1     
- Misses        112      115       +3     
  Partials       15       15              
Files with missing lines Coverage Δ
contracts/modules/validators/K1Validator.sol 68.67% <25.00%> (-2.94%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 69f437b...bbe68ea. Read the comment docs.

Copy link
Contributor

@livingrockrises livingrockrises left a comment

Choose a reason for hiding this comment

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

got it. lgtm

@livingrockrises
Copy link
Contributor

codecov/patch check is failing.

Copy link

github-actions bot commented Nov 1, 2024

Changes to gas cost

Generated at commit: 8058ccb31a6870a8c60f2aca104c56b0fbf84c8f, compared to commit: 69f437bb5db46e60c62bb780fcebc4120cab130a

🧾 Summary (5% most significant diffs)

Contract Method Avg (+/-) %

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
MockPaymaster 1,063,705 (+187)
HelperConfig 7,039,537 (+3,204,972)

Filipp Makarov added 2 commits November 1, 2024 18:03
Copy link

github-actions bot commented Nov 1, 2024

🤖 Slither Analysis Report 🔎

Slither report

# Slither report

THIS CHECKLIST IS NOT COMPLETE. Use --show-ignored-findings to show all the results.
Summary
🟡 - locked-ether (1 results) (Medium)

locked-ether

🟡 Impact: Medium
🔴 Confidence: High

utils/NexusBootstrap.sol#L33-L165

constable-states

Impact: Optimization
🔴 Confidence: High

base/RegistryAdapter.sol#L10

factory/RegistryFactory.sol#L39

_This comment was automatically generated by the GitHub Actions workflow._

@filmakarov
Copy link
Collaborator Author

codecov/patch check is failing.

fuck it. It shows 'uncovered' for lines which in fact are.

@livingrockrises livingrockrises merged commit d015436 into dev Nov 2, 2024
9 of 10 checks passed
@livingrockrises livingrockrises deleted the fix/optimize-sig-malleability-protection branch November 2, 2024 05:03
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.

2 participants