-
Notifications
You must be signed in to change notification settings - Fork 318
fix: verify signed online license entitlements #1442
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- AlterTable | ||
| ALTER TABLE "License" ADD COLUMN "licenseAssertion" TEXT; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,8 @@ import { | |
| decryptActivationCode, | ||
| env, | ||
| SOURCEBOT_VERSION, | ||
| isValidOfflineLicenseActive | ||
| isValidOfflineLicenseActive, | ||
| verifyOnlineLicenseAssertion, | ||
| } from "@sourcebot/shared"; | ||
| import { client } from "./client"; | ||
| import { ServicePingRequest } from "./types"; | ||
|
|
@@ -127,6 +128,13 @@ export const syncWithLighthouse = async (orgId: number) => { | |
|
|
||
| // If we have a license and Lighthouse returned license data, sync it | ||
| if (license && response.license) { | ||
| if (response.licenseAssertion && !verifyOnlineLicenseAssertion(response.licenseAssertion)) { | ||
| // Never persist an assertion we cannot authenticate. In particular, | ||
| // do not silently write only the legacy fields and create a | ||
| // signature-downgrade path. | ||
| throw new Error('Lighthouse returned an invalid online license assertion'); | ||
| } | ||
|
Comment on lines
129
to
+136
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟠 Major | ⚡ Quick win Handle assertion presence independently and fail closed.
Proposed fix+ const hasLicenseAssertion = response.licenseAssertion !== undefined;
+ if (hasLicenseAssertion && !response.license) {
+ throw new Error('Lighthouse returned an assertion without license data');
+ }
+ if (hasLicenseAssertion && !verifyOnlineLicenseAssertion(response.licenseAssertion)) {
+ throw new Error('Lighthouse returned an invalid online license assertion');
+ }
+
// If we have a license and Lighthouse returned license data, sync it
if (license && response.license) {
- if (response.licenseAssertion && !verifyOnlineLicenseAssertion(response.licenseAssertion)) {
- throw new Error('Lighthouse returned an invalid online license assertion');
- }
-
// ...
- ...(response.licenseAssertion && { licenseAssertion: response.licenseAssertion }),
+ ...(hasLicenseAssertion && { licenseAssertion: response.licenseAssertion }),
}Also applies to: 185-185 🤖 Prompt for AI Agents |
||
|
|
||
| const { | ||
| entitlements, | ||
| seats, | ||
|
|
@@ -174,6 +182,7 @@ export const syncWithLighthouse = async (orgId: number) => { | |
| yearlyPeakSeats: yearlyTermStatus?.peakSeats ?? null, | ||
| lastSyncAt: new Date(), | ||
| lastSyncErrorCode: null, | ||
| ...(response.licenseAssertion && { licenseAssertion: response.licenseAssertion }), | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stale assertion survives license syncHigh Severity The license sync updates mutable fields but retains the existing Reviewed by Cursor Bugbot for commit fe50da2. Configure here. |
||
| }, | ||
| }); | ||
|
|
||
|
|
||


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.
🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
Repository: sourcebot-dev/sourcebot
Length of output: 11713
🏁 Script executed:
Repository: sourcebot-dev/sourcebot
Length of output: 19338
🏁 Script executed:
Repository: sourcebot-dev/sourcebot
Length of output: 4348
🏁 Script executed:
Repository: sourcebot-dev/sourcebot
Length of output: 1211
Bind online assertions to a persisted license ID.
installIdalone still lets a valid assertion be reused across differentLicenserows on the same installation. Persist the upstreamlicenseId, compare it before accepting the assertion, and add a cross-license replay test.🤖 Prompt for AI Agents