Skip to content

fix(core,webapp): redact sensitive fields in logs by default and cap their size - #4401

Open
carderne wants to merge 5 commits into
mainfrom
fix/logger-redaction-sec-410
Open

fix(core,webapp): redact sensitive fields in logs by default and cap their size#4401
carderne wants to merge 5 commits into
mainfrom
fix/logger-redaction-sec-410

Conversation

@carderne

@carderne carderne commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary

Structured logs now redact common credential and sensitive-data fields by
default, including nested values and error metadata. Long strings and arrays
are capped so a single log entry cannot grow without bound.

The same redaction applies to error-reporting extras. Unchanged values retain
their existing references, avoiding unnecessary cloning on ordinary log calls.

…their size

The Logger used to only redact keys a caller explicitly listed, and most
call sites listed none. It now applies a default set of sensitive key
names (tokens, passwords, api keys, payloads, headers, email, and more)
to every log line, matched case-insensitively and recursively, no matter
how many arguments a log call passes. String values shaped like a bearer
token or API key are redacted even under an unlisted key.

Logged errors now run their message, stack and metadata through the same
redaction and size limits as the rest of the line, instead of being copied
through untouched. Long strings and large arrays are truncated with a
marker instead of written out in full.

The webapp's Sentry reporting now applies the same redaction to the extra
data it sends, so a field that gets filtered on stdout is filtered on its
way to Sentry too.
@changeset-bot

changeset-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: fb88613

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@trigger.dev/core Patch
@trigger.dev/build Patch
trigger.dev Patch
@trigger.dev/python Patch
@trigger.dev/redis-worker Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/llm-model-catalog Patch
@trigger.dev/rbac Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/run-store Patch
@internal/schedule-engine Patch
@trigger.dev/sso Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/tsql Patch
@internal/dashboard-agent Patch
@internal/sdk-compat-tests Patch
@trigger.dev/react-hooks Patch
@trigger.dev/rsc Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The logging system now applies default and caller-provided key filtering, secret-pattern detection, string and array truncation, and recursion limits. Structured errors use the same redaction pipeline for messages, stacks, metadata, and nested errors. The webapp’s Sentry error-reporting path redacts flattened log arguments before sending exception or message payloads. Tests cover logger output, the standalone redact helper, structured errors, and Sentry payloads.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only includes a summary and omits required template sections like Closes #issue, checklist, testing, changelog, and screenshots. Add the missing template sections, including Closes #issue, checklist items, testing steps, changelog, and screenshots if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: default redaction and log size limits in core/webapp logging.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/logger-redaction-sec-410

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]

This comment was marked as resolved.

@pkg-pr-new

pkg-pr-new Bot commented Jul 28, 2026

Copy link
Copy Markdown

Open in StackBlitz

@trigger.dev/build

npm i https://pkg.pr.new/@trigger.dev/build@fb88613

trigger.dev

npm i https://pkg.pr.new/trigger.dev@fb88613

@trigger.dev/core

npm i https://pkg.pr.new/@trigger.dev/core@fb88613

@trigger.dev/python

npm i https://pkg.pr.new/@trigger.dev/python@fb88613

@trigger.dev/react-hooks

npm i https://pkg.pr.new/@trigger.dev/react-hooks@fb88613

@trigger.dev/redis-worker

npm i https://pkg.pr.new/@trigger.dev/redis-worker@fb88613

@trigger.dev/rsc

npm i https://pkg.pr.new/@trigger.dev/rsc@fb88613

@trigger.dev/schema-to-json

npm i https://pkg.pr.new/@trigger.dev/schema-to-json@fb88613

@trigger.dev/sdk

npm i https://pkg.pr.new/@trigger.dev/sdk@fb88613

commit: fb88613

@carderne
carderne marked this pull request as ready for review July 28, 2026 09:59
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Primary log message is redacted inconsistently between the two loggers

In Logger.#structuredLog (packages/core/src/logger.ts:121-134) the primary message argument is placed directly into the structured log and never passed through filterKeys, so a secret embedded in the message string itself (e.g. logger.info("token tr_live_...")) is logged verbatim. In contrast, SimpleStructuredLogger.#structuredLog (packages/core/src/v3/utils/structuredLogger.ts:95-102) wraps the whole object — including message — in redact, so its primary message IS redacted. This is an inconsistency between the two loggers. Only the structured $message (from an args message key) and error message/stack/metadata are redacted in Logger. Not flagged as a bug because the pre-existing behavior for the primary message was also unredacted and the PR focuses on structured fields, but worth confirming it matches intent.

(Refers to line 127)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +21 to 30
const extra = redact(flattenArgs(args), SENTRY_EXTRA_FILTERED_KEYS) as Record<string, unknown>;

if (error) {
captureException(error, {
captureException(redactError(error), {
extra: {
message,
...flattenArgs(args),
...extra,
},
});
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔍 Captured Sentry extra still carries the raw Error object

On the captureException path in apps/webapp/app/services/logger.server.ts:23-30, extra is built from redact(flattenArgs(args), ...), which still contains the original error key (an Error instance). redact leaves the Error mostly untouched (Error message/stack are non-enumerable, so Object.entries yields nothing and the instance is returned unchanged). While the captured exception itself is redacted via redactError, the error entry inside extra is the un-redacted Error. In practice JSON.stringify(Error) serializes to {}, so the message/stack usually don't leak through the extra field, but Sentry's own serialization of Error objects could differ. Worth confirming Sentry doesn't surface the raw message/stack via the extra payload.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant