Skip to content

fix: critical security and economy correctness bugs - #152

Closed
cursor[bot] wants to merge 3 commits into
mainfrom
cursor/critical-correctness-bugs-b386
Closed

cursor[bot] wants to merge 3 commits into
mainfrom
cursor/critical-correctness-bugs-b386

Conversation

@cursor

@cursor cursor Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Summary

Automated critical-bug inspection found four high-severity issues in recent code (primarily from PR #130 and existing economy/moderation paths). This PR applies minimal, targeted fixes with regression tests.

Bugs fixed

1. safeEval sandbox bypass (security)

  • Impact: Developer /eval could exfiltrate process.env (bot token, DB URI) via constructor-chain escape and string-concatenated process access.
  • Root cause: PR Security hardening: permission gates, eval sandbox, single interaction path #130 blocklist only matched literal identifiers; VM context still exposed Function via .constructor.
  • Fix: Block constructor/__proto__/prototype, reject .constructor access, use null-prototype VM context.

2. /ban and /kick crash on users not in guild

  • Impact: Uncaught TypeError when getMember() returns null (user not in server).
  • Root cause: Missing null guard before .bannable/.kickable (timeout already had this guard).
  • Fix: Early reply when member is null.

3. /deposit and /withdraw balance corruption

  • Impact: Concurrent commands could double-spend; Math.abs() on negative wallet/bank turned race losses into money creation.
  • Root cause: Read-modify-write without per-user lock; abs "correction" amplified corruption.
  • Fix: Shared economy lock (same pattern as /rob); removed Math.abs.

4. /beg ghost credits

  • Impact: Users without an economy account could see a positive beg result with no DB update.
  • Root cause: Wallet update gated on existing account but success embed sent regardless.
  • Fix: Require account before applying changes.

Validation

  • npm test — 57/57 passing (9 new regression tests)
  • Manual verification: constructor-chain safeEval bypass now rejected

Notes

PR #135 (actions/checkout bump) was reviewed separately; no application-code issues found in that diff.

Open in Web View Automation 

cursoragent and others added 3 commits September 13, 2026 02:23
PR #130 added a VM sandbox for /eval, but string-concatenated process access
and Function constructor chains could still read process.env. Block
constructor/__proto__/prototype identifiers, reject .constructor access,
and use a null-prototype VM context.

Co-authored-by: Daan Vrieling <contact@zvapor.xyz>
getMember() returns null for users outside the server. Accessing
member.bannable/kickable threw an uncaught TypeError and broke the command.

Co-authored-by: Daan Vrieling <contact@zvapor.xyz>
Add per-user locks before DB reads in deposit/withdraw (same pattern as /rob).
Remove Math.abs balance correction that turned race-induced negatives into
created money. Require an economy account before /beg applies wallet changes.

Co-authored-by: Daan Vrieling <contact@zvapor.xyz>
@zVapor-Dev
zVapor-Dev marked this pull request as ready for review September 16, 2026 22:51
@zVapor-Dev zVapor-Dev closed this Sep 16, 2026
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.

2 participants