All the vulnerabilities related to the version 4.7.2 of the package
@apollo/server vulnerable to unsafe application of Content Security Policy via reused nonces
Content Security Policies (CSP) are a defense-in-depth strategy against XSS attacks. Improper application of CSP isn't itself a vulnerability, but it does fail to prevent XSS in the event that there is a viable attack vector for an XSS attack.
There aren't any XSS attack vectors via the Apollo Server landing pages known to Apollo, so to our knowledge there is no impact. However, if there are existing XSS vectors that haven't been reported and patched, then all users of Apollo Server's landing pages have a vulnerability which won't be prevented by the current CSP implemented by the landing pages.
Prior to version 4.7.1, there was no CSP implemented at all. However, the initial CSP implementation (4.7.1+) reused nonces. While this sufficiently resolved the issue w.r.t. scripts not running in Safari, it did not implement CSP in a safe or conventional way.
The issue is patched in the latest version of Apollo Server, v4.7.4. The changes can be reviewed in the merge commit.
The landing page can be disabled completely until the patch can be upgraded to. https://www.apollographql.com/docs/apollo-server/api/plugin/landing-pages/#disabling-the-landing-page
https://content-security-policy.com/nonce/
Prevent logging invalid header values
Apollo Server can log sensitive information (Studio API keys) if they are passed incorrectly (with leading/trailing whitespace) or if they have any characters that are invalid as part of a header value.
Users who (all of the below):
node-fetch
) or configured their own node-fetch
fetcherThe following node snippet can test whether your API key has invalid header values. This code is taken directly from node-fetch@2
's header value validation code.
const invalidHeaderCharRegex = /[^\t\x20-\x7e\x80-\xff]/;
if (invalidHeaderCharRegex.test('<YOUR_API_KEY>')) {
console.log('potentially affected');
}
console.log('unaffected');
If the provided API key is not a valid header value, whenever Apollo Server uses that API key in a request (to Studio, for example), node-fetch
will throw an error which contains the header value. This error is logged in various ways depending on the user's configuration, but most likely the console or some configured logging service.
This problem is patched in the latest version of Apollo Server as soon as this advisory is published.
fetcher
.trim()
on incoming API keys in order to eliminate leading/trailing whitespace and log a warning when it does so.node-fetch@2
performs on header values on startup. Apollo Server will throw an error on startup (i.e., fail to start completely) and notify the user their API key is invalid along with the offending characters.