fix(sec-010): strip C++ source paths from exception messages#141
Merged
Conversation
39f7603 to
43f71a3
Compare
Add verboseErrors parameter to ZVec::init() to control error detail disclosure. When verboseErrors=false (default), ZVecException omits file/line/function properties, preventing internal path leakage. Also strip __FILE__ to basename in MAKE_STATUS macro via strrchr() to reduce information disclosure even in verbose mode. Closes #78
43f71a3 to
ffba918
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
verboseErrorsparameter toZVec::init()to control error detail disclosure. WhenverboseErrors=false(default),ZVecExceptionomits file/line/function properties, preventing internal path leakage to end users.Also strip
__FILE__to basename inMAKE_STATUSmacro viastrrchr()to reduce information disclosure even in verbose mode.Changes
src/ZVec.php: Addprivate static bool $verboseErrors = falseandbool $verboseErrors = falseparameter toinit(). ModifycheckStatus()to conditionally include file/line/function based on$verboseErrors.ffi/zvec_ffi.cc: Addstrip_path()helper that usesstrrchr()to extract basename. UpdateMAKE_STATUSandSET_FFI_ERRORmacros to usestrip_path(__FILE__).tests/test_error_details.phpt: Updated to useverboseErrors: truesince this test specifically verifies error detail availability.test_verbose_errors_default.phpt,test_verbose_errors_enabled.phpt,test_verbose_errors_path_stripped.phptSecurity Impact
Before:
ZVecException: collection path not exist in /home/forge/php-zvec/ffi/zvec_ffi.cc:560 in function zvec_collection_openAfter:
ZVecException: collection path not exist(default)Closes
Closes #78