Remove redundant/potentially sensitive @backtrace_string from log message

Created on 12 December 2022, about 2 years ago
Updated 9 September 2023, over 1 year ago

Problem/Motivation

Sentry may receive both a backtrace array and a log message containing @backtrace_string - the latter is redundant. We could remove @backtrace_string from the log message.

Steps to reproduce

Trigger a php warning, etc. and observe the backtrace.

Proposed resolution

Remove @backtrace_string from the log message and context before processing.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    29 pass
  • πŸ‡©πŸ‡°Denmark xen

    Taking the liberty of upgrading this to major, as this can potentially leak sensitive information to Sentry, as Exception::getTraceAsString() includes string parameters in the backtrace.

    I've re-rolled against the latest version and taken further liberty in removing the configuration option. As far as I can tell, Sentry/Raven always produces their own backtrace, which can be configured to include parameter values or not, so the backtrace in the message is redundant and fills up the issue page at Sentry pushing the nicer looking native backtrace down.

    No interdiff as 3326662-3 doesn't apply to HEAD.

  • πŸ‡©πŸ‡°Denmark xen
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    I don't really like forcibly messing with everyone's $message and $context, but I'd agree it's simpler and safer to remove it without adding configuration.

    It looks like in core, @backtrace_string appears as %type: @message in %function (line %line of %file) @backtrace_string. so how about removing the string @backtrace_string such that the end result would be %type: @message in %function (line %line of %file).?

    By the way, as a workaround for this issue, you should be able to enable zend.exception_ignore_args in your php environment to ignore args completely, or set zend.exception_string_param_max_len to zero.

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    29 pass
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    Fixed the str_replace() to remove the space before period and tweaked the comment a bit.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco
    • mfb β†’ committed 53f50cf0 on 4.x
      Issue #3326662 by mfb, Xen: Remove redundant/potentially sensitive @...
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.1.x + Environment: PHP 8.2 & MySQL 8
    last update over 1 year ago
    29 pass
    • mfb β†’ committed 14b8131d on 3.x
      Issue #3326662 by mfb, Xen: Remove redundant/potentially sensitive @...
  • Status changed to Fixed over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco
  • πŸ‡©πŸ‡°Denmark xen

    @mfb

    Nice, but there's a related problem: the feature that collects log messages produced in the request and add them to the issue still get the old trace. The PHP options that you mention should be able to take care of this, but it means that this fix is half baked. Should it (and can we) clean the log messages too? If the PHP options is needed to clean the log messages this fix is sorta redundant. I think raven should either fix both, or instruct users to set the options instead.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    @Xen there is already code that cleans the stacktrace. Although likely it's not good enough - I tested it quite some time ago with stacktraces for exceptions, but need to verify it works, and maybe it doesn't work on other events (php warnings, etc. have one too, provided by drupal core, and sentry creates one for events that don't otherwise have one)

    If you have a chance maybe you can open a new issue with reproduce code.

  • Automatically closed - issue fixed for 2 weeks with no activity.

  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡°Denmark xen

    Sorry for the late response, I've had some issues with notifications.

    I've updated to the latest version and I'll see how it looks.

Production build 0.71.5 2024