WP Manifestindependent plugin directory
manifest / developer / sentry-integration

Sentry Integration WP Registry grade B-. Medium-severity findings · 3 findingsWP RegistryMedium-severity findings · 3 findingsOpen the reportB-

WordPress Sentry Integration Plugin

★ 10stars
5.6kcomposer installs
2.1.0latest · 8 years ago

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/itgalaxy/sentry-integration/archive/refs/heads/master.zip

On Packagist as itgalaxy/sentry-integration:

composer require itgalaxy/sentry-integration
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Sentry Integration

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

A (unofficial) WordPress plugin to report PHP, JavaScript and security headers (Expect-CT and X-XSS-Protection) errors to Sentry.

Introduction

This plugin can report PHP errors (optionally), JavaScript errors (optionally) and security headers (Expect-CT and X-XSS-Protection) (optionally) to Sentry and integrates with its release tracking.

It will auto detect authenticated users and add context where possible. All context/tags can be adjusted using filters mentioned below.

Usage

  1. Install this plugin by cloning or copying this repository to your wp-contents/plugins folder
  2. Configure your DSN as explained below
  3. Activate the plugin through the WordPress admin interface

Note: this plugin does not do anything by default and has no admin interface. A DSN must be configured first.

Configuration

PHP tracker

Track PHP errors by adding this snippet to your wp-config.php and replace ADDRESS_YOUR_DSN with your actual DSN that you find in Sentry:

define('SENTRY_INTEGRATION_DSN', 'ADDRESS_YOUR_DSN');
// Example `ADDRESS_YOUR_DSN` value - https://1fbf25e90f114a3d83a19aa4fa432dcf:3c13a039710e4287900bc71552b1e268@sentry.io/1

Note: Do not set this constant to disable the PHP tracker.


(Optionally) Set the error types the PHP tracker will track:

define(
  'SENTRY_INTEGRATION_ERROR_TYPES',
  E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_USER_DEPRECATED
);

JavaScript tracker

Track JavaScript errors by adding this snippet to your wp-config.php and replace PUBLIC_ADDRESS_YOUR_DSN with your actual public DSN that you find in Sentry (never use your private DSN):

define('SENTRY_INTEGRATION_PUBLIC_DSN', 'PUBLIC_ADDRESS_YOUR_DSN');
// Example `PUBLIC_ADDRESS_YOUR_DSN` value - https://1fbf25e90f114a3d83a19aa4fa432dcf@sentry.io/1

Note: Do not set this constant to disable the JavaScript tracker.


(Optionally) You can control how plugin should register and enqueue sentry JavaScript script (i.e. raven.min.js):

define('SENTRY_INTEGRATION_PUBLIC_DSN_ENQUEUE_MODE', 'manual');

There are 3 values for SENTRY_INTEGRATION_PUBLIC_DSN_ENQUEUE_MODE constant.

  1. inline (by default for better performance and avoid problems with order scripts from other plugins/themes) - print inline script and configuration in head html tag.
  2. standard - use standard WordPress api for scripts (i.e. using wp_register_script, wp_enqueue_script and wp_add_inline_script functions on wp_enqueue_scripts, login_enqueue_scripts and admin_enqueue_scripts actions).
  3. manual - don't register and enqueue script and configuration. You should manually register and enqueue sentry JavaScript script with configuration.

Expect-CT header tracker

Track Expect-CT header errors by adding this snippet to your wp-config.php and replace ADDRESS_YOUR_DSN with your actual DSN that you find in Sentry:

define('SENTRY_INTEGRATION_EXPECT_CT_DSN', 'ADDRESS_YOUR_DSN');
// Example `ADDRESS_YOUR_DSN` value - https://1fbf25e90f114a3d83a19aa4fa432dcf@sentry.io/1

Note: Do not set this constant to disable the Expect-CT tracker. Note: You should send Expect-CT header with report-uri="http://you-site.com/sentry-integration/expect-ct/report/" using .htaccess, php or another prefer method. See more about Expect-CT header.

X-XSS-Protection tracker

Track X-XSS-Protection header errors by adding this snippet to your wp-config.php and replace ADDRESS_YOUR_DSN with your actual DSN that you find in Sentry:

define('SENTRY_INTEGRATION_X_XSS_PROTECTION_DSN', 'ADDRESS_YOUR_DSN');
// Example `ADDRESS_YOUR_DSN` value - https://1fbf25e90f114a3d83a19aa4fa432dcf@sentry.io/1

Note: Do not set this constant to disable the X-XSS-Protection tracker. Note: You should send X-XSS-Protection header with report="http://you-site.com/sentry-integration/x-xss-protection/report/" using .htaccess, php or another prefer method. See more about X-XSS-Protection header.

Common configuration for all trackers

(Optionally) Define a version of your site; by default the theme version will be used. This is used for tracking at which version of your site the error occurred. When combined with release tracking this is a very powerful feature.

define('SENTRY_INTEGRATION_VERSION', 'v2.1.3');

(Optionally) Define an environment of your site. Defaults to unspecified.

define('SENTRY_INTEGRATION_ENV', 'production');

Note: By default SENTRY_INTEGRATION_VERSION constant contains wp_get_theme()->get('Version') result.

Filters

This plugin provides the following filters to plugin/theme developers.

Please note that some filters are fired when the Sentry trackers are initialized so they won't fire if you define them in you theme or in a plugin that loads after Sentry Integration does.

For PHP, JavaScript, Expect-CT and X-XSS-Protection trackers

sentry_integration_user_context (array)

You can use this filter to extend the Sentry user context for both PHP, JS and security headers trackers.

WARNING: These values are exposed to the public in the JS tracker, so make sure you do not expose anything private!

Example usage:

/**
 * Customize sentry user context.
 *
 * @param array $user The current sentry user context.
 *
 * @return array
 */
function customize_sentry_user_context(array $user)
{
  return array_merge($user, array(
    'a-custom-user-meta-key' => 'custom value'
  ));
}

add_filter('sentry_integration_user_context', 'customize_sentry_user_context');

Note: _This filter fires on the WordPress set_current_user action._

Specific to PHP tracker

sentry_integration_dsn (string)

You can use this filter to override the Sentry DSN used for the PHP tracker.

Example usage:

/**
 * Customize sentry dsn.
 *
 * @param string $dsn The current sentry public dsn.
 *
 * @return string
 */
function customize_sentry_dsn($dsn)
{
  return 'https://<key>:<secret>@sentry.io/<project>';
}

add_filter('sentry_integration_dsn', 'customize_sentry_dsn');

Note: _This filter fires on when Sentry Integration initializes and after the WP after_setup_theme._


sentry_integration_options (array)

You can use this filter to customize the Sentry options used to initialize the PHP tracker.

Example usage:

/**
 * Customize sentry options.
 *
 * @param array $options The current sentry options.
 *
 * @return array
 */
function customize_sentry_options(array $options)
{
  return array_merge($options, array(
    'tags' => array(
      'my-custom-tag' => 'custom value'
    )
  ));
}

add_filter('sentry_integration_options', 'customize_sentry_options');

Note: _This filter fires on when Sentry Integration initializes and after the WP after_setup_theme._


sentry_integration_send_data (array|bool)

Provide a function which will be called before Sentry PHP tracker sends any data, allowing you both to mutate that data, as well as prevent it from being sent to the server.

Example usage:

/**
 * Customize sentry send data.
 *
 * @param array $data The sentry send data.
 *
 * @return array|bool Return the data array or false to cancel the send operation.
 */
function filter_sentry_send_data(array $data)
{
  $data['tags']['my_custom_key'] = 'my_custom_value';

  return $data;
}

add_filter('sentry_integration_send_data', 'filter_sentry_send_data');

Note: This filter fires whenever the Sentry SDK is sending data to the Sentry server.

Specific to JavaScript tracker

sentry_integration_public_dsn (string)

You can use this filter to override the Sentry DSN used for the JS tracker.

WARNING: This value is exposed to the public, so make sure you do not use your private DSN!

Example usage:

/**
 * Customize public sentry dsn.
 *
 * @param string $dsn The current sentry public dsn.
 *
 * @return string
 */
function customize_public_sentry_dsn($dsn)
{
  return 'https://<key>@sentry.io/<project>';
}

add_filter('sentry_integration_public_dsn', 'customize_public_sentry_dsn');

sentry_integration_public_options (array)

You can use this filter to customize/override the sentry options used to initialize the JS tracker.

WARNING: These values are exposed to the public, so make sure you do not expose anything private !

Example usage:

/**
 * Customize public sentry options.
 *
 * @param array $options The current sentry public options.
 *
 * @return array
 */
function customize_public_sentry_options(array $options)
{
  return array_merge($options, array(
    'tags' => array(
      'custom-tag' => 'custom value'
    )
  ));
}

add_filter(
  'sentry_integration_public_options',
  'customize_sentry_public_options'
);

Specific to Expect-CT tracker

sentry_integration_expect_ct_dsn (string)

You can use this filter to override the Sentry DSN used for the Expect-CT tracker.

Example usage:

/**
 * Customize sentry dsn.
 *
 * @param string $dsn The current sentry public dsn.
 *
 * @return string
 */
function customize_sentry_dsn($dsn)
{
  return 'https://<key>:<secret>@sentry.io/<project>';
}

add_filter('sentry_integration_expect_ct_dsn', 'customize_sentry_dsn');

Note: _This filter fires on when Sentry Integration initializes and after the WP after_setup_theme._


sentry_integration_expect_ct_options (array)

You can use this filter to customize the Sentry options used to initialize the Expect-CT tracker.

Example usage:

/**
 * Customize sentry options.
 *
 * @param array $options The current sentry options.
 *
 * @return array
 */
function customize_sentry_options(array $options)
{
  return array_merge($options, array(
    'tags' => array(
      'my-custom-tag' => 'custom value'
    )
  ));
}

add_filter('sentry_integration_expect_ct_options', 'customize_sentry_options');

Note: _This filter fires on when Sentry Integration initializes and after the WP after_setup_theme._


sentry_integration_expect_ct_send_data (array|bool)

Provide a function which will be called before Sentry Expect-CT tracker sends any data, allowing you both to mutate that data, as well as prevent it from being sent to the server.

Example usage:

/**
 * Customize sentry send data.
 *
 * @param array $data The sentry send data.
 *
 * @return array|bool Return the data array or false to cancel the send operation.
 */
function filter_sentry_send_data(array $data)
{
  $data['tags']['my_custom_key'] = 'my_custom_value';

  return $data;
}

add_filter('sentry_integration_expect_ct_send_data', 'filter_sentry_send_data');

Note: This filter fires whenever the Sentry SDK is sending data to the Sentry server.

Specific to X-XSS-Protection tracker

sentry_integration_x_xss_protection_dsn (string)

You can use this filter to override the Sentry DSN used for the X-XSS-Protection tracker.

Example usage:

/**
 * Customize sentry dsn.
 *
 * @param string $dsn The current sentry public dsn.
 *
 * @return string
 */
function customize_sentry_dsn($dsn)
{
  return 'https://<key>:<secret>@sentry.io/<project>';
}

add_filter('sentry_integration_x_xss_protection_dsn', 'customize_sentry_dsn');

Note: _This filter fires on when Sentry Integration initializes and after the WP after_setup_theme._


sentry_integration_x_xss_protection_options (array)

You can use this filter to customize the Sentry options used to initialize the Expect-CT tracker.

Example usage:

/**
 * Customize sentry options.
 *
 * @param array $options The current sentry options.
 *
 * @return array
 */
function customize_sentry_options(array $options)
{
  return array_merge($options, array(
    'tags' => array(
      'my-custom-tag' => 'custom value'
    )
  ));
}

add_filter(
  'sentry_integration_x_xss_protection_options',
  'customize_sentry_options'
);

Note: _This filter fires on when Sentry Integration initializes and after the WP after_setup_theme._


sentry_integration_x_xss_protection_send_data (array|bool)

Provide a function which will be called before Sentry Expect-CT tracker sends any data, allowing you both to mutate that data, as well as prevent it from being sent to the server.

Example usage:

/**
 * Customize sentry send data.
 *
 * @param array $data The sentry send data.
 *
 * @return array|bool Return the data array or false to cancel the send operation.
 */
function filter_sentry_send_data(array $data)
{
  $data['tags']['my_custom_key'] = 'my_custom_value';

  return $data;
}

add_filter(
  'sentry_integration_x_xss_protection_send_data',
  'filter_sentry_send_data'
);

Note: This filter fires whenever the Sentry SDK is sending data to the Sentry server.

Catching plugin errors

Since this plugin is called sentry-integration it loads a bit late which could miss errors or notices occuring in plugins that load before it.

You can remedy this by loading WordPress Sentry as a must-use plugin by creating the file wp-content/mu-plugins/sentry-integration.php (if the mu-plugins directory does not exists you must create that too).

<?php

/**
 * Plugin Name: Sentry Integration
 * Plugin URI: https://github.com/itgalaxy/sentry-integration
 * Description: A (unofficial) WordPress plugin to report PHP and JavaScript and security headers errors to Sentry.
 * Version: must-use-proxy
 * Author: Alexander Krasnoyarov
 * Author URI: https://github.com/evilebottnawi
 * License: MIT
 */

$sentry_integration =
  __DIR__ . '/../plugins/sentry-integration/sentry-integration.php';

if (!file_exists($sentry_integration)) {
  return;
}

require $sentry_integration;

define('SENTRY_INTEGRATION_MU_LOADED', true);

Now sentry-integration will load always and before all other plugins.

Note: We advise you leave the original sentry-integration in the /wp-content/plugins folder to still have updates come in through the WordPress updater. However enabling or disabling does nothing if the above script is active (since it will always be enabled).

License

Sentry Integration plugin is open-sourced software licensed under the MIT license.

Releases

3 releases.

Tag
Published
2.1.0 latest
Mar 16, 2018 8 years ago
Jan 6, 2018 8 years ago
Nov 20, 2017 8 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.

B- grade

Security

Sentry Integration 2.1.0 · audited by WP Registry

Medium-severity findings.

2 medium 1 low
Audited release
2.1.0
Findings
3
Worst severity
medium
Content hash
b06047c0a00e6c8476f4651e…

Findings

  • medium Raven PHP tracker sends WordPress auth cookies and login passwords to Sentry

    information_disclosure

    When SENTRY_INTEGRATION_DSN is defined, PHPTracker::get_client() constructs Raven_Client with get_default_options() and never sets the processors option, so Raven_Client::getDefaultProcessors() installs only SanitizeDataProcessor. capture() then array_merge's get_http_data() onto every event: full $_COOKIE, the Cookie and Authorization headers, and $_POST. SanitizeDataProcessor::FIELDS_RE is /(authorization|password|passwd|secret|password_confirmation|card_number|auth_pw)/i and sanitizeHttp() only masks ini_get('session.name') (PHPSESSID) inside the cookies array — it does not walk headers and does not match WordPress's login field pwd or wordpress_logged_in_* / wordpress_sec_* cookies. RemoveCookiesProcessor and RemoveHttpBodyProcessor ship in vendor/sentry/sentry/lib/Raven/Processor/ and the 1.8.2 changelog says they would be default in 2.0, but this plugin never enables them. Observable: a PHP warning during wp-login.php or wp-admin stores the victim's session cookie and plaintext password in the Sentry issue; anyone with project access can hijack that WordPress session. Related: TrackerAbstract::on_set_current_user also puts user_email/user_login into context, and the documented sentry_integration_user_context filter is never applied (code checks wp_sentry_user_context, a leftover from the wp-sentry fork), so the documented PII-stripping hook is a no-op. JavaScriptTracker additionally inlines that same user object on wp_head/admin_head/login_head via wp_json_encode.

    src/PHPTracker.php:113-145,206-209

    Recommendation

    Pass processors including Raven_Processor_RemoveCookiesProcessor and Raven_Processor_RemoveHttpBodyProcessor, and extend SanitizeDataProcessor fields_re to cover pwd, wordpress_logged_in, wordpress_sec, app_pass, and card/cvv variants. Apply the documented sentry_integration_user_context filter (not wp_sentry_user_context). Prefer migrating to a maintained Sentry WordPress plugin on sentry-php 3/4 with send_default_pii defaulting to false.

  • medium Unauthenticated Expect-CT and X-XSS-Protection report routes inject Sentry events via the private DSN

    missing_auth

    If SENTRY_INTEGRATION_EXPECT_CT_DSN or SENTRY_INTEGRATION_X_XSS_PROTECTION_DSN is set, the corresponding tracker registers a public query var and parse_query handler with no capability, nonce, report authenticity check, payload-size cap, or rate limit. array_key_exists on the query var is enough (value is not required to be 'report'), so GET/POST /?sentry-integration-expect-ct-tracker=1 or /?sentry-integration-x-xss-protection-tracker=1 hits the sink even without pretty permalinks. Non-empty php://input is json_decode'd (true) and passed to Raven_Client::captureMessage as extra; capture() still merges get_http_data(), so a CSRF'd logged-in browser also uploads that user's cookies to Sentry. Empty body returns HTTP 204 and exit(). Observable: an unauthenticated client can flood the project's event quota (cost / alert-fatigue) with arbitrary extra JSON using the server-side DSN secret, and can 204 any URL that includes the query var. XXSSProtectionTracker::handle is the same pattern with extra taken from $report['xss-report']. Report-uri collectors are public by design, but this implementation is an unbounded private-DSN proxy.

    src/ExpectCTTracker.php:192-234,240-244

    Recommendation

    Keep report-uri public but bind it to a dedicated Sentry DSN/project with tight quotas, reject bodies over a few KB, rate-limit by IP, and do not attach the handling request's cookies/POST (call capture with an empty request context or enable RemoveCookiesProcessor/RemoveHttpBodyProcessor). Require the query var value to equal 'report'. Duplicate control in src/XXSSProtectionTracker.php (handle at 209-234).

  • low Plugin last released in 2018 with deprecated Raven PHP 1.8.2 and raven-js 3.21.0

    unmaintained

    Tag 2.1.0 (CHANGELOG 2018-01-06) is the latest GitHub release. composer.lock pins sentry/sentry 1.8.2 (21 Dec 2017); getsentry/raven-php is deprecated in favor of sentry-php and was archived in 2023. The bundled client still uses PHP 7 curly-brace string offsets in Raven_Client::_convertPath ($path{0}), which is a fatal on PHP 8 when prefixes/app_path conversion runs. public/raven.min.js is Raven.js 3.21.0 (also deprecated). There is no Update URI, no admin UI, and no path to receive SDK security fixes (cookie/PII defaults later changed in official Sentry SDKs). Sites should not expect patches for findings 1–2 from this tree.

    CHANGELOG.md:7-10

    Recommendation

    Replace with a currently maintained Sentry WordPress integration (e.g. stayallive/wp-sentry / wp-sentry-integration) on a supported sentry-php and @sentry/browser release. Do not expect security fixes for itgalaxy/sentry-integration 2.1.0.

WP Registry hashes the installable build and reports on that exact bytes-for-bytes copy. Embargoed findings are withheld until they are disclosed, so a clean verdict means nothing public is outstanding. WP Manifest does not audit code itself.