Skip to content

fix(security): remove raw session_id from security event logs#625

Open
hobostay wants to merge 1 commit into
OpenBMB:mainfrom
hobostay:fix/session-id-info-disclosure
Open

fix(security): remove raw session_id from security event logs#625
hobostay wants to merge 1 commit into
OpenBMB:mainfrom
hobostay:fix/session-id-info-disclosure

Conversation

@hobostay
Copy link
Copy Markdown

Summary

  • Remove the raw user-supplied session_id from the INVALID_SESSION_ID_FORMAT security log event
  • The previous code logged the potentially malicious input verbatim in both the message and details field

Vulnerability Details

In server/routes/sessions.py (lines 21-26), when an invalid session_id is detected, the code logs:

logger.log_security_event(
    "INVALID_SESSION_ID_FORMAT",
    f"Invalid session_id format: {session_id}",
    details={"received_session_id": session_id},
)

Since this input already failed the format validation and is flagged as potentially malicious, logging it verbatim is risky:

  1. Log injection: An attacker can craft a session_id containing newline characters or log-formatting sequences to inject fake log entries, obscuring real attacks
  2. Information disclosure: The raw value is stored in structured log details, potentially exposing injection payloads to downstream log analysis systems

Fix

Replace with a static message that still records the event without echoing the raw input:

logger.log_security_event(
    "INVALID_SESSION_ID_FORMAT",
    "Invalid session_id format rejected",
)

Test plan

  • Send a request with an invalid session_id and verify the security event is still logged
  • Verify the log no longer contains the raw user-supplied value

🤖 Generated with Claude Code

The INVALID_SESSION_ID_FORMAT log event was logging the raw
user-supplied session_id value in both the message and details
field. Since this input is already flagged as potentially malicious
(failing the format check), logging it verbatim could enable log
injection attacks where an attacker crafts a session_id containing
log-forging characters (e.g. newlines) to inject fake log entries.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant