Pranjali Thakur
Cleanup README
96a45ce
---
language:
- code
---
# # W3SA - Solana Insecure Programs
<!-- This repository consists of all the common program vulnerabilities in the Solana environment. Each program is meant to shocase a specific issue. These common vulnerabilities are gathered from the [Solana Foundation](https://solana.com/developers/courses/program-security) resources and different auditing firms. -->
This benchmark is dedicated to Solana contracts that are intentionally vulnerable to a list of most common vulnerabilities specific to Solana. The goal is to assess how effectively AI models and static analysis tools can detect these engineered weaknesses in a controlled scenario. This benchmark comprises a curated set of Solana programs, each engineered with one or more of the above-listed vulnerabilities and are inspired by the [sealevel-attacks](https://github.com/coral-xyz/sealevel-attacks/tree/master) that is a list of all the common vulnerabilities that are unique to the Solana Programming Model.
## List of vulnerabilities
1. **Account Data Matching:** Vulnerability due to mismatches or incorrect assumptions about account data formats. Mismatches between the expected and actual data structures of an account can lead to runtime errors to exploited assumptions. Attackers might use malformed sata to bypass logic cheks in the program.
2. **Arbitrary CPI:** Allowing uncontrolled cross-program invocation (CPI) can enable a program to call external contracts with parameters it doesn't fully control. This opens the door for malicious code execution or unintended state changes.
3. **Duplicate Accounts:** Passing the same account as an input could result in unintended data overwriting. This may lead to conflicts where invariants are violated.
4. **Improper Account Closing:** Failing to securely close an account can leave sensitive state data or funds vulnerable after the account is no longer in active use. Improper closure may also allow unauthorized reactivation or access to stale data.
5. **Integer Overflow/ Underflow:** Arithmetic operations that aren’t properly checked can wrap around, resulting in overflow or underflow errors. This can cause miscalculations in token balances or counters, compromising program logic.
6. **Missing Owner Check:** Neglecting to verify that an account's owner is valid before performing operations can let attackers manipulate accounts they do not control. This weakens the security model by bypassing fundamental ownership restrictions.
7. **Missing Signer Check:** Omitting verification that the transaction is signed by the required authority opens the door to unauthorized actions. Without this check, sensitive operations may be executed by any caller.
8. **PDA Sharing:** Sharing Program Derived Addresses (PDAs) between different parts of a program without proper safeguards can expose sensitive state data. This may result in unintended interactions or security vulnerabilities when multiple programs access the same PDA.
## Detection Rate
| Models | Overall Detection Rate |
|-------------|------------------------|
| ALMX-1.5 | 87.5% |
| GPT-o1 | 75.0% |
| GPT-o3-mini | 75.0% |
| GPT-o1-mini | 62.5% |
| Claude-3.5 | 62.5% |
| GPT-4o | 50% |
<img src="./resources/insecure_programs.png" alt="Solana Insecure Programs" style="border: 2px solid black; border-radius: 15px;" width="500">
The ALMX-1.5 model significantly outperforms the base AI models, achieving an overall detection rate of 87.5% compared to 50% and 62.5% for other base models. ALMX consistently identifies all targeted vulnerabilities except for “Duplicate Accounts” vulnerabilities, which have also not been detected by any other model. ALMX-1.5 is able to catch the “Improper Account Closing”, where all other base models had negative detections.
## Repo Structure
```
├── README.md
├── programs
│ ├── vuln-1
│ │ ├── src/lib.rs
│ │ └── Cargo.toml
│ └── vuln-2
│ ├── src/lib.rs
│ └── Cargo.toml
├── bm_src
└── resources
```
## Set up
- Install `uv` package manager if not yet available
- Run `uv sync`
## Run an experiment
- Set your `OPENAI_API_KEY` as environmental variable
- Launch your experiment by running:
```bash
uv run experiment.py --model o3-mini
```
## Contact Us
For or questions, suggestions, or to learn more about Almanax.ai, reach out to us at https://www.almanax.ai/contact