Skip to content

Commit f1460be

Browse files
feat: external security reviews & patrick addition (#160)
* feat: external security reviews & patrick addition * fix: lint * fix: moved smart contract audits to their own section
1 parent eef59b5 commit f1460be

11 files changed

Lines changed: 463 additions & 230 deletions

File tree

src/SUMMARY.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,11 @@
4949
- [Private Key & Seed Phrase Management](./wallet-security/private-key-management.md)
5050
- [Tools & Resources](./wallet-security/tools-&-resources.md)
5151
- [External Security Reviews](./external-security-reviews/README.md)
52-
- [Expectation](./external-security-reviews/expectation.md)
53-
- [Preparation](./external-security-reviews/preparation.md)
52+
- [Smart Contract Audits](./external-security-reviews/smart-contracts/README.md)
53+
- [Expectations](./external-security-reviews/smart-contracts/expectation.md)
54+
- [Preparation Guide](./external-security-reviews/smart-contracts/preparation.md)
55+
- [Vendor Selection](./external-security-reviews/smart-contracts/vendor-selection.md)
5456
- [Security Policies and Procedures](./external-security-reviews/security-policies-procedures.md)
55-
- [Vendor Selection](./external-security-reviews/vendor-selection.md)
5657
- [Vulnerability Disclosure](./vulnerability-disclosure/README.md)
5758
- [Security Contact](./vulnerability-disclosure/security-contact.md)
5859
- [Bug Bounties](./vulnerability-disclosure/bug-bounties.md)

src/external-security-reviews/README.md

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,42 @@ tags:
33
- Security Specialist
44
- Operations & Strategy
55
- Devops
6+
contributors:
7+
- role: wrote
8+
users: [patrickalphac]
69
---
710

811
# External Security Reviews
912

13+
An external security review is a time-boxed, security-based assessment of software systems, applications, and infrastructure to enhance security and identify vulnerabilities. External security reviews are essential for organizations to protect against threats and build trust with users and stakeholders.
1014

11-
External security reviews are quite common in web3 when it comes to smart contract audits which are often being done to check if the smart contracts are secure.
15+
## Why Are External Security Reviews Important?
1216

13-
It's important to note though that smart contracts are not the only components that should be considered during security reviews. Any relevant off-chain software (Bridges, Oracles, Sequencers, etc.) should also be reviewed in conjunction with any on-chain application.
17+
According to research, significant value and data have been compromised due to security vulnerabilities in software systems. Modern applications face complex threats from malicious actors, and security issues can lead to data breaches, financial losses, and reputation damage.
1418

15-
While external security reviews are good, they are certainly not foolproof and cannot guarantee absolute security, and for that reason this type of security testing is not a one-time event but an ongoing commitment to the safety and security of your web3 project.
19+
Beyond preventing security incidents, external security reviews provide several key benefits:
20+
21+
- **Enhanced Security**: Find and fix vulnerabilities before they can be exploited
22+
- **Team Education**: Level up your engineering team's knowledge through security best practices
23+
- **Trust Building**: Demonstrate maturity and safety to users and stakeholders
24+
- **Risk Mitigation**: Identify business logic issues and implementation flaws
25+
- **Compliance**: Meet regulatory and industry security requirements
26+
27+
## Scope of External Security Reviews
28+
29+
Security reviews can encompass multiple layers of an organization's technology stack:
30+
31+
- **Applications**: Web applications, mobile apps, APIs, and microservices
32+
- **Infrastructure**: Cloud configurations, network security, access controls, and deployment pipelines
33+
- **Data Systems**: Databases, data processing pipelines, and storage security
34+
- **Third-party Integrations**: External APIs, libraries, and vendor services
35+
- **Documentation**: Technical specifications, security policies, and incident response procedures
36+
37+
External security reviews are not foolproof and cannot guarantee absolute security. They represent an ongoing commitment to safety rather than a one-time event.
1638

1739
## Contents
1840

19-
1. [Expectation](./expectation.md)
20-
2. [Preparation](./preparation.md)
21-
3. [Vendor Selection](./vendor-selection.md)
22-
4. [Security Policies and Procedures](./security-policies-and-procedures.md)
41+
There are many different kinds of external security reviews, and we have some context on many of them here.
42+
43+
1. [Smart Contract Audits](./smart-contracts/README.md)
44+
5. [Security Policies and Procedures](./security-policies-and-procedures.md)

src/external-security-reviews/expectation.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/external-security-reviews/preparation.md

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/external-security-reviews/security-policies-procedures.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ tags:
44
- Legal & Compliance
55
- Operations & Strategy
66
- HR
7+
contributors:
8+
- role: wrote
9+
users: [patrickalphac]
710
---
811

912
# Security Policies and Procedures
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
tags:
3+
- Security Specialist
4+
- Operations & Strategy
5+
- Devops
6+
contributors:
7+
- role: wrote
8+
users: [patrickalphac]
9+
---
10+
11+
# Smart Contract Security Reviews
12+
13+
Smart contract security reviews are specialized assessments focused on identifying vulnerabilities in blockchain-based smart contracts and protocols. These reviews are critical for web3 projects due to the immutable nature of blockchain deployments and the high-value targets that smart contracts often represent.
14+
15+
## Why Smart Contract Security Reviews Are Critical
16+
17+
Smart contracts operate in a unique environment that makes security paramount:
18+
19+
- **Immutability**: Once deployed, smart contracts cannot be easily changed
20+
- **Financial Risk**: Smart contracts often handle significant value in cryptocurrencies
21+
- **Public Accessibility**: All code and transactions are visible on the blockchain
22+
- **Adversarial Environment**: Attackers are incentivized by potential financial gains
23+
- **Complex Interactions**: DeFi protocols involve intricate interactions between multiple contracts
24+
25+
According to industry data, billions of dollars have been lost due to smart contract vulnerabilities, making security reviews essential for protecting user funds and maintaining protocol integrity.
26+
27+
## Smart Contract Security Review Process
28+
29+
A security review engagement is typically divided into four phases:
30+
31+
- **Scoping Phase**: The project team prepares the codebase and defines specific scope for security researchers
32+
- **Initial Assessment Phase**: Researchers conduct preliminary analysis to identify potential security issues
33+
- **Mitigation Phase**: The team works on fixing identified issues with ongoing auditor support
34+
- **Final Report Phase**: Auditors review implemented fixes and provide a comprehensive final report
35+
36+
### Audit Methodologies
37+
- **Static Analysis**: Automated code scanning for known vulnerability patterns
38+
- **Dynamic Analysis**: Runtime testing and fuzzing
39+
- **Manual Review**: Expert analysis of business logic and complex vulnerabilities
40+
- **Formal Verification**: Mathematical proofs of contract correctness (where applicable)
41+
42+
## Types of Smart Contract Audits
43+
44+
### Private Audits
45+
- Dedicated security researchers assigned to your project
46+
- Confidential and personalized attention
47+
- Higher cost but comprehensive coverage
48+
- Direct communication with audit team
49+
50+
### Public/Competitive Audits
51+
- Multiple researchers competing for prizes
52+
- Diverse perspectives and approaches
53+
- More cost-effective option
54+
- Broader coverage through competition
55+
56+
## Contents
57+
58+
This section contains detailed guidance on different aspects of smart contract security reviews:
59+
60+
1. [Audit Expectations](./expectation.md) - What to expect during the audit process
61+
2. [Preparation Guide](./preparation.md) - How to prepare for a successful audit
62+
3. [Vendor Selection](./vendor-selection.md) - Choosing the right security auditor
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
tags:
3+
- Security Specialist
4+
- Operations & Strategy
5+
contributors:
6+
- role: wrote
7+
users: [patrickalphac]
8+
---
9+
10+
# Expectations
11+
12+
13+
## Scoping Phase
14+
The team looking for a security review will agree with the auditors/security researchers the exact parameters of the review. What *exact* contracts should they review? What should they not review? This is incredibly important so the can clearly estimate timelines on how long a review may take. This is also where compensation is discussed, usually the more aspects a team wants to review, the more expensive the audit will be.
15+
16+
## Initial Assessment Phase
17+
- **Automated Testing**: Auditors will run various automated security tools including static analysis, fuzz testing, formal verification, and unit testing to identify basic vulnerabilities
18+
- **Manual Code Review**: Security researchers will manually analyze the code to understand context, complexity, and identify deeper vulnerabilities that automated tools might miss
19+
- **Documentation Review**: Auditors will review project specifications and documentation to understand intended functionality
20+
21+
## Deliverables
22+
23+
A comprehensive security review will generate the following:
24+
25+
### Initial Report
26+
- **Vulnerability Identification**: Security vulnerabilities classified by severity (High, Medium, Low)
27+
- **Proof of Concept**: Demonstration of potential exploit scenarios where applicable
28+
- **Gas Optimizations**: Recommendations for improving contract efficiency
29+
- **Informational Findings**: Code quality improvements and best practice recommendations
30+
- **Mitigation Strategies**: Specific recommendations for addressing each identified issue
31+
32+
### Mitigation Phase
33+
- **Fix Review Period**: Time allocated for your team to address identified vulnerabilities
34+
- **Collaborative Support**: Ongoing communication with auditors during the fix implementation
35+
- **Code Re-review**: Assessment of implemented fixes to ensure issues are properly resolved
36+
37+
### Final Report
38+
- **Updated Assessment**: Review of all implemented fixes and their effectiveness
39+
- **Residual Risk Analysis**: Documentation of any remaining risks or limitations
40+
- **Public Publication**: In web3, audit reports are commonly published publicly to build community trust
41+
42+
## Timeline and Cost Expectations
43+
44+
The following are *incredibly rough estimates* for timelines/costs based on Solidity smart contract audits from around the industry. Actual timelines and costs will vary significantly based on the complexity of the codebase, the number of contracts, and the specific requirements of the project.
45+
46+
### Duration
47+
- **Small Projects** (< 1000 lines): 1-2 weeks
48+
- **Medium Projects** (1000-4000 lines): 2-5 weeks
49+
- **Large Projects** (> 4000 lines): 5+ weeks
50+
51+
### Cost Range
52+
- **Per Week**: $1,000 - $60,000 depending on complexity and auditor expertise
53+
- **Factors Affecting Cost**: Codebase size, complexity, timeline requirements, auditor reputation
54+
55+
## Important Limitations
56+
57+
- **No Guarantee**: Audits do not guarantee bug-free code or complete security. However, the engagement with the team should still provide value (teaching better security practices, improving code quality, etc.)
58+
- **Snapshot in Time**: Audits assess code at a specific commit hash - any changes create unaudited code
59+
- **Ongoing Process**: Security should be viewed as a continuous journey, not a one-time event
60+
- **Emergency Preparedness**: Even audited protocols should have incident response plans and emergency communication channels
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
---
2+
tags:
3+
- Security Specialist
4+
- Operations & Strategy
5+
- Devops
6+
contributors:
7+
- role: wrote
8+
users: [patrickalphac]
9+
---
10+
11+
# Preparation
12+
13+
A common misconception is that when doing a security review, you can just hand off the written code and let reviewers do their work. This approach is inefficient and costly, as auditors will spend time on issues you could have resolved beforehand. Proper preparation maximizes the value of your security review investment and helps auditors focus on complex vulnerabilities rather than basic issues.
14+
15+
## How to Get the Most Out of Your Security Review
16+
17+
## Set a Goal for the Review
18+
This is the most important step of a security review and often the most overlooked. By setting a scope that is not too large or undefined, you are more likely to have a successful audit. If the project is very large, you may want to focus on the most critical aspects of the project.
19+
20+
## Internal Due Diligence
21+
Conduct internal testing before engaging an external security provider. You can do this by creating and running test vectors for your code, and leverage automated tools to identify low-hanging fruit. Here’s a list of free/open-source tools your project could use:
22+
23+
- **Solidity**: slither, mythril, semgrep-smart-contracts
24+
- **Golang**: golangci-lint, go-critic, gosec
25+
- **Rust**: cargo audit, cargo outdated, clippy, cargo geiger, cargo tarpaulin
26+
27+
## Write Clear Documentation
28+
Providing comprehensive documentation is essential for auditors to understand your protocol's intended functionality. Since 80% of all bugs are due to business logic issues, auditors need to understand what your protocol should do, not just what the code does.
29+
30+
Documentation should include:
31+
32+
- **Project Overview**: Describe your protocol in plain English—what it does and its components.
33+
- **Flow Diagrams**: Outline all possible interaction paths within your system.
34+
- **Design Choices**: Document design decisions and any known potential issues.
35+
- **Known Restrictions / Limitations**: Document centralization risks and known limitations (e.g., limited TVL, token support).
36+
- **Dependencies**: List all external dependencies.
37+
- **Access Control / Privileged Roles**: Record all roles and their privileges.
38+
39+
## Provide a Robust Test Suite
40+
Maintaining a comprehensive test suite that covers significant portions of your codebase allows auditors to focus on finding vulnerabilities rather than understanding basic functionality. Before an audit, ensure you have:
41+
42+
- **Unit Tests**: Test individual functions and components
43+
- **Integration Tests**: Test interactions between different parts of your system
44+
- **Fuzz Testing**: Automated testing with random inputs to find edge cases
45+
- **High Code Coverage**: Aim for substantial coverage of your critical code paths
46+
- **Formal Verification**: If applicable, use formal methods to prove correctness of critical components
47+
48+
## Conduct an Initial Code Walkthrough
49+
The first step in a security audit should be a high-level video walkthrough where you:
50+
51+
- Explain your codebase architecture and key components
52+
- Describe how the code is intended to function
53+
- Highlight critical areas that need special attention
54+
- Provide context for design decisions and trade-offs
55+
- Guide auditors on where to find answers to common questions
56+
57+
This walkthrough helps auditors understand your system quickly and focus their time on security analysis rather than code comprehension.

0 commit comments

Comments
 (0)