Security: Sanitize Lightspeed Core error responses - #3296
Conversation
Changed Packages
|
Jdubrick
left a comment
There was a problem hiding this comment.
1 small comment, rest looks good
|
/ok-to-test |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3296 +/- ##
=======================================
Coverage 53.98% 53.98%
=======================================
Files 2401 2402 +1
Lines 87397 87397
Branches 24196 24195 -1
=======================================
+ Hits 47179 47182 +3
+ Misses 38670 38667 -3
Partials 1548 1548
*This pull request uses carry forward flags. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
JslYoon
left a comment
There was a problem hiding this comment.
Overall looks good, although the sanitizeLcsError() function uses any for both errorBody and logger
parameters. We should add proper TypeScript types:
- logger should use the LoggerService type (already imported in types.ts from
@backstage/backend-plugin-api). - errorBody should have an interface that matches the LCS error response
structure (see the test mocks for examples of the shape). - for the function sanitizeLcsError lets capitalize the LCS bit.
If you can also address the SonarCloud analysis and failing CI after rebasing, I can take another look.
JslYoon
left a comment
There was a problem hiding this comment.
lgtm, make sure all other comments are address too before merging
Fixes information disclosure vulnerability where LCS error details were being forwarded directly to clients. Changes: - Add sanitizeLcsError() function to sanitize error responses - Update 4 endpoints to use sanitization - Enhance tests to verify internal details are not exposed
- Move sanitizeLCSError to utils.ts for reusability - Fix TypeScript types (use LoggerService, add LCSErrorResponse interface) - Capitalize LCS in function name - Fix failing test for conversation not found - Add unit tests for utils to improve coverage
Extract duplicated error handling pattern into a reusable helper function. This reduces duplication from 5.6% to under 3%.
- Add try/catch to handle cases where LCS doesn't return JSON - Type the response parameter properly instead of using any - Add tests for both JSON and non-JSON error responses
3fbd276 to
54d8a44
Compare
|
|
/lgtm |


Hey, I just made a Pull Request!
Fixes an information disclosure vulnerability where error responses from Lightspeed Core were leaking internal details to clients.
The issue:
When LCS returns errors, we were forwarding the full error message to clients, which could include model names, provider info, org IDs, stack traces, etc. Not great for security.
What I changed:
sanitizeLcsError()function that logs the full error server-side but only returns a generic message to the client/v1/feedback,/v1/query/interrupt,/v1/query, and/v2/conversations/:idExample:
Before:
{"error": "Error from lightspeed-core server: Model gpt-4-0613 failed with OpenAI API error: rate limit exceeded for organization org-abc123"}After:
{"error": "Error from lightspeed-core server while processing query"}Full error details are still logged on the server for debugging.
✔️ Checklist