Skip to content

Template cache needs protection against unbounded growth #39

@willibrandon

Description

@willibrandon

The template cache in internal/parser/cache.go has no size limit or eviction policy, creating a potential memory exhaustion vulnerability.

Issue

Dynamic template generation could cause unbounded memory growth:

for i := 0; i < 1000000; i++ {
    logger.Info(fmt.Sprintf("User %d: {Action}", i), "login")
}

Solution

Implement an LRU cache with:

  • Configurable max size (default: 10,000 templates)
  • O(1) get/put operations
  • Optional TTL support
  • Cache hit/miss metrics for monitoring

Benefits

  • Prevents memory exhaustion
  • Predictable memory usage
  • Better performance insights via metrics
  • Production-ready for 1.0 release

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestsecuritySecurity improvements and vulnerability fixes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions