Skip to content

Commit

Permalink
Port GHSA-2fvv-qxrq-7jq6 fix from v3 (#6792)
Browse files Browse the repository at this point in the history
See
GHSA-2fvv-qxrq-7jq6
for details.

This removes the curl command from the no-bundle fallback on the default
landing page.
  • Loading branch information
glasser committed Aug 10, 2022
1 parent 680c9eb commit 400f786
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/stale-sheep-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/server": patch
---

Port GHSA-2fvv-qxrq-7jq6 fix from v3 (remove XSS from default landing page HTML)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ describe('Embedded Explorer Landing Page Config HTML', () => {
graphRef: 'graph@current',
};
expect(getEmbeddedExplorerHTML(version, config)).toMatchInlineSnapshot(`
<div class="fallback">
<h1>
Welcome to Apollo Server
</h1>
<p>
Apollo Explorer cannot be loaded; it appears that you might be offline.
</p>
</div>
<style>
iframe {
background-color: white;
Expand Down Expand Up @@ -59,6 +67,14 @@ describe('Embedded Explorer Landing Page Config HTML', () => {
graphRef: 'graph@current',
};
expect(getEmbeddedExplorerHTML(version, config)).toMatchInlineSnapshot(`
<div class="fallback">
<h1>
Welcome to Apollo Server
</h1>
<p>
Apollo Explorer cannot be loaded; it appears that you might be offline.
</p>
</div>
<style>
iframe {
background-color: white;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ describe('Landing Page Config HTML', () => {
embed: true,
};
expect(getEmbeddedSandboxHTML(version, config)).toMatchInlineSnapshot(`
<div class="fallback">
<h1>
Welcome to Apollo Server
</h1>
<p>
Apollo Sandbox cannot be loaded; it appears that you might be offline.
</p>
</div>
<style>
iframe {
background-color: white;
Expand Down Expand Up @@ -49,6 +57,14 @@ describe('Landing Page Config HTML', () => {
embed: true,
};
expect(getEmbeddedSandboxHTML(version, config)).toMatchInlineSnapshot(`
<div class="fallback">
<h1>
Welcome to Apollo Server
</h1>
<p>
Apollo Sandbox cannot be loaded; it appears that you might be offline.
</p>
</div>
<style>
iframe {
background-color: white;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export const getEmbeddedExplorerHTML = (
};

return `
<div class="fallback">
<h1>Welcome to Apollo Server</h1>
<p>Apollo Explorer cannot be loaded; it appears that you might be offline.</p>
</div>
<style>
iframe {
background-color: white;
Expand Down Expand Up @@ -92,6 +96,10 @@ export const getEmbeddedSandboxHTML = (
config: LandingPageConfig,
) => {
return `
<div class="fallback">
<h1>Welcome to Apollo Server</h1>
<p>Apollo Sandbox cannot be loaded; it appears that you might be offline.</p>
</div>
<style>
iframe {
background-color: white;
Expand Down
13 changes: 4 additions & 9 deletions packages/server/src/plugin/landingPage/default/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const getNonEmbeddedLandingPageHTML = (
const encodedConfig = encodeConfig(config);

return `
<div class="fallback">
<h1>Welcome to Apollo Server</h1>
<p>The full landing page cannot be loaded; it appears that you might be offline.</p>
</div>
<script>window.landingPage = ${encodedConfig};</script>
<script src="https://apollo-server-landing-page.cdn.apollographql.com/${version}/static/js/main.js"></script>`;
};
Expand Down Expand Up @@ -126,15 +130,6 @@ function ApolloServerPluginLandingPageDefault<TContext extends BaseContext>(
100% {opacity:1; }
}
</style>
<div class="fallback">
<h1>Welcome to Apollo Server</h1>
<p>It appears that you might be offline. POST to this endpoint to query your graph:</p>
<code style="white-space: pre;">
curl --request POST \\
--header 'content-type: application/json' \\
--url '<script>document.write(window.location.href)</script>' \\
--data '{"query":"query { __typename }"}'</code>
</div>
${
config.embed
? 'graphRef' in config && config.graphRef
Expand Down

0 comments on commit 400f786

Please sign in to comment.