-
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.
Add documentation to bump_seed_canonicalization, insecure_account_clo…
…se, type_cosplay
- Loading branch information
Vara Prasad Bandaru
committed
Feb 2, 2024
1 parent
926e7ef
commit e82b2e6
Showing
6 changed files
with
240 additions
and
10 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
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 |
---|---|---|
@@ -1,5 +1,34 @@ | ||
# insecure_account_close | ||
|
||
**What it does:** Checks for attempts to close an account by setting its lamports to 0 but | ||
not also clearing its data. See: | ||
https://docs.solana.com/developing/programming-model/transactions#multiple-instructions-in-a-single-transaction | ||
**What it does:** | ||
|
||
Checks for attempts to close an account by setting its lamports to 0 but | ||
not also clearing its data. | ||
|
||
**Why is this bad?** | ||
|
||
See: https://docs.solana.com/developing/programming-model/transactions#multiple-instructions-in-a-single-transaction | ||
|
||
> An example of where this could be a problem is if a token program, upon transferring the token out of an account, sets the account's lamports to zero, assuming it will be deleted by the runtime. If the program does not zero out the account's data, a malicious user could trail this instruction with another that transfers the tokens a second time. | ||
**Known problems:** | ||
|
||
None | ||
|
||
**Example:** | ||
|
||
See https://github.com/coral-xyz/sealevel-attacks/tree/master/programs/9-closing-accounts for examples of insecure, secure and recommended | ||
approach to close an account. | ||
|
||
**How the lint is implemented:** | ||
|
||
- For every expression like `(*(*some_expr).lamports.borrow_mut()) = 0;`; assigning `0` to account's lamports | ||
- If the body enclosing the expression `is_force_defund`, ignore the expression | ||
- The body contains expressions `some_expr.copy_from_slice(&another_expr[0..8])` and comparison expression | ||
comparing an `[u8; 8]` value. | ||
- Else If the body contains a manual clear of the account data | ||
- If the body has a for loop like pattern and the loop body has an expression assigning zero | ||
- Assume the loop is clearing the account data and the expression is safe | ||
- Else | ||
- report the expression as vulnerable | ||
|
Oops, something went wrong.