Tools
Log in
English

Learn to codeSecurity check

allow_url_include is on

HighP03PHP servers (Linux and Windows)

Turn off allow_url_include so include cannot load code from remote URLs.

What is the risk

With allow_url_include on, include and require read http:// or data:// URLs and run them as PHP code.

If any place passes request input to include, an attacker can run code from their own server (remote file inclusion, RFI). It is off by default and deprecated since PHP 7.4.

How to check

Linux

php -i | grep -E '^allow_url_(include|fopen)'
grep -rn 'allow_url_include' /etc/php/ /etc/php.ini /etc/php.d/ 2>/dev/null

php -i shows the command-line settings. The second line reads the files the web server uses.

Windows PowerShell (admin)

& "C:\php\php.exe" -i | Select-String allow_url
Select-String -Path C:\php\php.ini -Pattern allow_url_include

How to fix

php.ini

allow_url_include = Off

Set this in php.ini. Remove lines such as php_admin_flag[allow_url_include] = on from FPM pool files.

Debian / Ubuntu

sudo systemctl restart php8.3-fpm

RHEL / Rocky / Alma

sudo systemctl restart php-fpm

Windows PowerShell (admin)

if (Get-Service W3SVC -ErrorAction SilentlyContinue) { iisreset } else { Get-Service *apache* -ErrorAction SilentlyContinue | Restart-Service }

Restarts IIS if installed, otherwise the Apache service. With XAMPP press Stop then Start for Apache in the Control Panel.

How to prevent it

  • Never pass request input to include or require. Pick file names from a fixed list.
  • Limit the folders PHP can read with open_basedir.
  • Turn off allow_url_fopen too if you do not need it.

Check again after fixing

Linux

php -i | grep '^allow_url_include'

It should say Off.

Run the downloaded check again and make sure this item passes.

Security check home