GraphQL failed-request events use the server's error message, which can contain variable values

Open
#5,968 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
backend, security

Research direction

Start with src/Sentry/SentryGraphQLHttpFailedRequestHandler.cs, especially errorsElement[0].GetProperty("message") in DoEnsureSuccessfulResponse, and compare the three options described in the issue with sentry-java's behavior. Decide how the message should avoid exposing variable values while accounting for the IncomingResponseBody setting and title changes; done means the chosen behavior is implemented and covered by tests.

Written by the indexing model from the issue text.

Description

State: Needs Discussion

SentryGraphQLHttpFailedRequestHandler uses the server's errors[0].message as the exception message. Many GraphQL servers include the values of bad variables in that message, for example graphql-js's Variable "$id" got invalid value .... No DataCollection option covers the message, so variable values can reach Sentry even with DataCollection.GraphQL.Variables = false or SendDefaultPii = false.

This isn't a regression. The handler has always done this, and #5934 keeps it. It came up in the automated review of #5934.

sentry-java doesn't have this problem. Its Apollo interceptors build the message from the operation (GraphQL Request failed, name: ..., type: ...), and the server's response is attached only as the response body, gated by httpBodies.incomingResponse.

Options

Each of these changes what users see, which is why none of them is in #5934:

  • Remove the echoed variable values from the message. Not reliable: the message is free text from the server, and a short value such as 1 would match unrelated text.
  • Use the server's message only when IncomingResponseBody is on. The message is part of the response body, so this is arguably the right gate. But without ConfigureDataCollection that gate follows SendDefaultPii, so users with it off would get a generic message instead of the one they get today.
  • Build the message as sentry-java does, from the operation name and type. This changes the message for everyone.

The message becomes the issue title in Sentry, so the last two options change titles. Grouping wouldn't change when the request body can be read, since the fingerprint is the operation name, operation type and status code.

Where

  • src/Sentry/SentryGraphQLHttpFailedRequestHandler.cs: errorsElement[0].GetProperty("message") in DoEnsureSuccessfulResponse.

Related: #5420, #5432

Dominant language
C#
Stars
775
Forks
262
Avg merge
1d 16h
Merged PRs (30d)
118

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from getsentry/sentry-dotnet

All issues in getsentry/sentry-dotnet

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.