Maushish Yadav
DeFi Security Researcher | Auditor | Founder @Paystream Labs
Audit Overview
This report details the results of a static analysis conducted on the Paystream DeFi lending protocol using the tools X-Ray (v0.0.6) and Radar.Our audit spanned three primary program modules:
drift_optimizer
, lib
, and Paystream-v1
.The primary objective was to identify unsafe patterns, missing validations, and account mismanagement across Solana smart contracts that constitute the core protocol.
Tooling & Methodology
- Tools Used: X-Ray v0.0.6, Radar
- Techniques:
- IR file analysis
- Instruction graph traversal
- Owner/signer validation
- Unsafe
AccountInfo
pattern detection - Collateral access audits
- Scope: Drift Optimizer, Core Lending Program, Utility Libraries
Findings
Drift Optimizer
- Vulnerability: Missing
owner
check onspot_market
account - Location:
get_apys.rs
, line 26 - Risk: Unauthorized account manipulation; deserialization of arbitrary data
- Mitigation: Add explicit owner validation matching expected protocol program
Lib Module
- Vulnerabilities: None
- Status: All logic modules and dependencies passed pointer and transformation analysis cleanly.
Core Protocol (Paystream-v1
)
- Total Detected: 33 vulnerabilities
- Patterns Observed:
- Repeated absence of signer/owner checks on critical account inputs
- Unsafe use of unchecked
AccountInfo<'info>
underCHECK:
macros - Multiple validator bypass risks in borrow, repay, and withdraw flows
High-Risk Locations
deposit.rs
: No signer validation onprotocol_vault_authority
lend.rs
: Improper validation of protocol and vault accountsborrow.rs
: Data leakage and injection risks due to unchecked accountswithdraw.rs
: Deserialization ofcollateral_market
without secure constraintsliquidate_by_ltv.rs
: Direct liquidatee access without auth constraints
Recommendations
- Apply
.is_signer
and.owner == expected_program_id
checks across all cross-program andCHECK:
inputs - Replace unchecked
AccountInfo
fields with validatedAccount
orInterfaceAccount
where feasible - For all
#[account(...)]
constraints, enforce explicit runtime assertions - Protect
dangerously_mutate_*
functions with hardcoded access lists or role-based checks
Security References
Conclusion
While Paystream demonstrates significant innovation in on-chain lending and liquidity optimization, security hardening remains crucial before scaling further.Patching signer and owner validation gaps should be prioritized to mitigate protocol-level risks, particularly around token streaming and borrowing logic.
A formal verification of economic invariants and runtime constraints is recommended before public audits.