We actively support the following versions of GoRetry with security updates:
| Version | Supported |
|---|---|
| 1.x.x | ✅ |
| 0.x.x | ❌ |
The GoRetry maintainers take security seriously. If you discover a security vulnerability, please follow these steps:
DO NOT open a public GitHub issue for security vulnerabilities.
Instead, please contact me in the CNCF Slack: @Kris Coleman
Include the following information in your report:
- Description: A clear description of the vulnerability
- Impact: What an attacker could achieve by exploiting this vulnerability
- Reproduction: Step-by-step instructions to reproduce the issue
- Fix Suggestion: If you have suggestions for fixing the vulnerability
- Disclosure Timeline: Your preferred timeline for disclosure (if any)
- Acknowledgment: We'll acknowledge receipt of your report within 48 hours
- Initial Assessment: We'll provide an initial assessment within 5 business days
- Progress Updates: We'll keep you informed of our progress
- Resolution: We aim to resolve security issues within 30 days
- Credit: With your permission, we'll credit you in our security advisory
When using GoRetry in your applications, consider these security best practices:
func safeRetry(maxAttempts int, baseDelay time.Duration) error {
// Validate input to prevent resource exhaustion
if maxAttempts <= 0 || maxAttempts > 100 {
return errors.New("maxAttempts must be between 1 and 100")
}
if baseDelay < 0 || baseDelay > 1*time.Hour {
return errors.New("baseDelay must be between 0 and 1 hour")
}
retrier := goretry.NewRetrier(
goretry.NewExponentialBackoffPolicy(baseDelay, 30*time.Second),
goretry.WithMaxAttempts(maxAttempts),
)
return retrier.Do(yourOperation)
}// Always use context with timeouts to prevent indefinite blocking
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
defer cancel()
err := goretry.IfNeededWithContext(ctx, func(ctx context.Context) error {
return yourNetworkOperation(ctx)
})// Implement application-level rate limiting to prevent abuse
type RateLimitedRetrier struct {
retrier *goretry.Retrier
rateLimiter *rate.Limiter
}
func (r *RateLimitedRetrier) Do(fn func() error) error {
if !r.rateLimiter.Allow() {
return errors.New("rate limit exceeded")
}
return r.retrier.Do(fn)
}retrier := goretry.NewRetrier(policy,
goretry.WithOnRetry(func(attempt int, err error) {
// Be careful not to log sensitive information
log.Printf("Retry attempt %d failed: %s", attempt, sanitizeError(err))
}),
)
func sanitizeError(err error) string {
errStr := err.Error()
// Remove sensitive information like tokens, passwords, etc.
return regexp.MustCompile(`token=\w+`).ReplaceAllString(errStr, "token=***")
}func validatePolicy(policy goretry.RetryPolicy) error {
// Test policy with reasonable bounds
for attempt := 1; attempt <= 10; attempt++ {
delay, shouldContinue := policy.NextDelay(attempt)
if delay < 0 {
return fmt.Errorf("policy returned negative delay: %v", delay)
}
if delay > 5*time.Minute {
return fmt.Errorf("policy returned excessive delay: %v", delay)
}
if !shouldContinue {
break
}
}
return nil
}GoRetry operations can potentially consume significant resources if misconfigured:
- Memory: Storing error history in
OutOfRetriesError - Time: Long retry cycles with exponential backoff
- Network: Repeated failed requests
- CPU: Intensive retry operations
Protect against DoS attacks through retry mechanisms:
// Use circuit breakers to prevent retry storms
type CircuitBreaker struct {
failureThreshold int
resetTimeout time.Duration
// ... implementation
}
// Implement jitter to prevent thundering herd
policy := goretry.NewExponentialBackoffPolicy(100*time.Millisecond, 30*time.Second).
WithJitter(true)Be careful about what information is exposed through error messages and logs:
- Don't include sensitive data in error messages
- Sanitize error logs to remove credentials
- Consider using structured logging with field filtering
Always validate input parameters to prevent abuse:
- Maximum attempt limits
- Reasonable delay bounds
- Timeout constraints
- Function parameter validation
We employ several security testing measures:
- Static Analysis: Using
gosecto scan for security vulnerabilities - Dependency Scanning: Regular checks for vulnerable dependencies
- Fuzzing: Testing with random inputs to find edge cases
- Code Review: Security-focused code reviews for all changes
We believe in responsible disclosure and will:
- Work with security researchers to understand and fix vulnerabilities
- Provide credit to researchers who help improve our security
- Release security advisories for significant vulnerabilities
- Coordinate disclosure timelines that balance security with user notification
For security-related questions or concerns:
- Security Issues: CNCF Slack @Kris Coleman
- General Questions: Open a GitHub discussion
- Documentation Issues: Open a GitHub issue
Thank you for helping keep GoRetry and our users safe!