-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from CoinFabrik/53-add-vulnerability-and-detec…
…tor-documentation-for-set-contract-storage 53 add vulnerability and detector documentation for set contract storage Closes #53
- Loading branch information
Showing
3 changed files
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Set contract storage | ||
|
||
### What it does | ||
|
||
Checks for calls to `env.storage()` without a prior call to `env.require_auth()`. | ||
|
||
### Why is this bad? | ||
|
||
Functions using keys as variables without proper access control or input sanitation can allow users to perform changes in arbitrary memory locations. | ||
|
||
### Known problems | ||
|
||
Only check the function call, so false positives could result. | ||
|
||
### Example | ||
|
||
```rust | ||
fn set_contract_storage(env: Env) { | ||
let _storage = env.storage().instance(); | ||
} | ||
``` | ||
|
||
Use instead: | ||
|
||
```rust | ||
fn set_contract_storage(env: Env, user: Address) { | ||
user.require_auth(); | ||
let _storage = env.storage().instance(); | ||
} | ||
``` | ||
|
||
### Implementation | ||
|
||
The detector's implementation can be found at [this link](https://github.com/CoinFabrik/scout-soroban/tree/main/detectors/set-contract-storage). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters