Skip to content

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

Merged
BetterMint merged 1 commit intomainfrom
alert-autofix-22
Dec 15, 2025
Merged

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

Conversation

@BetterMint
Copy link
Owner

Potential fix for https://github.com/BetterMint/BetterMITM/security/code-scanning/22

To fix the issue, avoid returning raw exception details (e.g., str(e)) to the web client. Instead, return only neutral, generic error messages (such as "Internal server error" or "Script execution failed"), and log the actual exception details on the server side for diagnostic purposes. This approach keeps detailed debug information out of the hands of potential attackers while still making it available for developers/maintainers.

Required steps:

  • In BetterMITM/addons/web_script_executor.py:

    • In every place where an exception is caught and str(e) is included in the returned dictionary (lines 164, 288, and 327), replace this with a fixed string like "Internal server error" or "Script execution failed".
    • Also, ensure the actual exception details are logged on the server (logger.error(...)), which is already done at least on line 163.
  • In BetterMITM/tools/web/app.py:

    • No change to direct subprocess or exec exception catches is needed for this alert, but the place where result is written to the client (line 1509) should be reviewed. After the fix in the script executor, result cannot contain dangerous exception details.

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


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>
@BetterMint BetterMint marked this pull request as ready for review December 15, 2025 01:39
@BetterMint BetterMint merged commit ed569f3 into main Dec 15, 2025
12 of 47 checks passed
@BetterMint BetterMint deleted the alert-autofix-22 branch December 15, 2025 12:10
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