Potential fix for code scanning alert no. 3: Information exposure through a stack trace#2
Merged
Merged
Conversation
…ough a stack trace Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
fwartner
marked this pull request as ready for review
March 18, 2026 08:51
fwartner
added a commit
that referenced
this pull request
Mar 18, 2026
Potential fix for code scanning alert no. 3: Information exposure through a stack trace
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/fwartner/clawd-office/security/code-scanning/3
To fix the issue, error responses should no longer include raw exception text derived from
e. Instead, the server should return a generic error message (for example,"Invalid request body"or"Internal server error") while logging the detailed error (including stack trace) on the server. This avoids leaking stack traces or internal error messages to clients while maintaining debuggability.The most localized and non‑disruptive change is to update each
catch (e) { json(res, 400, { error: String(e) }) }block to:e.stackwhen available.eore.stack.Because different routes correspond to different classes of errors, we can slightly tailor the generic messages without relying on the actual exception text. For example:
"Invalid request"or"Invalid request body"."Internal error".Concretely, in
server.mjs:json()unchanged; it is a generic helper and is not inherently unsafe.catch (e)at lines 382, 411, 448, 509, 576, 608, and 638 (and any similar ones in the omitted sections, if present) to:console.error('Descriptive context...', e)to log details.String(e)with a fixed, non‑sensitive message, e.g.,{ error: 'Invalid request body' }or{ error: 'Internal server error' }.No new methods or external libraries are necessary; we can rely on Node’s built‑in
console.error. This single pattern change removes the flow of stack‑trace‑derived data toJSON.stringify(data)while preserving existing API structure and status codes.Suggested fixes powered by Copilot Autofix. Review carefully before merging.