Skip to content

[Security] Address cleartext logging of potentially sensitive information #246

Description

@sanchitmonga22

Problem Statement

GitHub security scanning detected potential logging of sensitive data (apiKey) in the logging infrastructure.

What's the issue?

  • The logging function at sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/Logging.swift:81 may receive and log sensitive information including API keys
  • API keys should never be logged in plaintext
  • This could lead to credential exposure through log files

Why does it matter?

  • Security concern flagged by GitHub Advanced Security
  • Could expose API keys in debug logs, crash reports, or log aggregation systems
  • Violates security best practices for credential handling

Current State

  • File: sdk/runanywhere-swift/Sources/RunAnywhere/Infrastructure/Logging/Logging.swift
  • Line: 81
  • Detection: GitHub Advanced Security - Cleartext logging of sensitive information

Proposed Solution

  1. Audit all logging call sites - Identify where sensitive data might be passed to logging functions
  2. Implement log sanitization - Add redaction for known sensitive patterns (API keys, tokens, etc.)
  3. Add documentation - Document which data should never be passed to logging functions
  4. Consider structured logging - Use typed log events that explicitly exclude sensitive fields

Example Sanitization Pattern

private func sanitize(_ message: String) -> String {
    // Redact API key patterns
    let apiKeyPattern = /(?:api[_-]?key|apikey|key)[=:]\s*["']?[\w-]+["']?/i
    return message.replacing(apiKeyPattern, with: "[REDACTED]")
}

Implementation Plan

  • Audit Logging.swift and all callers
  • Implement sanitization for known sensitive patterns
  • Add unit tests for sanitization
  • Update documentation on secure logging practices
  • Verify fix with GitHub security scanning

Success Criteria

  • GitHub Advanced Security no longer flags this issue
  • Sensitive data patterns are redacted in all log outputs
  • Documentation updated with secure logging guidelines

Related Links


🤖 Generated with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Critical / blockingbugSomething isn't workingios-sdkiOS / Swift SDKsecuritySecurity vulnerability or hardening

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions