Skip to content

tunnelRoute passes through Strict-Transport-Security header, enabling HSTS on users' domains #8931

Closed
@markspolakovs

Description

@markspolakovs

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

7.64.0

Framework Version

Next.js 13.4.19

Link to Sentry event

No response

SDK Setup

On the server:

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SERVER_SENTRY_DSN,
  tracesSampleRate: 1,
  debug: false,
  release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
});

On the client:

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SERVER_SENTRY_DSN,
  tracesSampleRate: 1,
  debug: false,
  replaysOnErrorSampleRate: 1.0,
  replaysSessionSampleRate: 0.1,
  integrations: [
    new Sentry.Replay({
      maskAllText: true,
      blockAllMedia: true,
    }),
  ],
  release: process.env.NEXT_PUBLIC_SENTRY_RELEASE,
  tracePropagationTargets: [
    "http://localhost:3000",
    "https://bowser.dev.ystv.co.uk",
    "https://bowser.ystv.co.uk",
  ],
});

In next.config.js:

module.exports = withSentryConfig(
  nextConfig,
  {
    silent: true,
    org: "ystv",
    project: "bowser-server",
    authToken: process.env.SENTRY_AUTH_TOKEN,
    release: sentryRelease,
  },
  {
    widenClientFileUpload: true,
    transpileClientSDK: false,
    tunnelRoute: "/monitoring",
    hideSourceMaps: true,
    disableLogger: true,
    disableClientWebpackPlugin: process.env.IS_PRODUCTION_BUILD !== "true",
    disableServerWebpackPlugin: process.env.IS_PRODUCTION_BUILD !== "true",
  },
);

Steps to Reproduce

  1. Set up the Next.js integration with tunnelRoute enabled
  2. Deploy the application on a hosting provider that does not set Strict-Transport-Security
  3. Visit a page in the application
  4. Watch the browser DevTools Network tab for a request to /monitoring

Expected Result

No Strict-Transport-Security header is present on any response

Actual Result

The initial response from the backend does not have Strict-Transport-Security:

image

However, the response to the /monitoring request has the Strict-Transport-Security header from the Sentry SaaS backend:

image

Looking in chrome://net-internals#hsts you can indeed see that this has unintentionally enabled dynamic HSTS for the domain in question:
image

Any subsequent non-HTTPS requests to the domain will now fail.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions