Harden ServiceMap config path validation to prevent local file disclosure#87
Harden ServiceMap config path validation to prevent local file disclosure#87terabytesoftw wants to merge 2 commits into
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ 5 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Motivation
yii2.config_pathand passed it torequireafter only checkingfile_exists, which allowed non-PHP readable files to be emitted to output/logs and attacker-controlled PHP to be executed.require, enabling local file disclosure in analysis/CI environments.Description
ServiceMapconstructor validation so that whenyii2.config_pathis provided it must be an existing regular file,is_readable, and have a.phpextension before being loaded.is_file,pathinfo, and thePATHINFO_EXTENSIONconstant to support the new checks.InvalidArgumentExceptionmessage to explicitly require a readable PHP file.Testing
php -l src/ServiceMap.phpreported no syntax errors../vendor/bin/phpunit --versioncould not run becausevendor/bin/phpunitis not present in this environment, so unit tests were not executed here.Codex Task