fix: avoid logging potentially sensitive request data - #4422
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
igor-kupczynski
commented
Jul 14, 2026
Comment on lines
146
to
+186
| @@ -186,12 +182,8 @@ func (w *V1WebhooksService) V1WebhookReceive(ctx echo.Context, request gen.V1Web | |||
| } else { | |||
| err := json.Unmarshal(rawBody, &payloadMap) | |||
| if err != nil { | |||
| bodyPreview := string(rawBody) | |||
| if len(bodyPreview) > 200 { | |||
| bodyPreview = bodyPreview[:200] + "..." | |||
| } | |||
| errorMsg := "Failed to unmarshal request body as JSON" | |||
| w.config.Logger.Info().Err(err).Str("webhook", webhookName).Str("tenant", tenantId.String()).Str("content_type", contentType).Int("body_length", len(rawBody)).Str("body_preview", bodyPreview).Msg(errorMsg) | |||
| w.config.Logger.Info().Err(err).Str("webhook", webhookName).Str("tenant", tenantId.String()).Str("content_type", contentType).Int("body_length", len(rawBody)).Msg(errorMsg) | |||
Contributor
Author
There was a problem hiding this comment.
Currently, when a webhook form-encoded payload contains invalid JSON, we log its first 200 characters.
I remove it here, in case there are any sensitive data in the malformed JSON. What is still logged is:
- Parse error
- Webhook and tenant
- Payload length
igor-kupczynski
commented
Jul 14, 2026
| Int("status", statusCode). | ||
| Str("method", v.Method). | ||
| Str("uri", v.URI). | ||
| Str("uri", v.URIPath). |
Contributor
Author
There was a problem hiding this comment.
It changes URI to URIPath which in practice drops the query parameters from the request log:
Before: /.../foo?code=abc123&state=xyz
After: /.../foo
The idea being that e.g. oauth callbacks may contain semi-sensitive values
igor-kupczynski
commented
Jul 14, 2026
|
|
||
| if err != nil { | ||
| m.l.Warn().Ctx(ctx).Err(err).Msgf("failed to unmarshal user event data %s", string(event.Data)) | ||
| m.l.Warn().Ctx(ctx).Err(err).Msgf("failed to unmarshal user event data. id: %s, key: %s", event.ID, event.Key) |
Contributor
Author
There was a problem hiding this comment.
Similar idea: don't log malformed payload bodies
igor-kupczynski
marked this pull request as ready for review
July 14, 2026 18:43
grutt
approved these changes
Jul 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Avoid logging request query strings and malformed payload contents.
See in-line comments for details