Skip to content

πŸ›‘οΈ Sentinel: Fix Information Leakage in Kafka Consumer#12

Closed
lgcorzo wants to merge 2 commits into
mainfrom
sentinel/fix-exception-leak-kafka-11752223050906537951
Closed

πŸ›‘οΈ Sentinel: Fix Information Leakage in Kafka Consumer#12
lgcorzo wants to merge 2 commits into
mainfrom
sentinel/fix-exception-leak-kafka-11752223050906537951

Conversation

@lgcorzo
Copy link
Copy Markdown
Owner

@lgcorzo lgcorzo commented Feb 5, 2026

πŸ›‘οΈ Sentinel: [MEDIUM] Fix Information Leakage in Kafka Consumer

🚨 Severity: MEDIUM
πŸ’‘ Vulnerability: The Kafka consumer and prediction callback were catching exceptions and embedding the raw exception message (str(e)) into the response payload sent to the output topic. This could leak sensitive internal details (stack traces, database info, etc.).
🎯 Impact: If the output topic is consumed by downstream systems or visible to users, sensitive information about the application internals could be exposed.
πŸ”§ Fix:
- Refactored src/regression_model_template/controller/kafka_app.py to use a PredictionService class.
- PredictionService catches exceptions, logs them using logger.exception(), and returns a generic "Internal Processing Error" message.
- Updated _process_message to similarly sanitize JSON decoding errors and other exceptions.
βœ… Verification:
- Added tests/controller/test_kafka_app_security.py which mocks a model raising a sensitive exception and asserts that the returned error message is sanitized.
- Ran existing tests to ensure no regressions.


PR created automatically by Jules for task 11752223050906537951 started by @lgcorzo

- Introduced `PredictionService` class to encapsulate prediction logic.
- Implemented secure exception handling in `PredictionService` to log full stack traces but return generic error messages to the client/topic.
- Updated `FastAPIKafkaService` to use `PredictionService` and improved exception handling in `_process_message`.
- Added `tests/controller/test_kafka_app_security.py` to verify sanitization of error messages.
- Updated `.jules/sentinel.md` with new security learning.

Co-authored-by: lgcorzo <46710567+lgcorzo@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Introduced `PredictionService` class to encapsulate prediction logic.
- Implemented secure exception handling in `PredictionService` to log full stack traces but return generic error messages to the client/topic.
- Updated `FastAPIKafkaService` to use `PredictionService` and improved exception handling in `_process_message`.
- Added `tests/controller/test_kafka_app_security.py` to verify sanitization of error messages.
- Formatted code with Ruff to comply with CI checks.
- Updated `.jules/sentinel.md` with new security learning.

Co-authored-by: lgcorzo <46710567+lgcorzo@users.noreply.github.com>
@lgcorzo lgcorzo closed this Feb 6, 2026
@lgcorzo lgcorzo deleted the sentinel/fix-exception-leak-kafka-11752223050906537951 branch February 6, 2026 15:49
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