Varnish Cache data leak when using file stevedore with synthetic objects Security

Published November 15, 2017.


A data leak can be triggered in Varnish Cache by a remote client if Varnish Cache is using the file stevedore for synthetic error objects and the backend does not respond properly or times out.

This was discovered and patched respectively by Carlo Cannas of and @shamger.


Potential impact is data leak and segmentation fault:

  • The data leaked will be an excerpt from the anonymously mapped memory of the varnishd process, limited upwards to 4k bytes and it will be present in the body of the synthesized error object created in place of the failed backend fetch.

  • Some requests will cause varnishd to segfault. This happens when the buffer overflow causes a read of unmapped memory.

Repeated attempts to fetch leaked memory will eventually produce a segmentation fault which can be detected by the administrator.


All of the following conditions are required to trigger the problem:

  • A file stevedore must be configured using the -s [<name>=]file,... option to varnishd.

  • A synthetic object must be created in vcl_backend_error{}. This happens e.g. when Varnish is unable to get a properly formatted HTTP response from the backend, or if requested from VCL by doing return (fail) or return (abandon).

(Note: The problem also applies in the same way for uses of the deprecated and unsupported stevedore persistent.)


Affected software versions

  • Varnish Cache: 4.1.0 - 5.2.0

Not affected software versions

  • Varnish Cache: Earlier than 4.1.0
  • Varnish Enterprise: All versions

Resolved in

  • Varnish Cache: 4.1.9
  • Varnish Cache: 5.2.1


The solution is to upgrade Varnish to one of the versions where this issue has been resolved, and then ensure that Varnish is restarted.


Organizations that are not able to upgrade their Varnish environment on short notice can switch from the file stevedore to the malloc stevedore.

The stevedore to use is specified using the -s option to the varnishd process:

# Existing configuration specifying file
varnishd -s file,1G,/var/lib/varnish/varnish_storage.bin

# New configuration specifying malloc
varnishd -s malloc,1G

Please note that the malloc stevedore uses system memory, and the cache size should be adjusted accordingly.

This is configured in:

  • /etc/sysconfig/varnish.params in Redhat and derivatives.
  • /etc/default/varnish in Debian and derivatives.


The vulnerability may trigger a segmentation fault, which will appear in the system logs.



  • @shamger opened pull request #2429 that fixed the segmentation fault.


  • Varnish Software accepted the pull request and backported the patch to the Varnish Cache 4.1 branch.


  • Carlo Cannas of reported to PHK that the issue can also cause data leaks in certain situations.


  • The security teams in Ubuntu, Debian, RedHat and FreeBSD were notified.


  • Varnish Cache packages released to the official Varnish Cache package repositories.
  • Public announcement.


  • Update the Prerequisites section removing the last clause as this was found to be inaccurate.


Varnish Software would like to thank Carlo Cannas of and @shamger for discovering and patching the vulnerability.