Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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