Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions modules/reverseproxy/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -1784,9 +1784,13 @@ func (m *ReverseProxyModule) createReverseProxyForBackend(ctx context.Context, t
}
if err := m.responseHeaderModifier(resp, backendID, tenantID); err != nil {
if m.app != nil && m.app.Logger() != nil {
// Sanitize tenantID before logging to prevent log forging via newlines
safeTenantID := strings.ReplaceAll(strings.ReplaceAll(string(tenantID), "\n", ""), "\r", "")
m.app.Logger().Error("Response header modifier error", "backend", backendID, "tenant", safeTenantID, "error", err.Error())
// Log a hashed representation of the tenant ID to avoid exposing it in clear text
tenantHashStr := ""
if hasTenant {
sum := sha256.Sum256([]byte(tenantID))
tenantHashStr = hex.EncodeToString(sum[:])
}
m.app.Logger().Error("Response header modifier error", "backend", backendID, "tenant_hash", tenantHashStr, "error", err.Error())
Comment on lines +1787 to +1793
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This log line manually computes a full SHA-256 hex string for the tenant ID, but this file already defines and consistently uses obfuscateTenantID(tenantID) for tenant_hash logging (and it intentionally truncates for brevity). Reuse the helper here (and consider logging the field only when hasTenant is true) to keep tenant hashing consistent across the module and avoid duplicated hashing logic.

Suggested change
// Log a hashed representation of the tenant ID to avoid exposing it in clear text
tenantHashStr := ""
if hasTenant {
sum := sha256.Sum256([]byte(tenantID))
tenantHashStr = hex.EncodeToString(sum[:])
}
m.app.Logger().Error("Response header modifier error", "backend", backendID, "tenant_hash", tenantHashStr, "error", err.Error())
// Log an obfuscated representation of the tenant ID to avoid exposing it in clear text
if hasTenant {
m.app.Logger().Error(
"Response header modifier error",
"backend", backendID,
"tenant_hash", obfuscateTenantID(tenantID),
"error", err.Error(),
)
} else {
m.app.Logger().Error(
"Response header modifier error",
"backend", backendID,
"error", err.Error(),
)
}

Copilot uses AI. Check for mistakes.
}
return err
}
Expand Down
Loading