anchor-security

Audit and harden Anchor programs with Solana security patterns.

1|Updated Feb 4, 2026
One-click install
npx skills add https://github.com/faremeter/flex --skill anchor-security
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: anchor-security
Source: https://github.com/faremeter/flex/tree/main/skills/anchor-security
Command: npx skills add https://github.com/faremeter/flex --skill anchor-security

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Security patterns and anti-patterns for building secure Anchor programs. This skill consolidates guidance from the sealevel-attacks repository and Anchor best practices to help developers prevent common vulnerabilities during design, review, and deployment.

Core Features & Use Cases

  • Security patterns from sealevel-attacks repository adapted for Anchor development.
  • Practical fixes and best practices for signer checks, account relationships, owner validation, discriminators, initialization, and CPI validation.
  • Used during code reviews, security training, and production-grade Anchor program development.

Quick Start

Review your Anchor program code and implement signer checks, account relationships, proper initialization, and CPI validations to align with the documented security patterns.

Frequently Asked Questions about anchor-security

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I secure Anchor programs against common Solana vulnerabilities?

Secure Anchor programs by enforcing signer constraints, validating account ownership, checking discriminators, and properly handling PDAs to prevent common Solana smart contract vulnerabilities during design, code review, and deployment.

What security checks should I perform during an Anchor code review?

During an Anchor code review, verify signer constraints, account relationships, owner validation, discriminators, initialization patterns, and CPI validation. Reviewing these areas ensures alignment with documented security patterns and prevents privilege escalation or account substitution attacks.

How do PDA handling and initialization patterns affect Solana smart contract security?

PDA handling and initialization patterns affect security by ensuring deterministic account derivation and preventing account reuse. Proper initialization with canonical seeds and bump seeds prevents attackers from hijacking uninitialized accounts or colliding PDA addresses in Anchor programs.

How do I validate CPI calls in Anchor to prevent unauthorized cross-program invocations?

Validate CPI calls in Anchor by checking the calling program's ID, verifying signer privileges for invoked PDAs, and enforcing strict account constraints. Proper CPI validation prevents unauthorized cross-program invocations and protects against malicious program interactions.

Does this Anchor security guidance apply to production-grade Solana deployments?

Yes, this Anchor security guidance applies to production-grade Solana deployments. It consolidates patterns from the sealevel-attacks repository adapted for Anchor development, making it suitable for production hardening, security training, and professional smart contract assessments.

What are the limitations of using Anchor constraints for Solana account validation?

Anchor constraints provide strong account validation but require careful configuration of init patterns, owner checks, and discriminator verification. Limitations arise when custom validation logic bypasses framework constraints, requiring manual security reviews to catch edge cases not covered by default macros.