Earn 5.76% APY staking with Solana Compass + help grow Solana's ecosystem

Stake natively or with our LST compassSOL to earn a market leading APY

Conference Talk Breakpoint 23

Breakpoint 2023: The Good, The Bad, and The Vulnerable

Solana 🧭 Compass By Solana 🧭 Compass Nov 09, 2023 5 min read

An insightful presentation on secure programming practices for developing Solana blockchain programs

The notes below are AI generated and may not be 100% accurate. Watch the video to be sure!
Note: these notes were generated by AI to help surface more Solana content

Summary

"Breakpoint 2023: The Good, The Bad, and The Vulnerable" is an informative video presented by Will, a software engineer from ORCA, focusing on the common pitfalls and best practices in Solana program development. With the growing complexity of blockchain applications, secure and robust development is essential to prevent exploitable vulnerabilities. The talk provides a deep dive into the "10 commandments" for security in Solana smart contract development, touching upon the importance of verification, program account ownership, correct interaction with secondary programs, and handling integer math operations. The speech not only covers technical details but also discusses the tools and practices that can help developers ensure the security of their Solana programs.

Key Points:

Signer Verification

Will stresses the significance of verifying the signer of a transaction in Solana applications. While there may be instances where a programmer might consider skipping this step, Will counters that the benefits of including it outweigh the minimal compute budget costs. This ensures that even in permissionless instructions or when delegating checks to other programs, the origin of a transaction is always validated, improving security.

Program Account Ownership and Interaction

A critical practice in Solana development is verifying the ownership of program accounts when accessing their data. Since only the owning program can write to an account, this verification ensures the reliability of the data. Similarly, when interacting with secondary programs, it is important to verify that the correct program is being addressed. Will points out that this prevents adversaries from manipulating the program's interactions.

Math Operations and Rounding Policies

Math operations in blockchain programs frequently involve integers, and special care must be taken to prevent overflows and underflows. Using checked arithmetic and correctly ordering operations to maintain precision are vital. Will also advises a consistent rounding policy to avoid discrepancies that could be exploited, particularly on a blockchain like Solana where affordable transaction fees could make even small vulnerabilities profitable for attackers.

Closing Program Accounts and Handling Errors

Closing program accounts can lead to vulnerabilities if not handled properly. Developers are advised to mark accounts closed in a recapitable manner. Additionally, errors should be meticulously handled; otherwise, a failed operation might silently allow a transaction to proceed, potentiating undesired effects.

PDA Seeds and Tools

The importance of unique and non-colliding Program Derived Addresses (PDAs) seeds is discussed, suggesting the use of prefixes to prevent address clashes. Will also recommends tools like Anchor for account validation and Solana Bankran for simulating various testing scenarios, which can assist developers in creating secure Solana applications.

Facts + Figures

  • Always verify the signer of a transaction in Solana programs, even in permissionless situations.
  • Verify the ownership of a program account to ensure the integrity and trustworthiness of the data.
  • Ensure interaction with the correct secondary program to avoid adversarial insertion of incorrect ones.
  • Utilize identifiers for Solana program accounts to separate different types of data accounts.
  • Use checked arithmetic to avoid integer overflow and underflow in smart contracts.
  • Preserve precision in integer math by performing magnifying operations before reducing ones.
  • Adopt a consistent rounding policy to prevent rounding discrepancies in token transfers.
  • Properly write boolean or identifiers before closing a program account to mark it as such even if reopened.
  • Always handle errors to prevent unintended continuation of execution despite failures.
  • Prefix PDA seeds to prevent collisions between different data accounts.

Top quotes

  • "Always make sure that you verify the signer of a transaction."
  • "Every time you read from a program account, make sure to check their owner."
  • "Always use identifiers for your program accounts."
  • "Check math pretty much always is the rule."
  • "Use a consistent rounding policy."
  • "Only the program that owns the account can actually write data."
  • "Always prefix your PDA seeds."
  • "Anchor forces you to be very explicit about the accounts and the validation."

Questions Answered

What is a common security practice when developing Solana programs?

Always ensure verification of the signer for transactions to authenticate the proper source, regardless of the transaction type.

Why is it important to verify program account ownership?

Verifying account ownership is crucial because it confirms that the data within a program account is trustworthy and has not been tampered with.

How can Solana developers avoid issues with integer math operations?

Developers should use checked arithmetic to prevent overflow and underflow and should structure their operations to perform magnifying actions before reducing ones to maintain numerical precision.

What should be done before closing a program account in Solana?

Before closing, write a boolean or an identifier to signal that the account is intended to be closed, to ensure that even if the account is reopened, it is still recognizable as previously closed.

What tool can help Solana developers with secure and explicit account validation?

Anchor is a tool that assists developers by enforcing clear validation and account handling practices, which can prevent many common programming errors in Solana's development environment.


Comments

Please login to leave a comment.

Related Content

Solana Program Security Audits and Bounties with David from MadShield - Solfate Podcast #27

Learn about Solana program security from MadShield's David, covering audit processes, common vulnerabilities, and the future of blockchain adoption.

What's Behind the Move Movement? w/ Rushi Manche (Movement Labs)

Discover how the Move programming language is transforming blockchain development with built-in security features and improved developer experience. Learn about Movement Labs' efforts to bring Move to multiple blockchains, including Solana and Ethere

Breakpoint 2023: Back to The Future: What Bugs You Can Expect in Your Project

Director of Security at Halborne, Piotr Cielas, discusses recurring bugs in projects and proposes a blockchain-specific vulnerability scoring system.

Sui's Move: A New Blockchain Programming Paradigm | Sam Blackshear, Evan Cheng

Explore Sui's innovative Move programming language, scalability solutions, and developer-friendly features in this in-depth discussion with founders Sam Blackshear and Evan Cheng.

Breakpoint 2024: Technical Talk: Fuzzing Comes to Solana (Viktor Fischer)

Learn about Trident, the new open-source fuzzing tool for Solana, and how it's revolutionizing smart contract security

Radix: Why Sharding is Crypto's Next 0 to 1 Unlock | Piers Ridyard, RDX Works

Explore how Radix is tackling blockchain scalability, security, and developer experience through innovative sharding and a novel programming language.

Solana Changelog July 11 - Merkle Shreds, Turbine, and a Security Series

Discover the latest Solana updates including QUIC Turbine implementation, Merkle Shreds rollout, and a new security series for developers. Learn how these changes improve network efficiency and program security.

Solana vs Ethereum: A Compare and Contrast - Solfate Podcast #25

Dive into the technical differences, developer experiences, and ecosystem dynamics of Solana and Ethereum with insights from blockchain experts on the Solfate Podcast.

Breakpoint 2023: Fuzzing, Formal Methods, and the State of Solana Security

An exploration of how fuzzing and formal verification techniques contribute to the security of the Solana blockchain.

Solana Changelog - December 5 - Geyser, GroupMember Extension, and Core BPF Programs

Explore the latest Solana updates including Geyser plugin logging, new token extensions, and improvements to core BPF programs. Learn about the impact on developers and the ecosystem.

Breakpoint 2025: Security Block: Asymmetric Research

Discover the biggest security risks facing Solana in 2025, from oracle compromises to CU optimization dangers, and learn how developers can protect their protocols.

Solana Changelog - January 17, 2023 - SIMD 3, Compute Cost Updates, Golana

Explore Solana's latest developments including SIMD 3 proposal for dynamic base fees, compute cost updates, and the introduction of Golana for Go developers.

Breakpoint 2025: Welcome to Day 1 - Solana Foundation Opens Exclusive Allocator Summit

Breakpoint 2025 Day 1 brings top asset allocators together for an exclusive deep dive into Solana ecosystem investment opportunities with Raoul Pal, Bitwise, and Multicoin Capital.

Not Your Keys, Not Your Crypto: The Importance of Self-Custody

Explore the critical importance of self-custody in crypto with Ledger CTO Charles Guillimet. Learn about hardware wallets, blockchain security, and the future of digital asset management.

Write Solidity on Solana with Solang (feat. Sean Young, Solana Labs) - Solfate Podcast #31

Discover how Solang enables Solidity development on Solana, offering EVM developers a bridge to high-performance blockchain infrastructure.

Solana tokens

Solana Token Markets

Explore all tokens →