-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[PM-28508] Fix No validation occurs for Expiration date on Self Host licenses #6655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-28508] Fix No validation occurs for Expiration date on Self Host licenses #6655
Conversation
|
Claude finished @cyprain-okeke's task —— View job Code Review Complete ✅Executive SummaryThis PR addresses a critical security vulnerability (PM-28508) where self-hosted license expiration dates displayed in the Web Vault could be tampered with by manually editing license files. The fix correctly implements the RCA recommendation by extracting expiration dates from cryptographically secured JWT token claims instead of editable file properties. Overall Assessment: ✅ APPROVED - The security fix is correct and effective. Security Assessment ✅Verdict: SECURE - Correctly Addresses Root CauseStrengths:
Security Validation: Code Quality Review✅ File: SubscriptionResponseModel.cs (Lines 53-81)Good:
✅ File: AccountsController.cs (Lines 101-102, 107-108)Good:
✅ File: OrganizationResponseModel.cs (Lines 183-205)Good:
Minor Observation:
✅ File: OrganizationsController.cs (Lines 69-71)Good:
Edge Cases Analysis ✅Scenario 1: Older Licenses Without Tokens
Scenario 2: Tampered License with Valid Token
Scenario 3: Missing Expiration Claim in Token
Scenario 4: Invalid/Expired Token
Completeness Check ✅All License Expiration Display Locations Fixed:
Other license expiration usages in the codebase are for setting database values (not display), so they don't need changes. Test Coverage Assessment
|
src/Core/Billing/Organizations/Commands/UpdateOrganizationLicenseCommand.cs
Outdated
Show resolved
Hide resolved
test/Core.Test/Billing/Services/LicenseExpirationValidationTests.cs
Outdated
Show resolved
Hide resolved
|
New Issues (2)Checkmarx found the following issues in this Pull Request
Fixed Issues (3)Great job! The following issues were fixed in this Pull Request
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6655 +/- ##
==========================================
- Coverage 53.40% 53.39% -0.01%
==========================================
Files 1917 1917
Lines 85466 85507 +41
Branches 7667 7676 +9
==========================================
+ Hits 45643 45660 +17
- Misses 38056 38077 +21
- Partials 1767 1770 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
sbrown-livefront
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small change to simplify logic using helper methods would help keep this verification a bit more readable in addition to a few questions and comments.
test/Core.Test/Billing/Organizations/Commands/UpdateOrganizationLicenseCommandTests.cs
Show resolved
Hide resolved
src/Core/AdminConsole/OrganizationFeatures/Organizations/SelfHostedOrganizationSignUpCommand.cs
Outdated
Show resolved
Hide resolved
src/Core/AdminConsole/OrganizationFeatures/Organizations/SelfHostedOrganizationSignUpCommand.cs
Outdated
Show resolved
Hide resolved
.../AdminConsole/OrganizationFeatures/Organizations/SelfHostedOrganizationSignUpCommandTests.cs
Outdated
Show resolved
Hide resolved
src/Core/Billing/Organizations/Commands/UpdateOrganizationLicenseCommand.cs
Outdated
Show resolved
Hide resolved
amorask-bitwarden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more thorough root cause analysis of this issue was necessary before making these changes. The issue here is not actually related to any validation mechanism for the licenses. The Expires property whose validation is being modified in this PR is useless when the license contains a Token. That JWT is cryptographically secured and appropriately validates expiration. The issue here is with what value we're returning to the Web Vault for display purposes. I.e., we should not be surfacing Expires from the JSON version of the license when the license contains a JWT Token. I left an RCA on the ticket itself that can be consulted to reformulate this PR: https://bitwarden.atlassian.net/browse/PM-28508
amorask-bitwarden
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for updating - still a few changes we should make. Additionally, does this fix need to be implemented for Premium as well?
src/Api/AdminConsole/Models/Response/Organizations/OrganizationResponseModel.cs
Outdated
Show resolved
Hide resolved
| if (claimsPrincipal != null) | ||
| { | ||
| var tokenExpires = claimsPrincipal.GetValue<DateTime>("Expires"); | ||
| if (tokenExpires != default(DateTime)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ I don't think there's a situation where this would be written as the default(DateTime), so you can remove this check and the duplicate else block.
src/Api/AdminConsole/Models/Response/Organizations/OrganizationResponseModel.cs
Outdated
Show resolved
Hide resolved
4df94c9 to
f8148ad
Compare
…piration-date-on-self-host-licenses
…piration-date-on-self-host-licenses
…piration-date-on-self-host-licenses
sbrown-livefront
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅


🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-28508
📔 Objective
Self-hosted license validations were not properly checking expiration dates, allowing users to manipulate expiration dates in license files to be far into the future (e.g., year 3000) and avoid subscription expiration. This security vulnerability allowed tampered licenses to be uploaded and remain valid even after the periodic validation job ran.
Replication Steps
expiresfield to a far future date (e.g., year 3000)Solution
Implemented multiple layers of defense to prevent license expiration date tampering:
Expiresproperty against the cryptographically signed token'sExpiresclaim📸 Screenshots
⏰ Reminders before review
🦮 Reviewer guidelines
:+1:) or similar for great changes:memo:) or ℹ️ (:information_source:) for notes or general info:question:) for questions:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion:art:) for suggestions / improvements:x:) or:warning:) for more significant problems or concerns needing attention:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt:pick:) for minor or nitpick changes