fix: reject colonless Basic-auth credentials (RFC 7617 compliance)#1393
fix: reject colonless Basic-auth credentials (RFC 7617 compliance)#1393francisjohnjohnston-web wants to merge 1 commit into
Conversation
A colonless decoded credential made indexOf(":") return -1, so
slice(0, -1) / slice(0) split e.g. "admins" into user="admin",
pass="admins". With matching config this authenticated a malformed
credential. Reject when no colon is present (RFC 7617).
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe pull request adds explicit validation to the Basic authentication handler to reject credentials lacking the required RFC 7617 colon delimiter. The implementation adds an early check in ChangesBasic Auth Colon Delimiter Validation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Bug
requireBasicAuthsilently authenticates colonless credentials.When a credential string has no
:separator,indexOf(":")returns-1. The subsequent slices become:authDecoded.slice(0, -1)→ trims the last character (e.g."admins"→"admin")authDecoded.slice(0)→ the full string ("admins")So the colonless credential
"admins"mis-parses intousername="admin"/password="admins". If the server has{ username: "admin", password: "admins" }configured, the malformed credential authenticates successfully.Fix
Reject immediately when
colonIndex === -1. RFC 7617 §2 defines the format asuser-id ":" password; a missing colon is an unconditionally invalid credential.Test
Added a regression test that sends
Basic base64("admins")against a server configured with{ username: "admin", password: "admins" }. Before this fix the test returned 200; after it returns 401.All 36 existing auth tests pass.
Summary by CodeRabbit