Skip to content

fix: avoid logging potentially sensitive request data - #4422

Merged
igor-kupczynski merged 1 commit into
mainfrom
minimize-sensitive-backend-logs
Jul 14, 2026
Merged

fix: avoid logging potentially sensitive request data#4422
igor-kupczynski merged 1 commit into
mainfrom
minimize-sensitive-backend-logs

Conversation

@igor-kupczynski

@igor-kupczynski igor-kupczynski commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Avoid logging request query strings and malformed payload contents.

See in-line comments for details

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hatchet-docs Ready Ready Preview, Comment Jul 14, 2026 5:31pm

Request Review

@github-actions github-actions Bot added the engine Related to the core Hatchet engine label Jul 14, 2026
@igor-kupczynski igor-kupczynski changed the title fix: avoid logging sensitive request data fix: avoid logging potentially sensitive request data 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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread api/v1/server/run/run.go
Int("status", statusCode).
Str("method", v.Method).
Str("uri", v.URI).
Str("uri", v.URIPath).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread pkg/repository/match.go

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar idea: don't log malformed payload bodies

@igor-kupczynski
igor-kupczynski marked this pull request as ready for review July 14, 2026 18:43
@igor-kupczynski
igor-kupczynski merged commit c30782f into main Jul 14, 2026
58 checks passed
@igor-kupczynski
igor-kupczynski deleted the minimize-sensitive-backend-logs branch July 14, 2026 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine Related to the core Hatchet engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants