Project: TrustLink - On-Chain Attestation & Verification System
Version: 0.1.0
Blockchain: Stellar Soroban
Audit Type: Pre-Mainnet Security Audit
Prepared: March 26, 2026
TrustLink is a Soroban smart contract providing a reusable trust layer for the Stellar blockchain. It enables authorized issuers to create, manage, and revoke attestations about wallet addresses, allowing other contracts and applications to verify claims before executing financial operations.
This audit scope document defines the boundaries, objectives, and deliverables for a comprehensive security review of TrustLink before mainnet deployment with real funds.
TrustLink solves decentralized identity verification and trust establishment on-chain. Instead of each application building its own KYC/verification system, TrustLink provides shared attestation infrastructure queryable by any smart contract.
- Authorized Issuers: Admin-controlled registry of trusted attestation issuers
- Claim Type Registry: Admin-managed registry of standard claim types with descriptions
- Flexible Claims: Support for any claim type (KYC_PASSED, ACCREDITED_INVESTOR, MERCHANT_VERIFIED, etc.)
- Expiration Support: Optional time-based expiration for attestations
- Historical Import: Admin can import externally verified attestations with original timestamps
- Cross-Chain Bridge Support: Trusted bridge contracts can bring attestations from other chains on-chain
- Configurable Fees: Admin can require a token-denominated fee for native attestation creation
- Revocation: Issuers can revoke attestations at any time
- Deterministic IDs: Attestations have unique, reproducible identifiers
- Event Emission: All state changes emit events for off-chain indexing
- Multi-Sig Support: M-of-N issuer co-signing for high-value claims
- GDPR Compliance: Soft-delete mechanism for right to erasure
- Pagination: Efficient listing of attestations per subject or issuer
- Mainnet: Stellar Production Network
- Real Funds: Yes - fee collection and potential token transfers
- User Impact: High - affects KYC/verification for regulated financial protocols
- Location:
src/directory - Language: Rust (Soroban SDK v21.0.0)
- Files:
src/lib.rs- Main contract implementation (40+ public functions)src/types.rs- Data structures, error definitions, attestation schemasrc/storage.rs- Storage patterns, TTL management, pagination logicsrc/validation.rs- Authorization and access control checkssrc/events.rs- Event emission for off-chain indexingsrc/test.rs- Unit tests
Functions to Review (40+):
- Initialization:
initialize,transfer_admin,get_admin - Issuer Management:
register_issuer,remove_issuer,is_issuer,update_issuer_tier,get_issuer_metadata,set_issuer_metadata - Claim Type Registry:
register_claim_type,get_claim_type_description,list_claim_types - Attestation Creation:
create_attestation,create_attestations_batch,create_attestation_from_template - Attestation Queries:
get_attestation,has_valid_claim,has_valid_claim_from_issuer,has_any_claim,has_all_claims,get_valid_claims,get_attestations_by_tag - Attestation Management:
revoke_attestation,revoke_attestations_batch,renew_attestation,update_expiration,request_deletion - Pagination:
get_subject_attestations,get_issuer_attestations - Templates:
create_template,get_template,list_templates - Multi-Sig:
propose_attestation,cosign_attestation - Endorsements:
endorse_attestation - Bridge Support:
register_bridge,bridge_attestation - Fee Management:
set_fee,get_fee_config - Import:
import_attestation - Emergency:
pause,unpause,is_paused - Hooks:
register_expiration_hook,remove_expiration_hook - Health:
health_check,get_version,get_contract_metadata,get_config,get_expiring_attestations,get_issuer_expiring_attestations
- Admin-only functions and their guards
- Issuer registry enforcement
- Subject authentication for deletion requests
- Bridge contract authorization
- Multi-sig threshold validation
- Pause mechanism enforcement
- Deterministic ID generation (SHA-256 based)
- Collision prevention and uniqueness guarantees
- Storage key management and TTL policies
- Pagination logic and boundary conditions
- Duplicate attestation prevention
- Revocation flag handling
- Expiration validation and enforcement
- Fee collection and token transfer correctness
- Batch operation atomicity and error handling
- Multi-sig proposal lifecycle (creation, co-signing, expiry)
- Endorsement chain validation
- Bridge attestation source tracking
- Template instantiation and override logic
- Claim type registry consistency
- Event completeness (all state changes emit events)
- Event accuracy (correct data in topics and data fields)
- Event ordering and consistency
- Off-chain indexer compatibility
- Soft-delete implementation (
request_deletion) - Deletion flag enforcement in queries
- Compliance audit trail (DeletionRequested events)
- Data minimization practices
- External contract calls (expiration hooks, fee token transfers)
- Callback trust boundaries
- Reentrancy considerations
- Error propagation from external calls
- Unit tests in
src/test.rs(30+ tests) - Authorization tests in
tests/authorization.rs - Integration tests in
tests/integration_test.rs - Fuzz tests in
tests/id_generation_fuzz.rs - Example contracts:
examples/kyc-token/,examples/anchor-integration/
- Indexer Application: Off-chain Node.js/TypeScript indexer (
indexer/directory) - separate audit recommended - SDK Implementation: TypeScript SDK (
sdk/typescript/) - separate audit recommended - Infrastructure: Docker, Kubernetes, deployment automation
- Stellar Network: Soroban runtime, Horizon API, consensus mechanism
- Third-Party Dependencies: Soroban SDK itself (assumed audited by Stellar)
- Documentation Quality: Grammar, clarity (content accuracy is in scope)
- Build System: Makefile, CI/CD configuration
- Example Contracts: KYC token and anchor integration examples (reference implementations only)
-
Authorization Correctness
- Verify all functions enforce correct access control
- Confirm admin, issuer, and subject roles are properly scoped
- Validate that de-registered issuers cannot perform privileged actions
- Ensure multi-sig thresholds are correctly enforced
-
Data Integrity
- Confirm deterministic ID generation prevents collisions
- Verify attestation immutability (only revoked flag and expiration can change)
- Validate storage key isolation and no cross-contamination
- Ensure pagination logic handles edge cases correctly
-
State Consistency
- Verify batch operations are atomic or fail safely
- Confirm event emission matches state changes
- Validate that pause mechanism blocks all write operations
- Ensure TTL expiry doesn't cause data loss or inconsistency
-
Threat Model Coverage
- Prevent unauthorized issuance
- Prevent self-attestation
- Prevent replay attacks
- Prevent admin impersonation
- Prevent issuer bypass after de-registration
- Prevent unauthorized revocation
- Prevent unauthorized admin transfer
-
Compliance & Privacy
- Verify GDPR right to erasure implementation
- Confirm data minimization practices
- Validate deletion event emission for off-chain compliance
- Ensure no PII leakage in on-chain data
-
Operational Security
- Assess admin key compromise impact
- Evaluate emergency pause effectiveness
- Review incident response capabilities
- Validate monitoring and alerting requirements
-
Performance & Scalability
- Assess gas efficiency of operations
- Evaluate pagination performance
- Review batch operation limits
- Validate storage TTL impact on long-term operations
-
Known Issues Resolution
- Verify three pre-identified HIGH/MEDIUM findings are fixed:
- FINDING-001:
initialize()state read before auth - FINDING-002:
revoke_attestation()missingrequire_issuercheck - FINDING-003:
update_expiration()missingrequire_issuercheck
- FINDING-001:
- Verify three pre-identified HIGH/MEDIUM findings are fixed:
A preliminary authorization audit identified three findings that must be resolved before mainnet deployment:
Location: src/lib.rs — initialize()
Status: Open
Severity: Medium
Description: Storage::has_admin() is called before admin.require_auth(), violating the principle that authorization must precede all state interaction.
Recommendation: Move require_auth() to the first line.
Location: src/lib.rs — revoke_attestation()
Status: Open
Severity: High
Description: Function lacks Validation::require_issuer() check. De-registered issuers can still revoke their attestations.
Recommendation: Add Validation::require_issuer(&env, &issuer)?; after require_auth().
Location: src/lib.rs — update_expiration()
Status: Open
Severity: High
Description: Function lacks Validation::require_issuer() check, inconsistent with renew_attestation(). De-registered issuers can extend expiration indefinitely.
Recommendation: Add Validation::require_issuer(&env, &issuer)?; after require_auth().
These are architectural limitations that are acceptable but should be understood:
- Admin Key Compromise: Single point of failure; mitigated by multisig account
- Issuer Key Compromise: No rate limiting or per-issuer caps
- No On-Chain Claim Type Validation: Registry is informational only
- Metadata Unverified: Free-form string, no content validation
- Storage TTL Expiry: Entries evicted after 30 days of inactivity
- Expiration Hook Callback Trust: Arbitrary external contract calls
- Bridge Contract Trust: Binary (all-or-nothing), no per-bridge claim type restrictions
- No Subject Consent: Subjects cannot reject attestations
- Batch Pause Gap:
create_attestations_batchnot pause-gated
-
Static Analysis
- Line-by-line review of all public functions
- Authorization flow verification
- Storage access pattern analysis
- Event emission completeness check
-
Authorization Audit
- Verify
require_auth()placement (must be first meaningful call) - Confirm state reads occur after authorization
- Validate TOCTOU (time-of-check-time-of-use) safety
- Check admin/issuer/subject role enforcement
- Verify
-
Data Flow Analysis
- Trace attestation creation through storage
- Verify ID generation determinism
- Validate pagination boundary conditions
- Check batch operation atomicity
-
Threat Modeling
- Review against documented threat model
- Identify potential attack vectors
- Assess impact of key compromise
- Evaluate emergency response capabilities
-
Test Coverage Review
- Analyze unit test completeness
- Review integration test scenarios
- Assess fuzz test effectiveness
- Identify coverage gaps
-
Functional Testing
- Execute all provided tests
- Verify test coverage of critical paths
- Validate test assertions
-
Security Testing
- Attempt authorization bypass scenarios
- Test boundary conditions
- Verify error handling
- Assess state consistency under failure
-
Integration Testing
- Test cross-contract interactions
- Verify event emission accuracy
- Validate fee collection correctness
- Test multi-sig workflows
A comprehensive security audit report including:
-
Executive Summary
- Overall risk assessment
- Critical findings summary
- Recommendations for mainnet deployment
-
Detailed Findings
- Critical issues (must fix before mainnet)
- High-severity issues (should fix before mainnet)
- Medium-severity issues (consider fixing)
- Low-severity issues (informational)
- Informational notes and best practices
-
Authorization Review
- Function-by-function authorization analysis
- Role enforcement verification
- Access control correctness assessment
-
Data Integrity Analysis
- ID generation verification
- Storage safety assessment
- Pagination correctness validation
-
Compliance Assessment
- GDPR compliance verification
- Data minimization review
- Privacy controls assessment
-
Recommendations
- Mainnet readiness assessment
- Suggested improvements
- Operational security guidance
- Monitoring and alerting requirements
- Detailed findings with code references
- Proof-of-concept exploits (if applicable)
- Test cases demonstrating issues
- Remediation guidance for each finding
- Risk matrix and prioritization
- Audit completion certificate
- Audit badge for README and website
- Audit report publication link
- Auditor contact information
✅ Audit Scope Document Created
- This document defines audit boundaries and objectives
✅ Reputable Firm Engaged
- Soroban-experienced security firm with blockchain audit track record
- Minimum 3 years of smart contract audit experience
- References from previous blockchain projects
✅ All Critical Findings Resolved
- All CRITICAL severity issues fixed and verified
- All HIGH severity issues fixed or accepted with documented risk
- Code changes tested and verified
✅ Audit Report Published
- Full audit report published on project website
- Executive summary available publicly
- Detailed findings available to stakeholders
✅ README Updated
- Audit badge/link added to README.md
- Audit completion date documented
- Link to full audit report provided
Before mainnet deployment:
- All three pre-audit findings (FINDING-001, FINDING-002, FINDING-003) are fixed
- Audit scope document approved by auditor
- Auditor engaged and audit commenced
- All critical findings resolved
- All high findings resolved or accepted
- Audit report completed and reviewed
- README updated with audit badge and link
- Audit report published publicly
- Admin key secured (hardware wallet or multisig)
- Deployment key differs from long-term admin key
- Initial issuers reviewed and key management confirmed
- Fee configuration reviewed (if enabled)
- Bridge contracts audited (if used)
- Incident response runbook created
- Event monitoring and alerting configured
- Testnet deployment and integration testing completed
- Soroban Experience: Minimum 2 audits of Soroban smart contracts
- Blockchain Expertise: 5+ years of blockchain security experience
- Smart Contract Audits: 20+ completed smart contract security audits
- References: Verifiable references from previous blockchain projects
- Team: Dedicated security engineers with cryptography background
- Engagement: 2-4 weeks
- Audit Duration: 4-6 weeks
- Report Delivery: 1-2 weeks after audit completion
- Total Timeline: 7-12 weeks from engagement to report publication
- Scope: ~5,000 lines of Rust code + tests
- Estimated Cost: $50,000 - $150,000 USD
- Factors: Firm reputation, team size, timeline urgency
Pre-Audit: HIGH RISK
- Three pre-identified security findings (1 MEDIUM, 2 HIGH)
- Requires external security audit before mainnet
- Not suitable for production deployment with real funds
Post-Audit (Expected): MEDIUM RISK
- Assuming all critical findings are resolved
- Residual risks from known limitations (documented)
- Suitable for mainnet with operational security measures
-
Admin Key Compromise (HIGH IMPACT, LOW PROBABILITY)
- Mitigation: Use multisig account for admin
- Mitigation: Hardware wallet for key storage
- Mitigation: Emergency pause mechanism
-
Issuer Key Compromise (MEDIUM IMPACT, MEDIUM PROBABILITY)
- Mitigation: Issuer rotation capability
- Mitigation: Revocation monitoring
- Mitigation: Expiration renewal workflows
-
Storage TTL Expiry (LOW IMPACT, LOW PROBABILITY)
- Mitigation: Periodic renewal of active attestations
- Mitigation: Monitoring for expiry events
-
Bridge Contract Vulnerability (MEDIUM IMPACT, LOW PROBABILITY)
- Mitigation: Audit bridge contracts before registration
- Mitigation: Selective bridge registration
- Publish audit report on project website
- Add audit badge to README.md
- Create link to full audit report
- Announce audit completion to community
- Address any critical findings
- Deploy to mainnet (if all critical findings resolved)
- Monitor contract for anomalies
- Establish incident response procedures
- Set up event monitoring and alerting
- Begin operational security monitoring
- Maintain audit report on website
- Monitor for security updates in Soroban SDK
- Plan periodic security reviews (annually)
- Track and document any incidents
- Maintain incident response runbook
- Project Lead: [Name/Contact]
- Technical Lead: [Name/Contact]
- Security Contact: [Name/Contact]
- Primary Contact: [Auditor Name/Email]
- Escalation Contact: [Auditor Manager/Email]
- Report Delivery: [Expected Date]
- Community: GitHub Discussions, Discord
- Integrators: Direct email notification
- Regulators: As required by jurisdiction
TrustLink/
├── src/
│ ├── lib.rs # Main contract (40+ functions)
│ ├── types.rs # Data structures, errors
│ ├── storage.rs # Storage patterns, TTL
│ ├── validation.rs # Authorization logic
│ ├── events.rs # Event emission
│ └── test.rs # Unit tests (30+)
├── tests/
│ ├── authorization.rs # Authorization tests
│ ├── integration_test.rs # Integration tests
│ └── id_generation_fuzz.rs # Fuzz tests
├── examples/
│ ├── kyc-token/ # Token contract example
│ └── anchor-integration/ # Anchor flow example
├── indexer/ # Off-chain indexer (out of scope)
├── sdk/typescript/ # TypeScript SDK (out of scope)
├── docs/
│ ├── security.md # Trust hierarchy, threat model
│ ├── security-review.md # Pre-audit findings
│ ├── compliance.md # GDPR compliance
│ ├── monitoring.md # Event monitoring
│ └── adr/ # Architecture decisions
├── Cargo.toml # Dependencies
├── DEPLOYMENT.md # Deployment guide
├── README.md # Main documentation
└── AUDIT_SCOPE.md # This document
- README.md - Project overview and usage
- docs/security.md - Trust hierarchy and threat model
- docs/security-review.md - Pre-audit findings
- docs/compliance.md - GDPR compliance details
- DEPLOYMENT.md - Deployment procedures
- docs/integration-guide.md - Cross-contract patterns
# Run all tests
cargo test
# Run specific test
cargo test test_create_attestation
# Run with output
cargo test -- --nocapture
# Build WASM
cargo build --target wasm32-unknown-unknown --release
# Optimize
soroban contract optimize --wasm target/wasm32-unknown-unknown/release/trustlink.wasm# Deploy to testnet
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/trustlink.wasm \
--source ADMIN_SECRET_KEY \
--network testnet
# Initialize
soroban contract invoke \
--id $CONTRACT_ID \
--source ADMIN_SECRET_KEY \
--network testnet \
-- initialize \
--admin ADMIN_PUBLIC_ADDRESS| Version | Date | Author | Changes |
|---|---|---|---|
| 1.0 | 2026-03-26 | TrustLink Team | Initial audit scope document |
Document Status: READY FOR AUDIT FIRM ENGAGEMENT
Next Step: Identify and contact Soroban-experienced audit firm with this scope document.