Trident is a Rust-based framework designed to help developers fuzz test Solana programs written in Anchor. Developed by Ackee Blockchain and supported by the Solana Foundation, Trident simplifies the testing process and helps developers ship secure code by uncovering edge-case vulnerabilities.

Trident Fuzzing Video Tutorial

For School of Solana we prepared a bonus lecture for developers to learn how to fuzz test Solana programs with Trident.

Trident is powerful

Trident’s development began over 2.5 years ago in 2021, originally under the name Trdelník. Trident has won the Marinade Finance community prize during the Solana Riptide Hackathon in 2022 and has received a development grant from the Solana Foundation in 2023.

Features

  1. Automated Fuzz Test Generation: Simplifies the creation of test templates for Anchor programs, reducing setup time and effort.
  2. Adaptive Inputs: Generates dynamic and adaptive inputs to improve test coverage and uncover hidden vulnerabilities.
  3. Guided Instruction Sequences: Uses customizable sequences of instructions for faster, more effective testing results.
  4. Invariant Checks: Allows developers to implement custom checks to spot vulnerabilities and unwanted behavior.

Getting Started

Installation

Trident is distributed via Rust’s cargo package manager. To install Trident and its dependencies, follow these steps:

  1. Install Trident CLI and honggfuzz:

  2. Initialize Trident in Your Project:

    This command sets up Trident in your project, generating necessary files and configurations.

Fuzz Testing Solana Programs

Fuzz testing is an automated technique that provides generated random, invalid, or unexpected input data to your program. This helps discover unknown bugs and vulnerabilities, potentially preventing zero-day exploits. Trident integrates the well-known fuzzer honggfuzz, developed by Google, to facilitate fuzz testing for Solana programs.

Example: Setting Up a New Anchor Project

    1. Initialize the Project:
    2. Create a Buggy Program:
      Create a program named unchecked_arithmetic_0 with intentional bugs for testing.
    3. Initialize Trident:
    4. Write a Fuzz Test:
      Modify the fuzz test template located at ‘trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs’ and finish the implementation of get_data and get_accounts methods and FuzzAccounts struct:

      Modify the fuzz test template located at ‘trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs’:
    5. Run the Fuzz Test:
    6. Debugging with Crash Files:Use crash files to debug and inspect issues:

Integration Testing

Trident also supports integration testing, allowing developers to test their Solana programs in a simulated environment that closely mirrors the actual Solana blockchain. This ensures that programs interact correctly with the blockchain and other programs.

 

Developer Support

Read the documentation, star our GitHub repo and follow Trident on Twitter/X @TridentSolana for updates. For developer support find us in our Discord #trident-chat and on warpcast /trident channel.