Skip to content

fix(plugin): avoid BanClient before the player entity exists - #47

Merged
Rushaway merged 1 commit into
mainfrom
fix/verifyban-before-entity
Sep 30, 2026
Merged

Rushaway merged 1 commit into
mainfrom
fix/verifyban-before-entity

Conversation

@Rushaway

Copy link
Copy Markdown
Member

Port of upstream sbpp#1580 (a418884c).

Problem

VerifyBan runs from OnClientAuthorized, which can fire before OnClientPutInServer. Our fork bans there with BanClient(), which resolves the client via ReferenceToIndex(). That returns -1 while the player has no entity, so SourceMod throws Client index -1 is invalid and the banned player is never kicked.

Fix

Use entity-independent natives that behave like BanClient:

  • GetClientAuthId(AuthId_Engine) + BanIdentity(..., BANFLAG_AUTHID), then KickClient. This keeps the engine-native auth string, so Synergy still works.
  • If the auth lookup or ban fails (LAN), KickClientEx then BanIdentity(ip, BANFLAG_IP). Kicking first matches BanClient's order.

Our fork-specific bits are kept: SetGlobalTransTarget + %t message and the "sbpp" command tag.

The other BanClient call sites are safe. SBPP_BanIdentity already checks IsClientInGame, and sm_ban only targets in-game players.

Verification

spcomp isn't available locally, so the plugin-build CI gate does the compile. Signatures were checked by hand against the SourceMod API.

🤖 Generated with Claude Code

VerifyBan runs from OnClientAuthorized, which can land before
OnClientPutInServer. BanClient() resolves the client through
ReferenceToIndex(), which returns -1 while the edict has no entity, so
SourceMod threw "Client index -1 is invalid" and the banned player was
never kicked.

Ban the engine auth string with BanIdentity (keeps Synergy's native
Steam3 form) and KickClient; when the auth lookup fails or the server
is LAN, KickClientEx then ban the IP, matching BanClient's
kick-then-addip order.

Port of upstream sbpp#1580 (a418884).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rushaway
Rushaway merged commit d165c34 into main Sep 30, 2026
1 check passed
@Rushaway
Rushaway deleted the fix/verifyban-before-entity branch September 30, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant