Skip to content

Latest commit

 

History

History
88 lines (63 loc) · 6.74 KB

File metadata and controls

88 lines (63 loc) · 6.74 KB

Mitigation Strategies Analysis for gabime/spdlog

  • Mitigation Strategy: Secure Configuration of Log Levels and Destinations

    • Description:

      1. Environment-Specific Configuration: Use separate configuration files (or environment variables, or programmatic configuration) for different environments (development, testing, staging, production). spdlog can be configured programmatically or via configuration files (though the file loading is typically handled by the application).
      2. Log Level Control:
        • Development/Testing: Use spdlog::level::debug or spdlog::level::trace.
        • Staging: Use spdlog::level::info or spdlog::level::debug (depending on testing needs).
        • Production: Use spdlog::level::info, spdlog::level::warn, or spdlog::level::err. Never use debug or trace in production. Use spdlog's level filtering capabilities.
      3. Secure File Sink Configuration (if used):
        • Permissions: (Handled outside of spdlog, but crucial).
        • Dedicated Directory: (Handled outside of spdlog, but crucial).
        • Rotation: Configure log rotation using spdlog's built-in features:
          • spdlog::sinks::rotating_file_sink_mt: Rotate based on file size. Use spdlog::sinks::rotating_file_sink_mt::set_rotation_policy().
          • spdlog::sinks::daily_file_sink_mt: Rotate daily.
          • Set appropriate size limits and the number of rotated files to keep using the sink's constructor or setter methods.
      4. Secure System Log Sink Configuration (if used):
        • Use spdlog::sinks::syslog_sink (or the Windows equivalent). The security of the system logger itself is outside of spdlog's control.
      5. Secure Remote Sink Configuration (if used):
        • This typically requires a custom sink, as spdlog doesn't have built-in remote sinks with TLS/authentication. If you implement a custom sink, ensure it handles security (TLS, authentication, certificate validation) within the sink's implementation.
      6. Regular Review: (Handled outside of spdlog).
    • Threats Mitigated:

      • Information Disclosure (High Severity): Prevents sensitive data from being logged at inappropriate log levels.
      • Unauthorized Access to Logs (High Severity): (Indirectly, by configuring secure destinations).
      • Denial of Service (DoS) via Disk Space Exhaustion (Medium Severity): Log rotation prevents log files from growing indefinitely.
    • Impact:

      • Information Disclosure: Risk significantly reduced.
      • Unauthorized Access to Logs: Risk reduced (depends on external configuration of file permissions, etc.).
      • DoS via Disk Space Exhaustion: Risk significantly reduced.
    • Currently Implemented: Mostly implemented. Environment-specific configurations are used. Production uses spdlog::level::info. File sinks are used with log rotation (daily, 5 files kept) configured via spdlog::sinks::daily_file_sink_mt.

    • Missing Implementation:

      • We are experimenting with a remote logging service, which would require a custom sink with TLS and authentication. This is not yet implemented.

Mitigation Strategy: Asynchronous Logging

  • Mitigation Strategy: Asynchronous Logging

    • Description:

      1. Use Asynchronous Logger: Instead of using the default synchronous loggers, use spdlog::async_logger (or the convenience functions like spdlog::create_async).
      2. Configure Queue Size: Adjust the size of the asynchronous queue based on expected log volume and memory constraints. Use the spdlog::init_thread_pool() function to initialize the thread pool and set the queue size.
      3. Handle Overflow Policy: Choose an appropriate overflow policy for the asynchronous queue:
        • spdlog::async_overflow_policy::block: The calling thread will block until space is available in the queue (this can impact performance).
        • spdlog::async_overflow_policy::overrun_oldest: The oldest messages in the queue will be discarded to make room for new messages (this can lead to log loss).
      4. Flush on critical errors: Use logger->flush_on(spdlog::level::err); to ensure that critical error messages are written immediately, even when using asynchronous logging.
    • Threats Mitigated:

      • Denial of Service (DoS) via Excessive Logging (Medium Severity): Prevents logging from blocking the main application thread, improving resilience to DoS attacks targeting the logging system.
    • Impact:

      • DoS via Excessive Logging: Risk reduced.
    • Currently Implemented: Asynchronous logging is enabled using spdlog::create_async. The default queue size is used. flush_on is set to spdlog::level::err.

    • Missing Implementation:

      • The queue size and overflow policy haven't been explicitly tuned for our application's specific needs.
  • Mitigation Strategy: Regular Updates and Dependency Management (Focus on spdlog and fmtlib)

    • Description:

      1. Dependency Management System: (Handled outside of spdlog, but crucial).
      2. Version Pinning: Pin the versions of spdlog and fmtlib to specific, known-good releases within your dependency management system.
      3. Regular Updates: Regularly check for new releases of spdlog and fmtlib through your dependency management system. Prioritize security updates.
      4. Vulnerability Scanning: (Ideally handled outside of spdlog, but relies on knowing the versions of spdlog and fmtlib).
      5. Testing: After updating spdlog or fmtlib, thoroughly test the application.
    • Threats Mitigated:

      • Exploitation of Known Vulnerabilities (Variable Severity, potentially Critical): Prevents attackers from exploiting known vulnerabilities in spdlog or its dependencies.
    • Impact:

      • Exploitation of Known Vulnerabilities: Risk significantly reduced.
    • Currently Implemented: We use CMake with FetchContent. Versions are pinned.

    • Missing Implementation:

      • Updates are not performed on a regular schedule.