Skip to content

Improve error handling: Remove exception details from API responses #5286

@Pritz395

Description

@Pritz395

Summary

Multiple API endpoints are returning raw exception messages (str(e)) in JSON responses, which can leak internal system information. While not exposing credentials directly, this violates security best practices and can aid attackers in reconnaissance.

Problem

Exception messages in API responses can reveal:

  • Internal service URLs (e.g., ORD_SERVER_URL endpoints in network errors)
  • Library versions and dependencies (if present in error messages)
  • System architecture hints (service names, internal paths)
  • Implementation details (error handling patterns, validation logic)

Note: This does NOT expose API keys, passwords, or credentials directly. However, it's still an information disclosure issue that should be addressed as a defense-in-depth measure.

Affected Endpoints

website/views/repo.py (7 instances)

  • Lines 257, 275: AI summary generation errors
  • Line 297: Section refresh operation errors
  • Line 445: GitHub API error handling
  • Line 565: Repository add operation errors
  • Lines 629, 647: Command execution errors (also exposes error_type field)

website/views/bitcoin.py (1 instance)

  • Line 89: RequestException in pending transactions view (could expose ORD_SERVER_URL)

website/views/core.py (2 instances)

  • Lines 1552, 1554: Roadmap PR submission errors

website/views/organization.py (2 instances)

  • Lines 2881, 2884: Message creation stream errors

Example

Current behavior:
{
"status": "error",
"message": "Connection refused: http://internal-service:9001/send-bacon-tokens"
}What this reveals:

  • Internal service endpoint URL
  • Service port number
  • Service name/functionality

Recommended behavior:
{
"status": "error",
"message": "An error occurred while processing your request. Please try again later."
}## Recommended Fix

  1. Log full exception details server-side with logger.error(..., exc_info=True)
  2. Return generic, user-friendly error messages to clients
  3. Remove error_type field from error responses (lines 629, 647 in repo.py)

Impact

  • Severity: Low-Medium (Information Disclosure)
  • CVSS: ~3.1 (Low) - Information Exposure
  • Priority: Best Practice / Defense-in-Depth
  • Exploitability: Low (requires error conditions to trigger)

Additional Improvements Included

  • Fix TransactionManagementError logging in blt/middleware/ip_restrict.py (change from debug to warning level)
  • Make CVE query prefix case-insensitive in website/views/issue.py for better UX

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions