Skip to content

[PM-32424] Send Access Enumeration protection#7166

Open
ike-kottlowski wants to merge 7 commits intomainfrom
auth/pm-32424/send-enumeration-protection
Open

[PM-32424] Send Access Enumeration protection#7166
ike-kottlowski wants to merge 7 commits intomainfrom
auth/pm-32424/send-enumeration-protection

Conversation

@ike-kottlowski
Copy link
Contributor

@ike-kottlowski ike-kottlowski commented Mar 6, 2026

🎟️ Tracking

PM-32424

Client PR: bitwarden/clients#19422
SDK PR: bitwarden/sdk-internal#821

📔 Objective

Improve enumeration protection of Sends

📸 Screenshots

@ike-kottlowski ike-kottlowski changed the title Auth/pm 32424/send enumeration protection [PM-32424] Send Access Enumeration protection Mar 6, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

Logo
Checkmarx One – Scan Summary & Details455d4801-076c-458f-b242-11428199c7db

Great job! No new security vulnerabilities introduced in this pull request

@ike-kottlowski ike-kottlowski marked this pull request as ready for review March 6, 2026 19:29
@ike-kottlowski ike-kottlowski requested a review from a team as a code owner March 6, 2026 19:29
@ike-kottlowski ike-kottlowski added the ai-review Request a Claude code review label Mar 6, 2026
@claude
Copy link
Contributor

claude bot commented Mar 6, 2026

Claude finished @ike-kottlowski's task in 4m 13s —— View job


Code Review: PM-32424 Send Access Enumeration protection

Reviewed commits: 1cbb9c36d through fdc43dc3b (8 commits)
Files reviewed: 5 changed files (+35/-46)

Summary

This PR improves enumeration protection for email-OTP-protected Sends by unifying all error responses to return the same InvalidRequest error with the email_and_otp_required status. Previously, distinct errors were returned for invalid OTP (InvalidGrant / "email otp is invalid.") and OTP generation failure (otp_generation_failed), which could allow an attacker to distinguish between these states and narrow their attack surface.

Changes Assessed

Area Assessment
Security The enumeration protection logic is sound. All failure paths in SendEmailOtpRequestValidator (invalid email, OTP sent, invalid OTP, OTP generation failure) now produce identical HTTP response bodies and status codes.
Correctness The BuildErrorResult default parameter pattern (EmailAndOtpRequired) is clean and correctly routes through the existing switch. The CultureInfo.InvariantCulture addition to string.Format for the token cache key is a good defensive practice. The OTP generation failure now appropriately logs an error instead of leaking a distinct error code.
Breaking Changes The invalid OTP response changed from InvalidGrant to InvalidRequest with a different error description. This is intentional and coordinated with the linked client PR (bitwarden/clients#19422) and SDK PR.
Test Coverage Unit tests, integration tests, and snapshot tests are all properly updated to verify the new uniform error behavior across all code paths.

Removed Constants

EmailOtpInvalid ("otp_invalid") and OtpGenerationFailed ("otp_generation_failed") were removed from SendAccessConstants. Verified no remaining references exist in the codebase.

Result

No issues found. This is a well-structured security improvement with good test coverage. Approving.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 6, 2026

@codecov
Copy link

codecov bot commented Mar 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.87%. Comparing base (fa5fde5) to head (fdc43dc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7166      +/-   ##
==========================================
- Coverage   56.87%   56.87%   -0.01%     
==========================================
  Files        2028     2028              
  Lines       88827    88820       -7     
  Branches     7917     7918       +1     
==========================================
- Hits        50523    50518       -5     
+ Misses      36472    36471       -1     
+ Partials     1832     1831       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@JaredSnider-Bitwarden JaredSnider-Bitwarden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants