jvoisin/snuffleupagus

Security module for php7 and php8 - Killing bugclasses and virtual-patching the rest!

PHP

844

906 commits

updated Oct 16, 2026

See the code

README


Snuffleupagus' logo
Snuffleupagus

Security module for php7 and php8 - Killing bugclasses and virtual-patching the rest!

Testing PHP7 on various Linux distributions Testing PHP8 on various Linux distributions Coverity CII Best Practises readthedocs.org coveralls twitter Packaging status CodeQL

Key Features • Download • Examples • Documentation • License • Thanks

Snuffleupagus is a PHP 7+ and 8+ module designed to drastically raise the cost of attacks against websites, by killing entire bug classes. It also provides a powerful virtual-patching system, allowing administrator to fix specific vulnerabilities and audit suspicious behaviours without having to touch the PHP code.

Key Features

  • No noticeable performance impact
  • Powerful yet simple to write virtual-patching rules
  • Killing several classes of vulnerabilities
    • Unserialize-based code execution
    • mail-based code execution
    • Cookie-stealing XSS
    • File-upload based code execution
    • Weak PRNG
    • XXE
    • Filter based remote code execution and assorted shenanigans
  • Several hardening features
    • Automatic secure and samesite flag for cookies
    • Bundled set of rules to detect post-compromissions behaviours
    • Global strict mode and type-juggling prevention
    • Whitelisting of stream wrappers
    • Preventing writeable files execution
    • Whitelist/blacklist for eval
    • Enforcing TLS certificate validation when using curl
    • Request dumping capability
  • A relatively sane code base:

Download

We've got a download page, where you can find packages for your distribution, but you can of course just git clone this repo, or check the releases on github.

Examples

We're providing various example rules, that are looking like this:

# Harden the `chmod` function
sp.disable_function.function("chmod").param("mode").value_r("^[0-9]{2}[67]$").drop();

# Mitigate command injection in `system`
sp.disable_function.function("system").param("command").value_r("[$|;&`\\n]").drop();

Upon violation of a rule, you should see lines like this in your logs:

[snuffleupagus][0.0.0.0][disabled_function][drop] The execution has been aborted in /var/www/index.php:2, because the return value (0) of the function 'strpos' matched a rule.

Documentation

We've got a comprehensive website with all the documentation that you could possibly wish for. You can of course build it yourself.

Thanks

Many thanks to:

c
elephant
hardening
php
php7
php-module
security
security-hardening

jvoisin/snuffleupagus

Security module for php7 and php8 - Killing bugclasses and virtual-patching the rest!

PHP

844

906 commits

updated Oct 16, 2026

See the code

README


Snuffleupagus' logo
Snuffleupagus

Security module for php7 and php8 - Killing bugclasses and virtual-patching the rest!

Testing PHP7 on various Linux distributions Testing PHP8 on various Linux distributions Coverity CII Best Practises readthedocs.org coveralls twitter Packaging status CodeQL

Key Features • Download • Examples • Documentation • License • Thanks

Snuffleupagus is a PHP 7+ and 8+ module designed to drastically raise the cost of attacks against websites, by killing entire bug classes. It also provides a powerful virtual-patching system, allowing administrator to fix specific vulnerabilities and audit suspicious behaviours without having to touch the PHP code.

Key Features

  • No noticeable performance impact
  • Powerful yet simple to write virtual-patching rules
  • Killing several classes of vulnerabilities
    • Unserialize-based code execution
    • mail-based code execution
    • Cookie-stealing XSS
    • File-upload based code execution
    • Weak PRNG
    • XXE
    • Filter based remote code execution and assorted shenanigans
  • Several hardening features
    • Automatic secure and samesite flag for cookies
    • Bundled set of rules to detect post-compromissions behaviours
    • Global strict mode and type-juggling prevention
    • Whitelisting of stream wrappers
    • Preventing writeable files execution
    • Whitelist/blacklist for eval
    • Enforcing TLS certificate validation when using curl
    • Request dumping capability
  • A relatively sane code base:

Download

We've got a download page, where you can find packages for your distribution, but you can of course just git clone this repo, or check the releases on github.

Examples

We're providing various example rules, that are looking like this:

# Harden the `chmod` function
sp.disable_function.function("chmod").param("mode").value_r("^[0-9]{2}[67]$").drop();

# Mitigate command injection in `system`
sp.disable_function.function("system").param("command").value_r("[$|;&`\\n]").drop();

Upon violation of a rule, you should see lines like this in your logs:

[snuffleupagus][0.0.0.0][disabled_function][drop] The execution has been aborted in /var/www/index.php:2, because the return value (0) of the function 'strpos' matched a rule.

Documentation

We've got a comprehensive website with all the documentation that you could possibly wish for. You can of course build it yourself.

Thanks

Many thanks to:

c
elephant
hardening
php
php7
php-module
security
security-hardening

Project health

Overall

4.2/10

Maintained

10/10

Code review

2/10
OpenSSF Scorecard

Significant stargazers

Marco Pivetta

4,385 followers · starred Aug 2018

mschwager

241 followers · starred Dec 2020

Fabien Villepinte

34 followers · starred Jun 2019

Jáchym Toušek

119 followers · starred Aug 2018