Skip to content

Potential fix for code scanning alert no. 78: Information exposure through an exception#14

Merged
Lexicoding-systems merged 1 commit intomainfrom
alert-autofix-78
Jan 10, 2026
Merged

Potential fix for code scanning alert no. 78: Information exposure through an exception#14
Lexicoding-systems merged 1 commit intomainfrom
alert-autofix-78

Conversation

@Lexicoding-systems
Copy link
Owner

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:

  1. In SignatureService.verify_signature (src/lexecon/security/signature_service.py), keep the existing behavior for InvalidSignature (this is an expected user-facing error), but change the generic except Exception as e handler to:

    • Log the full exception server-side (using the standard logging module).
    • Return a generic message like "Internal verification error" that does not contain str(e).
  2. In SignatureService, add a logging import and a module-level logger.

  3. 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_signature no 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 False with 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 of signature_service.py; the API handler in server.py can remain as is because it will now only relay safe messages.

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

…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>
@Lexicoding-systems Lexicoding-systems marked this pull request as ready for review January 8, 2026 15:50
@Lexicoding-systems Lexicoding-systems merged commit 8e4ffee into main Jan 10, 2026
6 of 42 checks passed
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.

1 participant