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

Prefer abi.encode over abi.encodePacked #4

Open
code423n4 opened this issue Sep 23, 2021 · 2 comments
Open

Prefer abi.encode over abi.encodePacked #4

code423n4 opened this issue Sep 23, 2021 · 2 comments

Comments

@code423n4
Copy link
Contributor

Handle

t11s

Vulnerability details

Impact

Use of abi.encodePacked in PositionKey is safe, but unnecessary and not recommended. abi.encodePacked can result in hash collisions when used with two dynamic arguments (string/bytes). PositionKey does not use any dynamic types, but for maximum safety against future mistakes, using abi.encode is recommended.

There is also discussion of removing abi.encodePacked from future versions of Solidity (ethereum/solidity#11593), so using abi.encode now will ensure compatibility in the future.

Proof of Concept

https://github.com/code-423n4/2021-09-wildcredit/blob/edfc97a8b75bb290a7f7f61cda62d586ed42c73e/contracts/external/PositionKey.sol#L11

Recommended Mitigation Steps

Use abi.encode instead.

@code423n4 code423n4 added bug Something isn't working 0 (Non-critical) labels Sep 23, 2021
code423n4 added a commit that referenced this issue Sep 23, 2021
@talegift
Copy link
Collaborator

This was taken from the Uniswap repo so don't want to modify this.

@ghoul-sol
Copy link
Collaborator

ghoul-sol commented Oct 12, 2021

on second look, I'll keep this as best practice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants