Scrubbing Sensitive Data

As with any third-party service it’s important to understand what data is being sent to Sentry, and where relevant ensure sensitive data either never reaches the Sentry servers, or at the very least it doesn’t get stored. We recommend filtering or scrubbing sensitive data within the SDK, so that data is not sent with the event, and also configuring server-side scrubbing to ensure the data is not stored.

There are two great examples for data scrubbing that every company should think about:

  • PII (Personally Identifiable Information) such as a user's name or email address, which post-GDPR should be on every company's mind.
  • Authentication credentials, like your AWS password or key.
  • Confidential IP (Intellectual Property), such as your favorite color, or your upcoming plans for world domination.

Personally Identifiable Information (PII)

If you do not wish to use the default PII behavior, you can also choose to identify users in a more controlled manner, using our user identity context.

Confidential Information in Alerts

It’s common that compliance within your company may mean that data can only be transmitted over SSL and securely stored. One area where this often comes up is with email notifications. By default, Sentry will send a large amount of data as part of the issue notification. In some cases, this data may be source code or other user data.

If you need to work around this, you can enable the Enhanced Privacy setting for your organization. To do so, visit your organization’s dashboard, click Settings, and then tick the option to enable enhanced privacy. Once you've enabled this setting, parts of the system, primarily email notifications, will immediately reflect the change and begin restricting data to only basic attributes, such as the issue title and description.

Scrubbing Data

SDKs provide a before-send hook, which is invoked before an event is sent and can be used to modify event data to remove sensitive information. Using before-send in the SDKs to scrub any data before it is sent is the recommended scrubbing approach, so sensitive data never leaves the local environment.

import Sentry

SentrySDK.start { options in
    options.dsn = ""
    options.beforeSend = { event in
        // modify event here or return NULL to discard the event
        return event

There's a few areas you should consider that sensitive data may appear:

  • Stack-locals → some SDKs (Python + PHP), will pick up variable values within the stacktrace. This can be scrubbed or disabled altogether, if necessary
  • Breadcrumbs → some SDKs (for example, JavaScript, Java logging integrations) will pick up previously executed log statements. Do not log PII if using this feature and including log statements as breadcrumbs in the event. Some backend SDKs will surface DB queries which may need to be scrubbed
  • User context → automated behavior is controlled via send-default-pii
  • HTTP context → query strings may be picked up in some frameworks as part of the HTTP request context

For more details, see Filtering Events.


Contextual information

Instead of sending confidential information in plaintext, considering hashing it:

Sentry.setTag("birthday", checksumOrHash("08/12/1990"));

This will allow you to correlate it within internal systems if needed, but keep it confidential from Sentry.

User details

Your organization may determine that emails are not considered confidential, but if they are, consider instead sending your internal identifier:

Sentry.setUser({ id: });

// or

Sentry.setUser({ username: user.username });

Doing this will ensure you still benefit from user-impact related features.

Logging integrations

As a best practice you should always avoid logging confidential information. If you have legacy systems you need to work around, consider the following:

  • Anonymize the confidential information within the log statements (for example, swap out email addresses -> for internal identifiers)
  • Use beforeBreadcrumb to filter it out from breadcrumbs before it is attached
  • Disable logging breadcrumb integration (for example, as described [here] /platforms/javascript/#breadcrumbs-10)

Server-Side Controls

If you cannot - or do not want to - scrub data within the SDK, Sentry provides a number of options to achieve this in the product itself. You'll find these settings under the Data Scrubber option within both your Organization and individual Project settings. By default this is enabled, and we highly recommend you keep it that way. With it enabled, Sentry will scrub the following:

  • Values that look like they contain credit cards (using a basic regular expression)
  • Values that themselves contain, or whose keynames contain, any of the following strings:
    • password
    • secret
    • passwd
    • api_key
    • apikey
    • access_token
    • auth_token
    • credentials
    • mysql_pwd
    • stripetoken
    • card[number]
  • Any keys which match values that you’ve added to the list of additional fields in your Project Settings.

Sentry will redact arrays and literal values, but not entire objects. For example:

credentials = {
  username: 'jane',
  cats: ['pancake', 'maple', 'hellboy']
  password: 'p4ssw0rd!',
  lastLogin: 'yesterday',

Using the default options would not cause the object credentials to be redacted in its entirety; rather, all of its entries would be subject to scrubbing. So password would be redacted by default, and adding cats, username, and/or lastLogin to the list of additional fields would cause those values to be redacted as well.

In addition, we provide an Advanced Data Scrubbing feature which allows more control over how filters are applied..

Removing Data

If you’ve accidentally sent sensitive data to the server it’s likely you’re not going to want to leave it there. There are a few things to note in removal:

  • If you send it as a tagged value, removing the event is not enough. You can visit Project Settings and under Tags you’ll find a way to permanently remove any related data for a given tag.
  • If you need to wipe just a single event, you’ll find the ability to bulk delete all sampled events under a rollup by visiting the rollup details page and selecting “Delete”.
  • If you send sparse events to a project (potentially all of them), your only option is to remove the project and re-create it. Keep in mind this will revoke API credentials, so you likely want to do this in the reverse order.
You can edit this page on GitHub.