Skip to content

Fix stack trace / exception detail exposure in Flask API error responses - #34

Merged
Pmaster-dev merged 4 commits into
developfrom
copilot/fix-code-scanning-alert-27
Aug 3, 2026
Merged

Fix stack trace / exception detail exposure in Flask API error responses#34
Pmaster-dev merged 4 commits into
developfrom
copilot/fix-code-scanning-alert-27

Conversation

Copilot AI commented Aug 2, 2026

Copy link
Copy Markdown

CodeQL alert #27 (py/stack-trace-exposure, CWE-209/497): raw exception details were being serialized into HTTP error responses, leaking internal implementation information to callers.

Changes — Services/asl_model_training_hub/flask_app/app.py

  • Replace all str(e) / e.stderr values in user-facing JSON message fields with static, generic strings
  • Server-side logger.error(...) calls are untouched — full exception detail remains in logs
# Before — leaks internals
except Exception as e:
    logger.error(f"Error in start_model: {str(e)}")
    return jsonify({"status": "error", "message": str(e)}), 500

# After — safe
except Exception as e:
    logger.error(f"Error in start_model: {str(e)}")
    return jsonify({"status": "error", "message": "An internal error occurred"}), 500

Affected handlers: list_models, start_model (×2), stop_model, run_inference (×2).

Copilot AI changed the title [WIP] Fix code scanning alert #27 Fix stack trace / exception detail exposure in Flask API error responses Aug 2, 2026
Copilot AI requested a review from Pmaster-dev August 2, 2026 16:53
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@Pmaster-dev
Pmaster-dev marked this pull request as ready for review August 3, 2026 04:21
Copilot AI review requested due to automatic review settings August 3, 2026 04:21
@Pmaster-dev
Pmaster-dev merged commit 9a66fe0 into develop Aug 3, 2026
11 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR mitigates information disclosure in the ASL Model Training Hub Flask API by removing raw exception details from JSON error responses, addressing a CodeQL finding for stack trace/exception detail exposure.

Changes:

  • Replace user-facing message fields that previously included str(e) with static, generic error strings.
  • Remove e.stderr from the inference error response body while keeping detailed server-side logging intact.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants