fix(security): harden bot runtime surface (sec-bot-01..09)#44
Open
Abdulkhalek-1 wants to merge 2 commits intomainfrom
Open
fix(security): harden bot runtime surface (sec-bot-01..09)#44Abdulkhalek-1 wants to merge 2 commits intomainfrom
Abdulkhalek-1 wants to merge 2 commits intomainfrom
Conversation
Implements 9 security hardening plans covering the bot process:
- sec-bot-01: regression tests pinning $queryRaw parameterized safety
- sec-bot-02: webhook headers -> strict allowlist (was denylist)
- sec-bot-03: sanitize usernames/guild name before welcome canvas render
(strip bidi overrides, zero-width chars, control chars)
- sec-bot-04: restrict action rule names to [a-zA-Z0-9 _-]{1,50}
- sec-bot-05: templateEngine - fix escape lookbehind so escaped user
content can no longer smuggle core variables into the second pass,
plus adversarial regression tests
- sec-bot-06: validate emoji against Unicode/custom-emoji form before
message.react()
- sec-bot-07: classify auto-role assignment failures by Discord API
error code (50013/10011 warn, others error)
- sec-bot-08: level-up announcements restrict mentions to the leveling
user only via allowedMentions config
- sec-bot-09: add checkBotPermissions for ManageMessages to /warn
Adds sanitizeDisplayName helper in packages/systems/welcome.
Bot test suite: 349 pass / 16 pre-existing baseline failures (no new
regressions). Systems test suite: 234/234 green.
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
Implements 9 security hardening plans covering the bot process.
Notable
sec-bot-05 was meant to be verification-only but the regression tests exposed a real bug: the zero-width escape relied on `String.prototype.includes`, which still matched `{user.id}` even when preceded by `\u200B`. Fixed by replacing the includes-based substitution with a regex using a negative lookbehind for the sentinel. User-controlled values now genuinely cannot smuggle core variables into the second resolver pass.
Changes
Test plan
🤖 Generated with Claude Code