crytic / crytic/slither

[Bug-Candidate]: Slither fails to correctly parse Vyper function parameters in IR

Open
#2,796 0 comments 0 reactions 0 assignees View on GitHub
bug-candidate
Dominant language
Python
Stars
6.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

### Describe the issue:

Slither's parsing of Vyper produces incomplete SlithIR, with function parameters missing (shown in **250907114030.f()**). Additionally, it does not support the latest Vyper version (0.4.3); currently, only version 0.3.7 is effectively supported.

### Code example to reproduce the issue:

##### vyper: 0.3.7
```vyper
@external
@view
def f(_x: Bytes[1024]) -> Bytes[1]:
return slice(_x, 0, 1)

@external
@view
def g(_x: Bytes[1024]) -> Bytes[1]:
return slice(_x, 0, 1)
```
In the SlithIR obtained below, the parameters of the f function are not parsed.
```
slither attached_public_library_function_accepting_calldata-250907114030.vy --print slithir --compile-force-framework vyper
```
```slithir
INFO:Printers:Contract attached_public_library_function_accepting_calldata-250907114030
Function attached_public_library_function_accepting_calldata-250907114030.f() (*)
Expression: slice()(_x,0,1)
IRs:
TMP_0(None) = SOLIDITY_CALL slice()(_x,0,1)
RETURN TMP_0
Function attached_public_library_function_accepting_calldata-250907114030.g() (*)
Expression: slice()(_x,0,1)
IRs:
TMP_1(None) = SOLIDITY_CALL slice()(_x,0,1)
RETURN TMP_1
```

##### vyper: 0.4.3
```
Vyper != 0.3.7 support is a best effort and might fail
Traceback (most recent call last):
File "/root/anaconda3/bin/slither", line 8, in
sys.exit(main())
^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/slither/__main__.py", line 776, in main
main_impl(all_detector_classes=detectors, all_printer_classes=printers)
File "/root/anaconda3/lib/python3.12/site-packages/slither/__main__.py", line 882, in main_impl
) = process_all(filename, args, detector_classes, printer_classes)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/slither/__main__.py", line 96, in process_all
compilations = compile_all(target, **vars(args))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 722, in compile_all
compilations.append(CryticCompile(target, **kwargs))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 211, in __init__
self._compile(**kwargs)
File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/crytic_compile.py", line 633, in _compile
self._platform.compile(self, **kwargs)
File "/root/anaconda3/lib/python3.12/site-packages/crytic_compile/platform/vyper.py", line 101, in compile
]["sourceMap"].split(";")
^^^^^
AttributeError: 'dict' object has no attribute 'split'
```

#### solc: 0.8.30
```solidity
library D {
function f(bytes calldata _x) public pure returns (bytes1) {
return _x[0];
}
function g(bytes memory _x) public pure returns (bytes1) {
return _x[0];
}
}
```
The SlithIR parsed from Solidity below is more complete and includes the function parameters.
```
slither attached_public_library_function_accepting_calldata.sol.sol --print slithir
```
```
INFO:Printers:Contract D
Function D.f(bytes) (*)
Expression: _x[0]
IRs:
REF_0(None) -> _x[0]
RETURN REF_0
Function D.g(bytes) (*)
Expression: _x[0]
IRs:
REF_1(None) -> _x[0]
RETURN REF_1
```

### Version:

slither version: 0.11.3

### Relevant log output:

```shell

```

Contributor guide

Open the contributing guide

Research direction

Reproduce the two examples with Vyper 0.3.7 and 0.4.3 using the shown Slither commands. Start in crytic_compile/platform/vyper.py at the sourceMap handling from the traceback, then trace how Vyper function parameters reach SlithIR. Done means parameters appear for the 0.3.7 example and the 0.4.3 example no longer fails with the sourceMap AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
compilers, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.