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

#28 - Ensure _execute and _tryExecute Functions Correctly Handle Calls to EOAs #128

Closed
wants to merge 1 commit into from

Conversation

Aboudjem
Copy link
Contributor

@Aboudjem Aboudjem commented Aug 2, 2024

Updated _execute and _tryExecute functions to include an extcodesize check, ensuring calls to EOAs are not incorrectly marked as successful. This change aligns the behavior of low-level calls with Solidity's expectations

@Aboudjem Aboudjem changed the title refactor: Improve error handling in ExecutionHelper contract #28 - Ensure _execute and _tryExecute Functions Correctly Handle Calls to EOAs Aug 2, 2024
Copy link

github-actions bot commented Aug 2, 2024

Changes to gas cost

Generated at commit: c654f5061ba8ac118b20169a31f048db9ef0d8ea, compared to commit: 9c2537deb0d2d8dd3f724186df2ab700193eaa26

🧾 Summary (5% most significant diffs)

Contract Method Avg (+/-) %
Nexus execute
executeFromExecutor
+176 ❌
+982 ❌
+0.36%
+4.96%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Nexus 5,480,373 (+14,715) execute
executeFromExecutor
6,356 (+156)
14,719 (+190)
+2.52%
+1.31%
49,150 (+176)
20,785 (+982)
+0.36%
+4.96%
38,056 (+156)
20,699 (+1,089)
+0.41%
+5.55%
143,098 (+120)
27,025 (+1,560)
+0.08%
+6.13%
76 (0)
4 (0)

@Aboudjem Aboudjem self-assigned this Aug 2, 2024
Copy link

refactor: Improve error handling in ExecutionHelper contract

Generated at commit: 0734b81b3272441e3385c33b8af9663351de94cd

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
0
1
0
6
24
31

For more details view the full report in OpenZeppelin Code Inspector

Copy link

github-actions bot commented Aug 2, 2024

🤖 Slither Analysis Report 🔎

Slither report

# Slither report

THIS CHECKLIST IS NOT COMPLETE. Use --show-ignored-findings to show all the results.
Summary

constable-states

Impact: Optimization
🔴 Confidence: High

base/RegistryAdapter.sol#L12

factory/RegistryFactory.sol#L39

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

Copy link

codecov bot commented Aug 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 13 lines in your changes missing coverage. Please review.

Project coverage is 71.68%. Comparing base (9c2537d) to head (0734b81).
Report is 46 commits behind head on remediations/cantina-spearbit.

Files Patch % Lines
contracts/base/ExecutionHelper.sol 0.00% 13 Missing ⚠️
Additional details and impacted files
@@                        Coverage Diff                        @@
##           remediations/cantina-spearbit     #128      +/-   ##
=================================================================
- Coverage                          72.54%   71.68%   -0.87%     
=================================================================
  Files                                 13       13              
  Lines                                663      671       +8     
  Branches                             151      154       +3     
=================================================================
  Hits                                 481      481              
- Misses                               182      190       +8     
Files Coverage Δ
contracts/base/ExecutionHelper.sol 48.03% <0.00%> (-4.09%) ⬇️

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 9c2537d...0734b81. Read the comment docs.

Base automatically changed from fix/finding-21-emit-events to fix/finding-18-withdraw-deposit-memory August 13, 2024 15:45
mstore(result, 0) // Set result length to 0
mstore(0x40, add(result, 0x20)) // Update free memory pointer
}
if iszero(success) {
Copy link
Contributor

Choose a reason for hiding this comment

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

success would already be 0 if it doesn't go to previous block.

Copy link
Contributor

Choose a reason for hiding this comment

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

then it will still do this for EOA

success := call(gas(), target, value, result, callData.length, codesize(), 0x00)

@livingrockrises
Copy link
Contributor

ensuring calls to EOAs are not incorrectly marked as successful.

I notice in case of eoa you're just doing this

mstore(result, 0) // Set result length to 0
mstore(0x40, add(result, 0x20)) // Update free memory pointer

but the other code following can still be executed.

Can you bring auditers attention to this comment again please?

a. Assume all calls to EOA invalid / unsuccessfull
b. sucessfull if it's just value transfer > 0 and calldata is 0x

Ensure it returns in such cases and does not go to other control paths.

Write appropriate tests for it

@livingrockrises
Copy link
Contributor

@Aboudjem

@livingrockrises
Copy link
Contributor

inclined to close this.

Base automatically changed from fix/finding-18-withdraw-deposit-memory to remediations/cantina-spearbit August 19, 2024 03:33
@livingrockrises livingrockrises deleted the fix/finding-28 branch October 14, 2024 10:42
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