Skip to content

docs for safeCasting and uncheckedOverflow builtin rules#447

Merged
yoav-rodeh merged 6 commits intomasterfrom
yoav/safecasting-builtin
Feb 5, 2026
Merged

docs for safeCasting and uncheckedOverflow builtin rules#447
yoav-rodeh merged 6 commits intomasterfrom
yoav/safecasting-builtin

Conversation

@yoav-rodeh
Copy link
Copy Markdown
Contributor

@yoav-rodeh yoav-rodeh commented Nov 19, 2025

as the title says

@yoav-rodeh yoav-rodeh requested a review from jar-ben November 19, 2025 14:32
@yoav-rodeh yoav-rodeh changed the title docs for safeCasting builtin rule docs for safeCasting and uncheckedOverflow builtin rules Feb 4, 2026

The `safeCasting` built-in rule is there to catch cases where an explicit cast in solidity is actually out of bounds.
For example, if an `uint` is cast to a `uint64`, the rule will fail if there is some external function in the contract, that can be called
in such a way, that the value being cast is larger than `2^64 - 1`. Casting between signed and unsigned values are also checked. So if an `uint` is cast to an `int`, and the cast value is larger than `2^255 - 1`. the rule will fail.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

. the rule will fail. has . at the beginning - should be ,.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed

```cvl
use builtin rule safeCasting;
```
in a spec file. In addition, the line `safe_casting_builtin : true` must be added to the conf file.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does safe_casting_builtin : true work? I thought it has to be "safe_casting_builtin" : true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

both work, but I think they somehow prefer the brackets, i'll add it.

```
This will fail the builtin rule, because the multiplication is a `uint128` multiplication (even if it's later considered as a `uint`).

This rule can be enabled by including
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I suppose you also have to set unchecked_overflow_builtin in the .conf file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh yah, i forgot. Added.

@yoav-rodeh yoav-rodeh requested a review from jar-ben February 5, 2026 12:36
@yoav-rodeh yoav-rodeh merged commit 26598f4 into master Feb 5, 2026
2 checks passed
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