Security considerations and best practices for using Shade402 in production.
Wallet Security
Private Key Storage
Never store private keys in code or version control:
Copy // BAD: Hardcoded private key
const wallet = Keypair . fromSecretKey (
Buffer . from ( ' hardcoded-secret-key ' , ' base64 ' )
) ;
// GOOD: Load from environment variable
const wallet = Keypair . fromSecretKey (
Buffer . from ( process . env . WALLET_SECRET_KEY ! , ' base64 ' )
) ;
// GOOD: Use key management service
const wallet = await loadWalletFromAWSSecretsManager () ; Regularly rotate wallet keys:
Update environment variables
Monitor old wallet for unexpected activity
Key Access Control
Limit access to wallet private keys:
Use environment variables (not committed to git)
Use secret management services (AWS Secrets Manager, HashiCorp Vault)
Implement access controls and audit logging
Use separate wallets for different environments
Payment Verification
On-chain Verification
Always enable on-chain verification in production:
On-chain verification:
Confirms transaction exists on blockchain
Verifies transaction signature
Checks transaction status
Payment Expiration
Set appropriate expiration times:
Consider:
Shorter expiration for high-value resources
Longer expiration for user-initiated flows
Balance security with user experience
Amount Validation
Always validate payment amounts:
Resource Encryption
Enable Encryption
Use resource encryption for sensitive resources:
Encryption prevents:
Payment request replay attacks
Unauthorized access to payment requests
Store encryption keys securely:
Use separate keys for different environments
Use key management services
Never expose private keys
Client-side Validation
The client validates URLs to prevent SSRF attacks:
Only allows http:// and https:// schemes
Blocks localhost and private IPs (unless allowLocal is enabled)
For local development only:
Never use allowLocal in production.
Server-side Validation
Validate all incoming URLs and parameters:
Implement rate limiting for payment-protected endpoints:
Transaction Security
Transaction Signing
Always verify transaction signatures:
Transaction Monitoring
Monitor transactions for suspicious activity:
Track payment amounts and frequencies
Alert on unusual patterns
Log all payment transactions
Review failed payment attempts
Network Security
RPC Endpoint Security
Use secure RPC endpoints:
Network Validation
Validate network configuration:
Best Practices Summary
Never commit private keys to version control
Use environment variables or key management services
Enable on-chain verification in production
Set appropriate expiration times for payment requests
Validate all payment data before processing
Enable resource encryption for sensitive resources
Implement rate limiting for payment endpoints
Monitor transactions for suspicious activity
Use secure RPC endpoints with HTTPS
Log payment transactions for audit purposes
Handle errors securely without exposing sensitive information
Regularly rotate keys and update dependencies
Test security measures before production deployment
Keep dependencies updated for security patches
Security Checklist
Before deploying to production:
Reporting Security Issues
If you discover a security vulnerability:
Do not open a public issue
Include details of the vulnerability
Wait for confirmation before disclosing
Last updated 3 months ago