Skip to content

Bug: server_proxy.py returns JSON parsing error on non-JSON upstream responses #1996

@RavMonSOL

Description

@RavMonSOL

Severity: Low (5 RTC)

Description

The Flask proxy at server_proxy.py unconditionally calls response.json() on the upstream response. If the upstream (localhost:8088) returns non-JSON (e.g., HTML error page, plain text), response.json() raises JSONDecodeError and the proxy returns a 500, obscuring the original error.

Code location

# server_proxy.py
@app.route('/api/<path:path>', methods=['GET', 'POST'])
def proxy(path):
    ...
    resp = requests.post(url, ...)  # or get
    return resp.json(), resp.status_code  # <-- unsafe

Impact

  • Proxy hides upstream errors
  • Crashes when upstream returns non-JSON (e.g., 500 HTML)

Fix

Check Content-Type header before parsing JSON; fall back to resp.text and set Content-Type accordingly.


Bug report for bounty #305. Wallet: RTC3fcd93a4ec68cfd6b59d1b41c4872c5c239c4ad8

Metadata

Metadata

Assignees

No one assigned

    Labels

    securitySecurity-related change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions