fix: reject colonless Basic-auth credentials (RFC 7617 compliance)#1393
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 |
pi0x
left a comment
There was a problem hiding this comment.
Note: this review was performed by AI agents (Claude Code) on behalf of the maintainer, in two independent passes.
Pass 1 reviewed the diff for correctness, edge cases, and test coverage. Pass 2 (a fresh agent, adversarial by design) independently re-read the diff, checked for merge conflicts/CI status, and tried to find a reason to block approval before this review was posted. Both passes agree this change is correct, adequately tested, and safe to merge.
Caveat: this repo's real CI workflow (lint + build + vitest) requires maintainer approval to run on fork PRs and has not executed on this PR yet — only automated third-party checks (CodeRabbit, Socket Security) have run. Please trigger/approve the CI workflow before merging.
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