crytic / crytic/slither

create reference variable for offset and length in Yul

Open
#1,469 1 comment 0 reactions 0 assignees View on GitHub
enhancement ir yul
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

`write-after-write` detector falsely reacts on assembly work with calldata:

### Code example to reproduce the issue:

```
function foo(bytes calldata cd) private pure returns (bytes calldata signature)
{
assembly {
let ptr := add(cd.offset, calldataload(cd.offset))
signature.offset := add(ptr, 0x20)
signature.length := calldataload(ptr)
}
}
```

### Version:

^0.9 - tool was run on other machine

### Relevant log output:

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the false positive with the provided foo(bytes calldata cd) Yul example and the available Slither version. Inspect the write-after-write detector's handling of calldata offset and length assignments; done means this example no longer reports a false positive and regression coverage verifies that behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, solidity
Domain
security, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.