Skip to content

fix: critical security vulnerabilities#1

Open
peleg-development wants to merge 1 commit into
sanashaju:mainfrom
peleg-development:fix/security-vulnerabilities
Open

fix: critical security vulnerabilities#1
peleg-development wants to merge 1 commit into
sanashaju:mainfrom
peleg-development:fix/security-vulnerabilities

Conversation

@peleg-development

Copy link
Copy Markdown

Security Fixes

Critical

  • Privilege Escalation via Registration: Removed role from accepted registration fields. Previously, any user could register as admin by sending {"role": "admin"} in the request body.
  • Unauthenticated User Routes: Added verifyUser middleware to GET /api/users and GET /api/users/:id. These routes were publicly accessible without any authentication.

Medium

  • Regex Injection (ReDoS): Escaped special regex characters in category and role query filters to prevent Regular Expression Denial of Service attacks.
  • Missing Security Headers: Enabled helmet middleware (was imported but never used).
  • Password Logging: Removed console.log(req.body) from registration handler that logged passwords in plaintext.
  • Role Enum Restriction: Restricted User model role field to ["user", "admin"] enum to prevent arbitrary role values.
  • Login Response Leak: Removed role field from login response to avoid exposing internal role structure.

- Remove role from registration request body (privilege escalation)
- Add authentication to user listing routes
- Escape regex special characters in query filters (ReDoS)
- Enable helmet middleware for security headers
- Restrict user role field to enum values
- Remove console.log leaking request body with passwords
- Remove role from login response
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