← Home ← Codex ← DEBT
Browse by Category
+ added · updated 7d
← Back to glossary

php.ini Security Settings

PHP OWASP A5:2021 PHP 5.0+ Intermediate
debt(d5/e3/b5/t5)
d5 Detectability Operational debt — how invisible misuse is to your safety net

Closest to 'specialist tool catches' (d5). The term's detection_hints list phpinfo, semgrep, and lynis as tools — these are specialist security/configuration scanners rather than default IDE linters. Misconfigurations like expose_php=On or display_errors=On in production require intentional auditing with these tools or manual review; they won't be caught by standard PHP syntax checking.

e3 Effort Remediation debt — work required to fix once spotted

Closest to 'simple parameterised fix' (e3). The quick_fix shows a checklist of ini directives that can be changed in one file, but fixing php.ini misconfigurations often requires understanding which pool/vhost/context is affected, potentially touching multiple configuration files (php-fpm pool configs, .htaccess, vhost configs). It's more than a one-line patch but typically contained within the server configuration layer rather than application code.

b5 Burden Structural debt — long-term weight of choosing wrong

Closest to 'persistent productivity tax' (b5). php.ini settings apply across web and CLI contexts as noted in applies_to, affecting every PHP process on the server. The common_mistakes highlight that CLI and FPM often need different settings — this creates ongoing maintenance burden as the team must track which settings apply where. The choice shapes debugging workflows, deployment procedures, and security posture across all work streams without being completely architectural.

t5 Trap Cognitive debt — how counter-intuitive correct behaviour is

Closest to 'notable trap' (t5). The misconception explicitly states developers wrongly assume php.ini settings apply uniformly to all PHP processes, when in fact settings can be overridden at multiple levels (per-directory, per-virtualhost, per-pool, runtime). Understanding INI_ALL/INI_SYSTEM/INI_PERDIR permission levels is a documented gotcha that most PHP developers eventually learn, but causes confusion during debugging.

About DEBT scoring →

Also Known As

php.ini PHP configuration file PHP runtime settings

TL;DR

Critical php.ini directives that harden PHP applications by disabling dangerous features and restricting runtime behaviour.

Explanation

Key security settings in php.ini include: display_errors=Off and log_errors=On (prevent information leakage), expose_php=Off (hides version), allow_url_include=Off (prevents RFI), disable_functions listing dangerous functions (exec, system, passthru, shell_exec), open_basedir restricting file access to the application directory, session.use_strict_mode=On and session.cookie_httponly=On (session security), post_max_size and upload_max_filesize (DoS prevention). Review settings regularly as PHP defaults favour development over security.

Common Misconception

php.ini settings apply uniformly to all PHP processes on a server. Settings can be overridden per-directory with .htaccess, per-virtualhost, per-pool in PHP-FPM, and at runtime with ini_set() — understanding the INI_ALL/INI_SYSTEM/INI_PERDIR permission levels is essential for debugging unexpected behaviour.

Why It Matters

php.ini controls PHP's runtime behaviour at the server level — misconfigured settings silently affect security, performance, and error visibility across every script.

Common Mistakes

  • Not having separate php.ini for CLI and FPM — they often need different memory_limit and timeout values.
  • Leaving expose_php = On — the X-Powered-By header advertises your PHP version to attackers.
  • Not setting session.cookie_secure, session.cookie_httponly, and session.cookie_samesite at the php.ini level as defaults.
  • Using large upload_max_filesize without corresponding post_max_size — POST data is silently truncated.

Code Examples

✗ Vulnerable
; php.ini security issues:
expose_php = On           ; Advertises PHP version
display_errors = On       ; Stack traces to users in production
allow_url_include = On    ; Enables remote file inclusion
register_globals = On     ; Removed in PHP 5.4 but shows config hygiene issues
session.cookie_httponly = 0 ; Cookies readable by JS
✓ Fixed
; Key php.ini settings

; Development:
error_reporting        = E_ALL
display_errors         = On
display_startup_errors = On

; Production:
error_reporting  = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors   = Off    ; CRITICAL — never expose to users
log_errors       = On
error_log        = /var/log/php/error.log
expose_php       = Off    ; hides X-Powered-By header
max_execution_time = 30
memory_limit     = 256M
upload_max_filesize = 10M
post_max_size    = 12M
date.timezone    = UTC

; Check active settings at runtime:
ini_get('memory_limit'); // specific value
phpinfo();               // full page — NEVER in production

Added 15 Mar 2026
Edited 22 Mar 2026
Views 104
Rate this term
No ratings yet
🤖 AI Guestbook educational data only
| |
Last 30 days
1 ping T 0 pings W 1 ping T 0 pings F 0 pings S 0 pings S 1 ping M 1 ping T 0 pings W 1 ping T 6 pings F 3 pings S 9 pings S 4 pings M 2 pings T 0 pings W 1 ping T 1 ping F 2 pings S 1 ping S 0 pings M 0 pings T 1 ping W 0 pings T 1 ping F 1 ping S 1 ping S 1 ping M 0 pings T 0 pings W
No pings yet today
No pings yesterday
Perplexity 24 Scrapy 23 Amazonbot 9 ChatGPT 8 Google 7 Unknown AI 4 SEMrush 4 Claude 2 Ahrefs 2 Meta AI 1 PetalBot 1
crawler 79 crawler_json 5 pre-tracking 1
DEV INTEL Tools & Severity
🟠 High ⚙ Fix effort: Low
⚡ Quick Fix
Production php.ini checklist: display_errors=Off, log_errors=On, expose_php=Off, upload_max_filesize match your needs, memory_limit=256M, opcache.enable=1
📦 Applies To
PHP 5.0+ web cli
🔗 Prerequisites
🔍 Detection Hints
display_errors=On production; expose_php=On; opcache.enable=0; allow_url_include=On dangerous setting
Auto-detectable: ✓ Yes phpinfo semgrep lynis
⚠ Related Problems
🤖 AI Agent
Confidence: Medium False Positives: Medium ✗ Manual fix Fix: Medium Context: File


✓ schema.org compliant