Skip to content
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

Security improvement: don't reveal powered-by #2813

Closed
wants to merge 1 commit into from
Closed
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
6 changes: 0 additions & 6 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ app.defaultConfiguration = function defaultConfiguration() {
var env = process.env.NODE_ENV || 'development';

// default settings
this.enable('x-powered-by');
this.set('etag', 'weak');
this.set('env', env);
this.set('query parser', 'extended');
Expand Down Expand Up @@ -150,11 +149,6 @@ app.handle = function handle(req, res, callback) {
onerror: logerror.bind(this)
});

// set powered by header
if (this.enabled('x-powered-by')) {
res.setHeader('X-Powered-By', 'Express');
}

// set circular references
req.res = res;
res.req = req;
Expand Down
15 changes: 15 additions & 0 deletions test/req.secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ var express = require('../')
, request = require('supertest');

describe('req', function(){
it('should not reveal powered-by', function(done){
var app = express();

app.get('/', function(req, res){
res.send('hello world');
});

request(app)
.get('/')
.expect(function (res) {
res.header.should.not.have.property('x-powered-by');
})
.expect(200, done)
})

describe('.secure', function(){
describe('when X-Forwarded-Proto is missing', function(){
it('should return false when http', function(done){
Expand Down