-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request from GHSA-68jh-rf6x-836f
* CSP fixes * Update snapshots * spell check * add a test that actually validates the whole point of this change :) * Apply new config option `allowDynamicStyling` for explorer/sandbox With the updated (more restrictive) CSP, the dynamic styling implemented by explorer/sandbox now triggers a CSP error. With this new option, we can disable the dynamic styles (and just apply them ourselves in our nonced inline styles). * oops wrong symbol * test cleanup * warn on precomputedNonce configuration
- Loading branch information
1 parent
aeb511c
commit 0adaf80
Showing
13 changed files
with
324 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
'@apollo/server-integration-testsuite': patch | ||
'@apollo/server': patch | ||
--- | ||
|
||
Address Content Security Policy issues | ||
|
||
The previous implementation of CSP nonces within the landing pages did not take full advantage of the security benefit of using them. Nonces should only be used once per request, whereas Apollo Server was generating one nonce and reusing it for the lifetime of the instance. The reuse of nonces degrades the security benefit of using them but does not pose a security risk on its own. The CSP provides a defense-in-depth measure against a _potential_ XSS, so in the absence of a _known_ XSS vulnerability there is likely no risk to the user. | ||
|
||
The mentioned fix also coincidentally addresses an issue with using crypto functions on startup within Cloudflare Workers. Crypto functions are now called during requests only, which resolves the error that Cloudflare Workers were facing. A recent change introduced a `precomputedNonce` configuration option to mitigate this issue, but it was an incorrect approach given the nature of CSP nonces. This configuration option is now deprecated and should not be used for any reason since it suffers from the previously mentioned issue of reusing nonces. | ||
|
||
Additionally, this change adds other applicable CSPs for the scripts, styles, images, manifest, and iframes that the landing pages load. | ||
|
||
A final consequence of this change is an extension of the `renderLandingPage` plugin hook. This hook can now return an object with an `html` property which returns a `Promise<string>` in addition to a `string` (which was the only option before). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,6 +89,7 @@ Hofmann | |
hrtime | ||
htmls | ||
httpcache | ||
iframes | ||
IHTTP | ||
importability | ||
instanceof | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,22 +41,29 @@ describe('Embedded Explorer Landing Page Config HTML', () => { | |
Apollo Explorer cannot be loaded; it appears that you might be offline. | ||
</p> | ||
</div> | ||
<style> | ||
<style nonce="nonce"> | ||
iframe { | ||
background-color: white; | ||
height: 100%; | ||
width: 100%; | ||
border: none; | ||
} | ||
#embeddableExplorer { | ||
width: 100vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
} | ||
</style> | ||
<div style="width: 100vw; height: 100vh; position: absolute; top: 0;" | ||
id="embeddableExplorer" | ||
> | ||
<div id="embeddableExplorer"> | ||
</div> | ||
<script nonce="nonce" | ||
src="https://embeddable-explorer.cdn.apollographql.com/_latest/embeddable-explorer.umd.production.min.js?runtime=%40apollo%2Fserver%404.0.0" | ||
> | ||
</script> | ||
<script nonce="nonce"> | ||
var endpointUrl = window.location.href; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"document":"query Test { id }","headers":{"authorization":"true"},"variables":{"option":{"a":"val","b":1,"c":true}},"displayOptions":{"showHeadersAndEnvVars":true,"docsPanelState":"open","theme":"light"}},"persistExplorerState":true,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":true}; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"document":"query Test { id }","headers":{"authorization":"true"},"variables":{"option":{"a":"val","b":1,"c":true}},"displayOptions":{"showHeadersAndEnvVars":true,"docsPanelState":"open","theme":"light"}},"persistExplorerState":true,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":true,"allowDynamicStyles":false}; | ||
new window.EmbeddedExplorer({ | ||
...embeddedExplorerConfig, | ||
endpointUrl, | ||
|
@@ -84,22 +91,29 @@ describe('Embedded Explorer Landing Page Config HTML', () => { | |
Apollo Explorer cannot be loaded; it appears that you might be offline. | ||
</p> | ||
</div> | ||
<style> | ||
<style nonce="nonce"> | ||
iframe { | ||
background-color: white; | ||
height: 100%; | ||
width: 100%; | ||
border: none; | ||
} | ||
#embeddableExplorer { | ||
width: 100vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
} | ||
</style> | ||
<div style="width: 100vw; height: 100vh; position: absolute; top: 0;" | ||
id="embeddableExplorer" | ||
> | ||
<div id="embeddableExplorer"> | ||
</div> | ||
<script nonce="nonce" | ||
src="https://embeddable-explorer.cdn.apollographql.com/_latest/embeddable-explorer.umd.production.min.js?runtime=%40apollo%2Fserver%404.0.0" | ||
> | ||
</script> | ||
<script nonce="nonce"> | ||
var endpointUrl = window.location.href; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"headers":{"authorization":"true"},"displayOptions":{}},"persistExplorerState":false,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":true}; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"headers":{"authorization":"true"},"displayOptions":{}},"persistExplorerState":false,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":true,"allowDynamicStyles":false}; | ||
new window.EmbeddedExplorer({ | ||
...embeddedExplorerConfig, | ||
endpointUrl, | ||
|
@@ -128,22 +142,29 @@ describe('Embedded Explorer Landing Page Config HTML', () => { | |
Apollo Explorer cannot be loaded; it appears that you might be offline. | ||
</p> | ||
</div> | ||
<style> | ||
<style nonce="nonce"> | ||
iframe { | ||
background-color: white; | ||
height: 100%; | ||
width: 100%; | ||
border: none; | ||
} | ||
#embeddableExplorer { | ||
width: 100vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
} | ||
</style> | ||
<div style="width: 100vw; height: 100vh; position: absolute; top: 0;" | ||
id="embeddableExplorer" | ||
> | ||
<div id="embeddableExplorer"> | ||
</div> | ||
<script nonce="nonce" | ||
src="https://embeddable-explorer.cdn.apollographql.com/_latest/embeddable-explorer.umd.production.min.js?runtime=%40apollo%2Fserver%404.0.0" | ||
> | ||
</script> | ||
<script nonce="nonce"> | ||
var endpointUrl = window.location.href; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"collectionId":"12345","operationId":"abcdef","displayOptions":{}},"persistExplorerState":false,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":true}; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"collectionId":"12345","operationId":"abcdef","displayOptions":{}},"persistExplorerState":false,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":true,"allowDynamicStyles":false}; | ||
new window.EmbeddedExplorer({ | ||
...embeddedExplorerConfig, | ||
endpointUrl, | ||
|
@@ -170,22 +191,29 @@ describe('Embedded Explorer Landing Page Config HTML', () => { | |
Apollo Explorer cannot be loaded; it appears that you might be offline. | ||
</p> | ||
</div> | ||
<style> | ||
<style nonce="nonce"> | ||
iframe { | ||
background-color: white; | ||
height: 100%; | ||
width: 100%; | ||
border: none; | ||
} | ||
#embeddableExplorer { | ||
width: 100vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
} | ||
</style> | ||
<div style="width: 100vw; height: 100vh; position: absolute; top: 0;" | ||
id="embeddableExplorer" | ||
> | ||
<div id="embeddableExplorer"> | ||
</div> | ||
<script nonce="nonce" | ||
src="https://embeddable-explorer.cdn.apollographql.com/_latest/embeddable-explorer.umd.production.min.js?runtime=%40apollo%2Fserver%404.0.0" | ||
> | ||
</script> | ||
<script nonce="nonce"> | ||
var endpointUrl = window.location.href; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"displayOptions":{}},"persistExplorerState":false,"includeCookies":false,"runtime":"@apollo/[email protected]","runTelemetry":true}; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"displayOptions":{}},"persistExplorerState":false,"includeCookies":false,"runtime":"@apollo/[email protected]","runTelemetry":true,"allowDynamicStyles":false}; | ||
new window.EmbeddedExplorer({ | ||
...embeddedExplorerConfig, | ||
endpointUrl, | ||
|
@@ -215,22 +243,29 @@ describe('Embedded Explorer Landing Page Config HTML', () => { | |
Apollo Explorer cannot be loaded; it appears that you might be offline. | ||
</p> | ||
</div> | ||
<style> | ||
<style nonce="nonce"> | ||
iframe { | ||
background-color: white; | ||
height: 100%; | ||
width: 100%; | ||
border: none; | ||
} | ||
#embeddableExplorer { | ||
width: 100vw; | ||
height: 100vh; | ||
position: absolute; | ||
top: 0; | ||
} | ||
</style> | ||
<div style="width: 100vw; height: 100vh; position: absolute; top: 0;" | ||
id="embeddableExplorer" | ||
> | ||
<div id="embeddableExplorer"> | ||
</div> | ||
<script nonce="nonce" | ||
src="https://embeddable-explorer.cdn.apollographql.com/_latest/embeddable-explorer.umd.production.min.js?runtime=%40apollo%2Fserver%404.0.0" | ||
> | ||
</script> | ||
<script nonce="nonce"> | ||
var endpointUrl = window.location.href; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"headers":{"authorization":"true"},"displayOptions":{}},"persistExplorerState":false,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":false}; | ||
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"headers":{"authorization":"true"},"displayOptions":{}},"persistExplorerState":false,"includeCookies":true,"runtime":"@apollo/[email protected]","runTelemetry":false,"allowDynamicStyles":false}; | ||
new window.EmbeddedExplorer({ | ||
...embeddedExplorerConfig, | ||
endpointUrl, | ||
|
Oops, something went wrong.