Skip to content

fix: critical security issues#70

Merged
AlexJuca merged 2 commits into
mainfrom
fix-critical-security-issues
Apr 26, 2026
Merged

fix: critical security issues#70
AlexJuca merged 2 commits into
mainfrom
fix-critical-security-issues

Conversation

@AlexJuca
Copy link
Copy Markdown
Owner

This PR adds security improvements based on #67 audit performed.

It mainly focused on fixing buffer/memory bugs

added network security fixes:

  • Socket creation check: == 0 → < 0 (socket returns -1 on error, 0 is valid)
  • Added SO_REUSEADDR to server socket
  • Unix socket permissions: 0777 → 0770
  • Fixed fd leaks on error paths in start_client/start_uds_client

and also hardens the event loop:

  • try_process_frames now returns int (-1 on protocol error) so callers disconnect the client
  • After freeing a client, remaining events in the batch are nullified (prevents use-after-free)
  • VLA size capped at 1024 to prevent stack overflow

…erts

Replace all assert() calls with proper runtime error handling since
asserts are no-ops in release builds. Fix critical bugs: wbuf_append
overflow check, DECR_BY adding instead of subtracting, config parser
dangling pointers to stack locals, socket() return value check, memory
leaks on error paths, and use-after-free in event loops from stale
event references. Cap VLA event arrays at 1024, restrict Unix socket
permissions to 0770, add SO_REUSEADDR, and bound sscanf formats.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@AlexJuca AlexJuca self-assigned this Mar 13, 2026
@AlexJuca AlexJuca added the security security issues label Mar 13, 2026
@AlexJuca AlexJuca merged commit eeb1f09 into main Apr 26, 2026
2 checks passed
@AlexJuca AlexJuca deleted the fix-critical-security-issues branch April 26, 2026 21:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security security issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant