Skip to content

Security: jellyfishing2346/cryptex

Security

SECURITY.md

Security Policy

Supported Versions

Currently, only the latest version of Cryptex is supported with security updates.

Version Supported
0.8.x
< 0.8

Reporting a Vulnerability

If you discover a security vulnerability, please report it responsibly.

How to Report

Do NOT open a public issue for security vulnerabilities.

Instead, please send an email to: security@cryptex.dev

Include the following information in your report:

  • Description of the vulnerability
  • Steps to reproduce the vulnerability
  • Potential impact of the vulnerability
  • Any suggested fixes or mitigations

Response Timeline

  • Initial response: Within 48 hours
  • Detailed assessment: Within 7 days
  • Fix timeline: Based on severity, typically within 30 days

What to Expect

  1. Acknowledgment: We will acknowledge receipt of your report within 48 hours
  2. Validation: We will validate the vulnerability and assess its severity
  3. Coordination: We will work with you to coordinate a fix and disclosure
  4. Credit: With your permission, we will credit you in the security advisory

Security Best Practices

Deployment Security

1. Authentication

Currently, Cryptex does not implement authentication. In production, you MUST add authentication before deploying.

Recommended approaches:

  • JWT token authentication
  • API key authentication
  • OAuth 2.0 integration

2. Network Security

  • Use HTTPS in production (TLS/SSL)
  • Implement firewall rules
  • Use VPC/private networks for internal services
  • Restrict access to Redis and NATS

3. Secrets Management

Never commit secrets to the repository:

  • Use environment variables for configuration
  • Use secret management tools (HashiCorp Vault, AWS Secrets Manager)
  • Rotate credentials regularly
  • Use different credentials for different environments

4. Input Validation

Cryptex implements basic input validation, but in production:

  • Add rate limiting
  • Implement request size limits
  • Validate all user inputs
  • Sanitize data before storage

Operational Security

1. Redis Security

# Enable Redis authentication
requirepass your-strong-password

# Disable dangerous commands
rename-command FLUSHDB ""
rename-command FLUSHALL ""
rename-command CONFIG ""

# Use TLS in production
tls-port 6380
port 0
tls-cert-file /path/to/redis.crt
tls-key-file /path/to/redis.key

2. NATS Security

# Enable authentication
# Use NATS account-based security
# Enable TLS for encryption

3. Container Security

# Use non-root user
USER nonroot

# Minimize attack surface
# Use minimal base images
# Regularly update base images

Application Security

1. Risk Management

Cryptex includes built-in risk management:

  • Position limits: Prevent excessive exposure
  • Self-trade prevention: Prevent accidental conflicts
  • Price collars: Prevent extreme price manipulation

Configure these appropriately for your use case:

export MAX_POSITION_SIZE=1000.0
export MIN_PRICE=0.01
export MAX_PRICE=1000000.0

2. Order Validation

All orders are validated before processing:

  • Trading pair validation
  • Price and quantity validation
  • User ID validation
  • Order type validation

3. Error Handling

  • Never expose sensitive information in error messages
  • Use generic error messages for clients
  • Log detailed errors server-side
  • Implement proper error boundaries

Data Security

1. Data at Rest

  • Encrypt sensitive data at rest
  • Use Redis encryption for persistence
  • Implement backup encryption
  • Secure backup storage

2. Data in Transit

  • Use TLS for all network communications
  • Encrypt WebSocket connections (wss://)
  • Secure API endpoints with HTTPS
  • Encrypt Redis connections

3. Data Retention

  • Implement data retention policies
  • Regularly clean up old orders
  • Securely delete sensitive data
  • Audit data access

Known Security Considerations

Current Limitations

  1. No Authentication: API is currently open to all requests
  2. No Rate Limiting: API is vulnerable to abuse
  3. No Audit Logging: Limited security event tracking
  4. No Input Sanitization: Basic validation only
  5. No Encryption: Data transmitted in plain text

Recommended Improvements

  1. Add Authentication Layer

    • Implement JWT authentication
    • Add API key support
    • Integrate OAuth 2.0
  2. Add Rate Limiting

    • Implement per-user rate limits
    • Add IP-based rate limiting
    • Use Redis for rate limit storage
  3. Add Audit Logging

    • Log all order placements
    • Log all cancellations
    • Log all trades
    • Log failed authentication attempts
  4. Add Encryption

    • Enable TLS for all connections
    • Encrypt data at rest
    • Use secure WebSocket connections
  5. Add Input Sanitization

    • Sanitize all user inputs
    • Validate data types
    • Prevent injection attacks

Security Checklist

Before Deployment

  • Authentication implemented
  • Rate limiting configured
  • TLS/SSL enabled
  • Secrets managed securely
  • Firewall rules configured
  • Redis authentication enabled
  • NATS authentication enabled
  • Input validation enhanced
  • Error handling reviewed
  • Logging configured
  • Monitoring configured
  • Backup strategy implemented
  • Incident response plan created

Regular Security Tasks

  • Update dependencies regularly
  • Review and rotate secrets
  • Monitor security advisories
  • Conduct security audits
  • Test backup recovery
  • Review access logs
  • Update firewall rules
  • Review user permissions

Dependency Security

Keeping Dependencies Updated

# Check for outdated dependencies
go list -u -m all

# Update dependencies
go get -u ./...
go mod tidy

# Check for vulnerabilities
go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...

Vulnerability Scanning

Regularly scan for vulnerabilities in dependencies:

# Use Go vulnerability checker
govulncheck ./...

# Use Docker security scanning
docker scan cryptex:latest

# Use third-party tools
# Snyk, Dependabot, etc.

Incident Response

Security Incident Process

  1. Detection

    • Monitor security alerts
    • Review logs regularly
    • Monitor for unusual activity
  2. Containment

    • Isolate affected systems
    • Disable compromised accounts
    • Block malicious IPs
  3. Eradication

    • Remove malicious code
    • Patch vulnerabilities
    • Update compromised credentials
  4. Recovery

    • Restore from clean backups
    • Monitor for recurrence
    • Document lessons learned
  5. Post-Incident

    • Conduct post-mortem
    • Update security policies
    • Improve monitoring

Contact Information

For security incidents:

Compliance

Data Protection

Ensure compliance with relevant regulations:

  • GDPR (if handling EU data)
  • CCPA (if handling California data)
  • SOC 2 (for enterprise customers)
  • PCI DSS (if handling payment data)

Security Standards

Aim to comply with:

  • OWASP Top 10
  • NIST Cybersecurity Framework
  • ISO 27001 (information security)

Security Resources

Useful Tools

  • OWASP ZAP: Web application security scanner
  • Go vulncheck: Go vulnerability scanner
  • Docker Bench: Docker security best practices
  • Nessus: Vulnerability scanner
  • Burp Suite: Web application testing

Further Reading

Acknowledgments

We thank all security researchers who help keep Cryptex secure by responsibly reporting vulnerabilities.


Remember: Security is an ongoing process. Regularly review and update your security practices.

There aren't any published security advisories