Skip to content

security: avoid raw uploaded filename leakage in service logs (fixes #273)#274

Open
Flamki wants to merge 1 commit intojenkinsci:mainfrom
Flamki:fix/sanitize-file-logging
Open

security: avoid raw uploaded filename leakage in service logs (fixes #273)#274
Flamki wants to merge 1 commit intojenkinsci:mainfrom
Flamki:fix/sanitize-file-logging

Conversation

@Flamki
Copy link
Contributor

@Flamki Flamki commented Mar 11, 2026

Description

Fixes #273.

This PR hardens file_service logging to avoid raw uploaded filename leakage in service logs, while preserving operational signal.

What changed

  • chatbot-core/api/services/file_service.py
    • Added _safe_filename_for_log() using existing sanitize_logs utility.
    • Updated warning logs that include filename to use sanitized basename.
    • Replaced INFO log Processing uploaded file: <filename> with metadata-only logging:
      • file size in bytes
      • file extension
  • chatbot-core/tests/unit/services/test_file_service.py
    • Added regression test ensuring the INFO log path does not include raw filename values.

Why

Filenames are user-controlled input and can contain sensitive identifiers. This keeps INFO/WARN logs safer by default without changing file-processing behavior or response contracts.

Scope / non-overlap

  • Backend logging hardening only.
  • No changes to upload validation logic, persistence flow, auth/gatekeeper, or retrieval architecture.

Verification

  • pytest tests/unit/services/test_file_service.py -q -> 46 passed
  • pylint api/services/file_service.py tests/unit/services/test_file_service.py -> 10.00/10

@Flamki Flamki requested a review from a team as a code owner March 11, 2026 17:32
@berviantoleo berviantoleo added the bug For changelog: Minor bug. Will be listed after features label Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug For changelog: Minor bug. Will be listed after features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Security] Avoid raw uploaded filename leakage in file_service logs

2 participants