Conversation
Enhanced Kban_RemoveBan function to escape additional parameters for admin Steam ID, reason, and client IP.
Add IP escaping for database update to prevent SQL injection.
Member
Author
There was a problem hiding this comment.
Pull request overview
This PR hardens SQL input handling in the KnockbackRestrict SourceMod plugin by expanding DB string escaping across several query paths, and it improves unban log consistency by including the unban reason in server logs.
Changes:
- Escapes additional DB-bound fields (SteamID, IP, map, message) in multiple query/insert/update paths to reduce SQL injection/malformed input risk.
- Updates unban logging (
KbRestrict_srvlogs.message) to include the (escaped) unban reason. - Fixes the offline unban menu UPDATE to correctly set
reason_removedand adds a missingWHEREclause to prevent broad updates.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| addons/sourcemod/scripting/KnockbackRestrict.sp | Adds escaping for more query inputs; includes unban reason in srvlogs; hardens verification and post-insert lookups. |
| addons/sourcemod/scripting/include/KnockbackRestrict.inc | Bumps patch version from 4.0.7 to 4.0.8. |
| addons/sourcemod/scripting/helpers/menus.sp | Fixes offline unban UPDATE correctness (reason assignment + WHERE) and escapes added parameters. |
Removed unnecessary escaping of SteamID and IP in queries. Simplified database queries by directly using the SteamID and IP from the g_sSteamIDs and g_sIPs arrays.
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
This PR improves SQL safety across the plugin by escaping all user-influenced string inputs before query formatting, and fixes inconsistencies in unban logging behavior.
What Changed
Kban_PublishKunbanto actually use the unban reason inKbRestrict_srvlogs.message:Removed KbanRemoved Kban (Reason: %s)(escaped)client_steamidclient_ipadmin_steamidmapmessageVerifyKbanClientby escaping SteamID/IP beforeSELECTandUPDATEqueries.Kban_AddBanandKban_AddOfflineBanby escaping additional DB-bound fields, not only names/reason.OnKbanAddedlookup query by escaping SteamID/IP inWHERE.helpers/menus.sp:reason_removedassignment.WHEREclause to avoid broad updates.Why
UPDATEstatement and noWHERE, which was risky.Kban_PublishKunbanescapedreasonbut did not use it in SQL logs, creating a logic mismatch.Impact