Skip to content

[Bug] Webhook URLs are logged in full on any non-success response, and they contain the auth token #45

Description

@egg82

What happened?

A Discord webhook URL is a credential - the trailing path segment is the token that authorises posting to that channel. parseResponse logs the whole URL whenever the send fails:

Webhook/src/main/java/me/egg82/fwebhook/internal/api/webhook/AbstractWebhookDestination.java:162

logger.warn("Got non-success response (code {}) for URL {}: {}",
        response.getStatus(), response.getRequestSummary().getUrl(), response.getBody());

Same on lines 163 and 168.

Real output from a running instance, redacted here:

[WARN] Got non-success response (code 400) for URL
  https://discord.com/api/webhooks/1487200889859997746/<TOKEN IN CLEARTEXT>: {"embeds": ["0"]}

That instance logged it 13 times in one pod lifetime. Anyone with read access to the logs - or to whatever aggregates them - can post to the channel.

What did you expect to happen?

The failure is logged with enough context to debug it, without the credential. The webhook's configured id/name, the status code and the response body are the useful parts; the token isn't.

Steps to reproduce

Configure a Discord webhook, cause any non-2xx response (an over-long embed field will do it), read the log.

Notes

Worth checking the other two call sites at the same time - getParsingError on 163 and the null-body warning on 168 both log the same URL.

Notifiarr's passthrough endpoint takes its key in a header rather than the URL, so this is Discord-shaped specifically, but the fix is the same in parseResponse for both.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions