Repository navigation
Fix SQL injection in bStrArr() by binding each value - #12
Merged
Merged
Conversation
Statement::bStrArr() pasted the values into the SQL between quotes without escaping them, so a value containing a quote could change the query. Each value is now bound as its own named parameter (:arr0, :arr1, ...) and the %% placeholder becomes the list of those names. The calling code and getComputed() output are unchanged. getComputed() now fills raw placeholders before named ones, matching execute(). The binding-layer bStrArr() methods are kept for custom binding classes but marked deprecated. Also adds the 4.0.11 CHANGELOG entry and README updates for this and the bInt() fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Security fix.
Statement::bStrArr()pasted its values into the SQL between quotes without escaping them:Each value is now bound as its own named parameter (
:arr0, :arr1, …), and the%%placeholder becomes that list of names. Calling code doesn't change, andgetComputed()still showsIN ('Germany', 'USA').Details
:arrNnames, so they never shift the positions of?placeholders around them.$defaultraw, as before. The README now warns not to pass untrusted input as$default.NULLvalues become'', as they did withimplode(). Arrays and objects throwInvalidArgumentException.getComputed()now fills raw (%%) placeholders before named ones, matching whatexecute()does.bStrArr()methods (StringBindingInterface,Bindings,MySQLStringBindings) are kept so custom binding classes don't break, but are marked@deprecated.Statementno longer calls them.bInt()fix in Fix bInt() turning negative numbers into huge positive ones #11.Tests: 4 new tests: injection attempt, mixed
?and array placeholders, empty array, non-scalar value. The full suite passes against MySQL 8.4 (54 tests), along with PHPStan level 8 and PSR-12.🤖 Generated with Claude Code