Conversation
Signed-off-by: Kostas Kyrimis <kostas@dragonflydb.io>
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
🤖 Augment PR SummarySummary: Requires authentication on newly created non-privileged Redis connections whenever JWT validation is enabled, even if the default ACL user is 🤖 Was this summary useful? React with 👍 or 👎 |
| } else { | ||
| res->req_auth = !user_registry_.AuthUser("default", ""); | ||
| // JWT validation must gate every connection even if the local "default" user is nopass. | ||
| res->req_auth = acl::JwtValidator::IsEnabled() || !user_registry_.AuthUser("default", ""); |
There was a problem hiding this comment.
src/server/main_service.cc:1897 — Existing non-privileged Redis connections opened while the default user is nopass retain req_auth == false; because this check only runs in CreateContext, they continue executing commands without a JWT after CONFIG SET jwt_validate yes, despite this flag being runtime-mutable. This leaves the intended authentication boundary bypassable until those connections close.
Severity: high
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
| } else { | ||
| res->req_auth = !user_registry_.AuthUser("default", ""); | ||
| // JWT validation must gate every connection even if the local "default" user is nopass. | ||
| res->req_auth = acl::JwtValidator::IsEnabled() || !user_registry_.AuthUser("default", ""); |
There was a problem hiding this comment.
src/server/main_service.cc:1897 — This JWT gate is never reached for MEMCACHE connections: the preceding branch explicitly sets authenticated true and req_auth false. Consequently, enabling --memcached_port alongside JWT validation still gives unauthenticated clients default-user access without a token.
Severity: high
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.
There was a problem hiding this comment.
🟡 Changes recommended
The new JWT gating behavior is security-sensitive and should be covered by an automated regression test to prevent future bypass regressions.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR tightens the authentication gate in main_service so that when JWT-mode auth is enabled, clients can’t bypass authentication via a nopass default user on the Redis protocol listener.
Changes:
- Require authentication on non-privileged Redis connections whenever
acl::JwtValidator::IsEnabled()is true, even ifdefaultwould otherwise authenticate with an empty password.
File summaries
| File | Description |
|---|---|
| src/server/main_service.cc | Forces req_auth when JWT auth is enabled to prevent unauthenticated access via default/nopass. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| } else { | ||
| res->req_auth = !user_registry_.AuthUser("default", ""); | ||
| // JWT validation must gate every connection even if the local "default" user is nopass. | ||
| res->req_auth = acl::JwtValidator::IsEnabled() || !user_registry_.AuthUser("default", ""); |
| res->authenticated = true; // Automatically authenticated for Memcached protocol | ||
| } else { | ||
| res->req_auth = !user_registry_.AuthUser("default", ""); | ||
| // JWT validation must gate every connection even if the local "default" user is nopass. |
PR Summary by QodoEnforce JWT authentication for nopass default users
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
🔴 High 1. Existing clients bypass enabled JWT
|
| } else { | ||
| res->req_auth = !user_registry_.AuthUser("default", ""); | ||
| // JWT validation must gate every connection even if the local "default" user is nopass. | ||
| res->req_auth = acl::JwtValidator::IsEnabled() || !user_registry_.AuthUser("default", ""); |
There was a problem hiding this comment.
🔴 High
1. Existing clients bypass enabled jwt 🐞 Bug ⛨ Security
Service::CreateContext snapshots JwtValidator::IsEnabled() into req_auth only when a connection is created, while jwt_validate can later be changed through CONFIG SET. When JWT is enabled at runtime, existing default-user connections retain req_auth == false and `authenticated == false`, so command dispatch continues accepting their commands without a token.
Agent Prompt
## Issue description
JWT mode is runtime-mutable, but normal connections only capture its state when their context is created. Connections opened while JWT is disabled and the default user is `nopass` therefore remain unrestricted after JWT is enabled.
## Fix Focus Areas
- src/server/main_service.cc[1387-1403]
- src/server/main_service.cc[1880-1902]
- src/server/main_service.cc[1067-1078]
## Recommended Fix
Evaluate the current JWT mode during command dispatch for eligible non-privileged Redis connections, rather than relying only on the connection-time `req_auth` snapshot. Preserve the intentional UDS, privileged, and Memcached exemptions, centralize the eligibility condition so creation and dispatch cannot diverge, and add a test that opens a nopass connection before enabling JWT and verifies its subsequent non-authentication commands receive `NOAUTH`.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Reject a default user authentication without a jwt token when jwt authentication is on