Potential fix for code scanning alert no. 78: Information exposure through an exception#14
Merged
Lexicoding-systems merged 1 commit intomainfrom Jan 10, 2026
Merged
Conversation
…rough an exception Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Lexicoding <234111021+Lexicoding-systems@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/Lexicoding-systems/Lexecon/security/code-scanning/78
In general, the fix is to stop returning raw exception messages (or stack traces) to the client and instead return generic, non-sensitive messages while logging detailed errors on the server. The verification result should distinguish only between expected validation failures (like invalid signature) and unexpected internal errors, without exposing internal exception text.
The best minimal fix here is:
In
SignatureService.verify_signature(src/lexecon/security/signature_service.py), keep the existing behavior forInvalidSignature(this is an expected user-facing error), but change the genericexcept Exception as ehandler to:loggingmodule)."Internal verification error"that does not containstr(e).In
SignatureService, add aloggingimport and a module-level logger.Optionally (but not strictly required for the specific CodeQL path), we could later adjust the FastAPI endpoint to further normalize user-facing messages, but once
verify_packet_signatureno longer embeds raw exception details, the current endpoint implementation is safe enough.This preserves existing functionality in terms of boolean validity results and high-level error semantics: callers still receive
Falsewith a message when verification fails, but the message no longer leaks internal exception details for unexpected errors. The only code changes are within the shown snippet ofsignature_service.py; the API handler inserver.pycan remain as is because it will now only relay safe messages.Suggested fixes powered by Copilot Autofix. Review carefully before merging.