-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider providing an option to disable the "x-powered-by" header #3812
Comments
PR welcome! |
@abernix I feel like there may be a few options here. Option 1, does it make sense to introduce generic properties for adding and removing static headers? For example, I may want to add headers similar to ones that the Helmet package adds and I'm not sure if that is possible now if not using the express middleware. Option 2 would be a apollo-helmet plugin... take the functionality of helmet and make it into an apollo plugin.
This works for the most part except that the X-Powered-By isn't present when Option 3 would be adding helmet as a dependency for apollo-server-express and attaching it to express by default, since it applies security best practices. This option is the most "forceful" option but not necessarily a bad idea as these headers are generally considered security best practices. |
@andrewmcgivery Your proposal seems like a bigger conversation. Perhaps we can just disable this default Express header for now without any configuration? I don't think it adds much value in its current reveal of the server being "Express". @scottohara, @pauloedurezende others: Thoughts of just disable the header for now, without a top-level configuration setting which I'd rather not introduce for this? |
I’d be happy with just disabling the x-powered-by header by default for now. |
@scottohara Unless someone objects, I think that would be fine and welcome. However, it's worth noting that @pauloedurezende opened a PR recently which referenced this issue and I left a comment on it: #3821 (comment). Perhaps the adjustments can just be made to that PR, otherwise, a new PR would be welcome. And if anyone watching objects to disabling this default header in the |
Yep, thanks @abernix; I noticed that PR was already up after my earlier comment (so I edited accordingly). I’ll wait to see if the other PR progresses or stalls. Thanks. |
@abernix I'm good with the simple disable of the header change. However, I'm still wondering if it is worth shipping apollo-server-express with the helmet middleware out of the box to encourage security best practices. Is there any downsides to that approach that you can think of? |
@andrewmcgivery I agree with the idea generally, but introducing those middleware, which might be carefully placed in existing As noted above: in a not-too-distant version of Apollo Server, this functionality will all live in an HTTP-specific transport in future versions. We plan on providing a production best-practice / pre-flight guide to supplement that pattern, and including |
@abernix Thanks! |
Affected package/version:
[email protected]
Issue description
When using
apollo-server
(without explicitly callingserver.applyMiddleware()
), the out-of-box configuration defaults internally toapollo-server-express
.Responses from this default server include the following response header:
As per Express Production Best Practices: Security, consider disabling this header to avoid unnecessary disclosure to potential attackers that the server is running Express.
Alternatively, consider providing an option in the
ApolloServer
constructor to allow developers to opt into, e.g.The presence of this header is commonly flagged by security scanning tools such as Netsparker.
Steps to reproduce
Assume
NODE_ENV=production
(playground disabled).Server setup
Request
Response
Note the presence of the
x-powered-by
header in the response.Additional notes
It is possible to disable the header when using
apollo-server-express
directly, e.g.However developers following the Getting Started guide, which uses code similar to the reproduction above, should be set up for success by defaulting to a server configuration that adheres to Express best practices for security.
The text was updated successfully, but these errors were encountered: