status.php leaks exception stack trace in JSON response via exception-to-string cast #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
status.phppasses a caughtPDOExceptionobject directly tostrtok():strtok()expects a string, so PHP calls$e->__toString()which produces the full exception representation including: exception class, message (with DSN), file path, line number, and complete stack trace. Only the first line is returned — but that first line is the message containing the DSN (SQLSTATE[HY000] [2002] ... mysql:host=X;dbname=Y;port=Z).Location
status.php, lines 13–15 and 19–21Risk
Anyone who hits
/status.phpwhen the database is unreachable receives the database DSN in the JSON response. This endpoint is likely monitored externally or accessed publicly, directly revealing database infrastructure details.Suggested fix direction
Extract only the SQLSTATE code or a sanitized message:
$status = $e->getCode() . ": database unavailable";. Never pass exception objects to string functions intended for output.Severity
moderate
Found by
Automated audit by Claude Code