feat: adjust the playground to support the auth token#3240
feat: adjust the playground to support the auth token#3240unseen2004 wants to merge 1 commit intoFuelLabs:masterfrom
Conversation
…param close FuelLabs#3140 Allows users to pass an auth token via the URL query parameter `?token=<value>` when accessing the GraphQL playground at /v1/playground. The token is injected as an `Authorization: Bearer <token>` header in the GraphiQL UI, enabling usage with external data providers like Quicknode, Ankr, etc. When no token is provided, the existing cached static HTML is used unchanged.
|
Thanks for the contribution! Before we can merge this, we need @unseen2004 to sign the Fuel Labs Contributor License Agreement. |
PR SummaryMedium Risk Overview Refactors playground rendering by extracting Written by Cursor Bugbot for commit 391a485. This will update automatically on new commits. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| graphql_subscription_endpoint, | ||
| token, | ||
| ) | ||
| }; |
There was a problem hiding this comment.
Reflected XSS via unsanitized token query parameter
High Severity
The token query parameter is taken directly from the URL and passed unsanitized into GraphiQLSource::build().header(), which embeds the value into a <script> tag in the HTML response. Since async-graphql uses Handlebars templating with JSON serialization for headers (and serde_json does not escape <, >, or / by default), an attacker can craft a URL like /v1/playground?token=</script><script>alert(1)// to inject arbitrary JavaScript — a classic reflected XSS. The token value needs validation or sanitization before being embedded in the HTML output.


close #3140
Summary
Adds auth token support to the GraphQL playground at
/v1/playground.Users can now pass an auth token via the
?token=<value>URL query parameter,which gets injected as an
Authorization: Bearer <token>header into the GraphiQL UI.This enables usage with external data providers like Quicknode, Ankr, etc.
Changes
?token=query parameter on the/v1/playgroundrouteAuthorization: Bearerheader injectedbuild_playground_htmlhelper to avoid code duplicationTesting
/v1/playground?token=my-api-keyto verify the header is injected in GraphiQL requests