Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Security: kriscoleman/GoRetry

Security

SECURITY.md

Security Policy

Supported Versions

We actively support the following versions of GoRetry with security updates:

Version Supported
1.x.x
0.x.x

Reporting a Vulnerability

The GoRetry maintainers take security seriously. If you discover a security vulnerability, please follow these steps:

For Security Issues

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:

  1. Description: A clear description of the vulnerability
  2. Impact: What an attacker could achieve by exploiting this vulnerability
  3. Reproduction: Step-by-step instructions to reproduce the issue
  4. Fix Suggestion: If you have suggestions for fixing the vulnerability
  5. Disclosure Timeline: Your preferred timeline for disclosure (if any)

What to Expect

  • 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

Security Best Practices for Users

When using GoRetry in your applications, consider these security best practices:

1. Validate Input Parameters

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)
}

2. Set Reasonable Timeouts

// 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)
})

3. Implement Rate Limiting

// 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)
}

4. Sanitize Log Output

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=***")
}

5. Validate Retry Policies

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
}

Security Considerations

Resource Exhaustion

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

Denial of Service (DoS) Protection

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)

Information Disclosure

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

Input Validation

Always validate input parameters to prevent abuse:

  • Maximum attempt limits
  • Reasonable delay bounds
  • Timeout constraints
  • Function parameter validation

Security Testing

We employ several security testing measures:

  1. Static Analysis: Using gosec to scan for security vulnerabilities
  2. Dependency Scanning: Regular checks for vulnerable dependencies
  3. Fuzzing: Testing with random inputs to find edge cases
  4. Code Review: Security-focused code reviews for all changes

Responsible Disclosure

We believe in responsible disclosure and will:

  1. Work with security researchers to understand and fix vulnerabilities
  2. Provide credit to researchers who help improve our security
  3. Release security advisories for significant vulnerabilities
  4. Coordinate disclosure timelines that balance security with user notification

Security Resources

Contact

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!

There aren’t any published security advisories