Opened 3 months ago

Closed 3 months ago

#1842 closed defect (invalid)

server_tokens doesnt affect redirects. Exposing software version.

Reported by: soporteatisa@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.14.x
Keywords: redirect exposed version Cc:
uname -a: Linux websrv 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx/1.14.0 (Ubuntu) built with OpenSSL 1.1.1 11 Sep 2018 (running with OpenSSL 1.1.1c 28 May 2019) TLS SNI support enabled configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-DUghaW/nginx-1.14.0=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

Description

Even after setting the server_tokens directive,
software version is exposed when using redirect.

To test this configure your server with the server_tokens off
and then in any vhost perform a redirect.
Example in a :80 vhost
return 301 https://$host$request_uri;

Response:
80/tcp open http 4 8 15 16 23 42
| fingerprint-strings:
| FourOhFourRequest?:
| HTTP/1.1 301 Moved Permanently
| Date: Wed, 28 Aug 2019 09:44:16 GMT
| Content-Type: text/html
| Content-Length: 194
| Connection: close
| Location: https://_/nice%20ports%2C/Tri%6Eity.txt%2ebak
| Server: 4 8 15 16 23 42
| <html>
| <head><title>301 Moved Permanently</title></head>
| <body bgcolor="white">
| <center><h1>301 Moved Permanently</h1></center>
| <hr><center>nginx/1.14.0 (Ubuntu)</center>
| </body>
| </html>

The main purpose of having the server_tokens directive is to easily switch off or modify the information avaliable to the public about thecnologies and versions used.

Change History (1)

comment:1 Changed 3 months ago by mdounin

  • Resolution set to invalid
  • Status changed from new to closed

It looks like you are testing it wrong.
Example configuration:

http {
    server {
        listen 8080;
        server_tokens off;
        return 301 https://$host$request_uri;
    }
}

Test results:

$ curl -v http://127.0.0.1:8080/test
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /test HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.62.0
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Mon, 02 Sep 2019 12:08:36 GMT
< Content-Type: text/html
< Content-Length: 162
< Connection: keep-alive
< Location: https://127.0.0.1/test
< 
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact

Note well that hiding information about software and versions used is more or less pointless. Even if configured properly, there are a lot of ways to find out which version is used, and how to attack it. Security by obscurity isn't a proper way to secure your systems, see here. Instead, consider using versions which aren't obsolete.

Note: See TracTickets for help on using tickets.