Skip to content

fix(#5442): hide internal exception details in dashboard health endpoint#5470

Closed
weilixiong wants to merge 1 commit into
Scottcjn:mainfrom
weilixiong:fix-5442-dashboard-error-leak
Closed

fix(#5442): hide internal exception details in dashboard health endpoint#5470
weilixiong wants to merge 1 commit into
Scottcjn:mainfrom
weilixiong:fix-5442-dashboard-error-leak

Conversation

@weilixiong
Copy link
Copy Markdown
Contributor

Fix #5442\n\nReplaced str(e) with generic "unavailable" messages in dashboard health endpoint.\n\nFiles: bridge/dashboard_api.py (3 occurrences)

@github-actions github-actions Bot added the BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) label May 16, 2026
@weilixiong
Copy link
Copy Markdown
Contributor Author

@Scottcjn New error leak fix ready for review. Same pattern as the other PRs.

@github-actions github-actions Bot added the size/S PR: 11-50 lines label May 16, 2026
Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@kekehanshujun kekehanshujun left a comment

Choose a reason for hiding this comment

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

LGTM. I verified the health endpoint no longer returns raw exception text for the database, Solana RPC, or mint-account checks, while preserving the existing health response shape and component status behavior.

Validation run on the PR diff:

  • python -m py_compile bridge/dashboard_api.py
  • python -m pytest bridge/test_dashboard_api.py -q --tb=short -> 22 passed

I also confirmed the three previous str(e) detail paths now return generic unavailable messages.

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown

@ZacharyZhang-NY ZacharyZhang-NY left a comment

Choose a reason for hiding this comment

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

Requesting changes on head 788e3719867cc24d59eb5185a7c0fdc055613ad1.

Validation performed:

  • git diff --check origin/main...review-pr-5470 -- bridge/dashboard_api.py
  • python -B -m py_compile bridge/dashboard_api.py bridge/test_dashboard_api.py
  • python -B -m pytest -q bridge/test_dashboard_api.py --confcutdir=<temp> -> 22 passed
  • source check for logger.exception, logging.getLogger, and generic health detail strings

The client-facing redaction part is moving in the right direction, but the linked #5442 report explicitly calls for regression tests for the three leak paths and server-side logging of the original exceptions. This PR only changes the response strings in bridge/dashboard_api.py; it adds no coverage for the database/RPC/mint leak cases and leaves no server-side logger.exception(...) path for operators.

Please add focused tests that force failures for the database check, Solana RPC check, and mint check, assert that secret-bearing exception text is absent from the response, and log the caught exceptions server-side while returning generic details to clients.

@BossChaos
Copy link
Copy Markdown
Contributor

Code Review — Bounty #73

PR: fix(#5442): hide internal exception details in dashboard health endpoint by @weilixiong
Files changed: 1 (+6/-6)

  • ✅ Bug fix or input validation
  • ✅ Error handling present

Summary

This is a bug fix PR. Changes appear consistent with project patterns.

Wallet: 0xdaE5d307339074A24F579dB48e7c639359D94904

Reviewing under Bounty #73 — Code Review Bounty Program

@weilixiong
Copy link
Copy Markdown
Contributor Author

Thanks for the review @BossChaos! Will address any suggestions.

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown

@TJCurnutte TJCurnutte left a comment

Choose a reason for hiding this comment

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

Approved. I reviewed the dashboard health exception handling in bridge/dashboard_api.py.

Validation proof:

git diff --check origin/main...HEAD -- bridge/dashboard_api.py
PYTHONPYCACHEPREFIX=/tmp/rustchain-pycache-5470 python3 -B -m py_compile bridge/dashboard_api.py
PYTHONPATH=. uv run --no-project --with pytest --with flask --with flask-cors --with requests python -B -m pytest -q -o addopts='' bridge/test_dashboard_api.py --noconftest -p no:cacheprovider

Results: git diff --check passed, py_compile passed, and the focused dashboard API suite passed with 22 passed in 1.75s.

I also ran a Flask test-client probe for /bridge/dashboard/health with get_db() forced to raise a private SQLite/path/password string and urllib.request.urlopen() forced to raise a private Solana RPC/token/keypair string, with WRTC_MINT_ADDRESS configured so the mint-check branch executed too. The response stayed HTTP 200/degraded and returned only the generic detail values:

{
  "rustchain": "Database error: unavailable",
  "solana_rpc": "RPC error: unavailable",
  "wrtc_mint": "Mint check error: unavailable"
}

The response body did not reflect the injected super-secret, private paths, keypair filename, or RPC URL. That covers all three changed exception paths while preserving the health endpoint contract.

Copy link
Copy Markdown
Contributor

@508704820 508704820 left a comment

Choose a reason for hiding this comment

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

Hide internal exception details in dashboard. Good - dashboard errors often leak DB queries, internal IPs, and service versions. Verify all dashboard error handlers follow this pattern. - Xeophon (security review)

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Copy Markdown
Contributor

@HCIE2054 HCIE2054 left a comment

Choose a reason for hiding this comment

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

LGTM!

@508704820
Copy link
Copy Markdown
Contributor

Security Review ✅

Same class as #5545/#5482: hide internal exception details in dashboard health endpoint. Logs server-side, returns generic error.

Reviewed by Xeophon - Solana: Lt9nERv6VHsojw15LpFeiaabuphAggzfLF9sM9UXRrZ

@Scottcjn
Copy link
Copy Markdown
Owner

Closing as duplicate of #5443 by @hungle123-dev (first-posted 4h earlier on the same issue).

Per first-poster rule, only the original submitter gets bounty credit on a given issue. The fix in #5443 addresses the same root cause and is already under review.

Appreciate the effort — for next time, please check open PRs against the same issue before filing. Thanks for the contribution.

@Scottcjn Scottcjn closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BCOS-L1 Beacon Certified Open Source tier BCOS-L1 (required for non-doc PRs) size/S PR: 11-50 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Dashboard health leaks internal component exception details

8 participants