Skip to content

Conversation

@GitTimeraider
Copy link
Owner

Potential fix for https://github.com/GitTimeraider/Directadmin-Emailforwarder/security/code-scanning/2

To fix the problem, we should avoid returning the exception message (str(e)) in the API response. Instead, we should return a generic error message to the client, while logging the detailed error (including the stack trace) on the server for debugging purposes. This ensures that sensitive information is not leaked to the client, but developers can still diagnose issues using the server logs.

Specifically, in app/main.py, in the exception handler for the /api/forwarders GET endpoint (lines 133–140), remove the 'details': str(e) field from the JSON response. The server-side logging (print and traceback.print_exc()) can remain as-is.

No new imports or methods are required, as logging is already being done.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ough an exception

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@GitTimeraider GitTimeraider marked this pull request as ready for review August 5, 2025 11:06
@GitTimeraider GitTimeraider merged commit cadc785 into main Aug 5, 2025
4 of 5 checks passed
@GitTimeraider GitTimeraider deleted the alert-autofix-2 branch August 5, 2025 14:04
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.

2 participants