cacti icon indicating copy to clipboard operation
cacti copied to clipboard

security(plugin-htlc-coordinator-besu): 500 responses expose raw exceptions and stack traces

Open malsomesh9 opened this issue 6 months ago • 0 comments

Summary

Two HTLC coordinator Besu endpoints expose internal exception details in HTTP 500 responses instead of returning a sanitized error payload.

Affected code

  • extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/own-htlc-endpoint.ts:104-109
  • extensions/cactus-plugin-htlc-coordinator-besu/src/main/typescript/web-services/counterparty-htlc-endpoint.ts:109-114

Details

OwnHtlcEndpoint#handleRequest() returns the raw caught exception object:

res.status(500).json({
  message: "Internal Server Error",
  error: ex,
});

CounterpartyHtlcEndpoint#handleRequest() returns ex?.stack || ex?.message, which can expose server-side stack traces to API clients.

res.status(500).json({
  message: "Internal Server Error",
  error: ex?.stack || ex?.message,
});

This creates an information disclosure risk and is inconsistent with safer patterns elsewhere in the repo that avoid reflecting raw exceptions back to callers.

Expected behavior

HTTP 500 responses should return a stable, sanitized error body such as:

{ "message": "Internal Server Error" }

or a bounded public error code/message that does not include stack traces or raw exception objects.

Suggested fix

  • Avoid serializing ex directly into the response body.
  • Avoid returning ex.stack to clients.
  • Keep full exception detail in server logs only.

malsomesh9 avatar May 04 '26 16:05 malsomesh9