Ravindra Bagale · Cyber Securityसर्व coursesया course चे lessonsशोधाEnglish

Cyber Security · मराठी आवृत्ती

PHP चे secure configuration settings

रवींद्र बागले यांच्या course वर आधारित · सहज मराठीत explanation

या page मध्ये

PHP चालू झाल्यावर active web handler ची php.ini settings तपासा. php --ini CLI config दाखवतो; FPM/Apache वेगळं config वापरू शकतात. Amazon Linux example /etc/php.ini; Ubuntu मध्ये /etc/php/8.x/fpm/php.ini किंवा apache2/php.ini. Actual version/path तपासा.

Setting सुचवलेली setting का?
expose_php Off PHP version header कमी करतो
display_errors Off Visitors ना paths/SQL errors दिसू नयेत
log_errors On Errors logs मध्ये लिहिले जातात
allow_url_include Off URL-based include बंद/मर्यादित
upload_​max_​filesize / post_max_size App ला आवश्यक तितकीच limit Upload size चा गैरवापर मर्यादित
session.​cookie_​httponly 1 JavaScript cookie वाचू शकत नाही; XSS damage काही प्रमाणात कमी
session.​cookie_​secure 1 (HTTPS वापरताना) Cookie फक्त HTTPS वर पाठवली जाते
php --ini | grep "Loaded Configuration"
sudo sed -i 's/^expose_php = On/expose_php = Off/' /etc/php.ini              # Amazon Linux
sudo sed -i 's/^display_errors = On/display_errors = Off/' /etc/php.ini
sudo service php-fpm restart                                                 # Ubuntu: php8.3-fpm
curl -I http://localhost/index.php | grep -i x-powered-by                    # should print nothing

Sed examples exact existing line match झाल्यावरच बदल करतात. Comments किंवा दुसरी value असेल तर काहीच बदलणार नाही. Active configuration आणि applicable service restart/reload तपासा. Mod_php असेल तर Apache config/runtime वेगळा; FPM असेल तर actual FPM service.

Security मध्ये उपयोग

Verbose DB/PHP errors paths, query details किंवा internals उघड करू शकतात. Production मध्ये user-friendly generic message आणि restricted logs ठेवा. Header नाहीसा झाला म्हणजे सर्व server fingerprinting किंवा bugs गेले असं नाही.

Practice

एका lab server वर आवश्यक settings लागू करा. योग्य PHP handler restart करा. PHP response वर curl -I ने X-Powered-By header तपासा; proxy/app दुसरीकडून header देत असेल तर त्याचा source शोधा.

Chapter recap

आता पुढे MySQL सविस्तर शिकू.