Skip to content

feat: compiler warning for using shielded values in branching conditions + prevent shielded types as inputs for abi.encode#96

Open
matthias-wright wants to merge 5 commits intoveridise-auditfrom
m/shielded-branching-into-veradise-audit
Open

feat: compiler warning for using shielded values in branching conditions + prevent shielded types as inputs for abi.encode#96
matthias-wright wants to merge 5 commits intoveridise-auditfrom
m/shielded-branching-into-veradise-audit

Conversation

@matthias-wright
Copy link
Collaborator

This makes two changes to prevent leakage of private information.

  1. This adds a compiler warning (code 9663) for using shielded values in branching conditions for the following statements: if conditions, while loops, for loops, and ternary operators
  2. Prevents the usage of shielded types as inputs for abi.encode, abi.encodePacked, abi.encodeWithSelector, abi.encodeWithSignature, abi.encodeCall

The motivation for 1 are examples like the following. In this if condition

  if (shieldedBalance > suint(1000)) {
      // code path that costs 20k gas
  } else {
      // code path that costs 2k gas
  }

the gas usage can give information about the shielded value shieldedBalance.

Tests were added to verify this behavior.

The full warning looks like this:

Warning 9663: (106-115): Using shielded types in branching conditions can leak information through observable execution patterns such as gas costs, state changes, and execution traces.

The motivation for 2 is the fact that abi.encode etc all return bytes. Since bytes is not shielded, it would leak information about the shielded input.

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.

1 participant