Potential fix for code scanning alert no. 5: Information exposure through a stack trace#206
Open
Potential fix for code scanning alert no. 5: Information exposure through a stack trace#206
Conversation
…ough a stack trace Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/stripe/sync-engine/security/code-scanning/5
To fix the problem, the stack trace and other low-level error details should no longer be returned to the client. Instead, the server should log the full error (including
err.stack) and send back a generic, high-level error message. This preserves debuggability while preventing remote callers from learning about internal structure.Concretely, in
packages/sync-engine/src/supabase/edge-functions/sigma-data-worker.ts:catchblock aroundpostgres(dbUrl, ...)(lines 38–50), replace thejsonResponsebody so that it does not containdetailsorstack. Optionally log the error server-side withconsole.error.catchblock aroundStripeSync.create(...)(lines 84–95), likewise stop includingdetailsandstackin the JSON response, and optionally log the error.try/catch(lines 309–313), stop returning{ error: err.message, stack: err.stack }and instead return a generic message, while logging the full error including stack.No changes are needed in
packages/sync-engine/src/database/postgres.ts; the stack there is simply thrown and only becomes problematic when it is formatted into HTTP responses. We can use existingconsole.errorfor logging, so no new imports are required. Functionality from the client’s perspective remains the same in terms of status codes and high-level messages (still 500s, still indicate failure), but without leaking stack traces.Suggested fixes powered by Copilot Autofix. Review carefully before merging.