fix: address five medium-severity auth lifecycle security gaps#52
Draft
fix: address five medium-severity auth lifecycle security gaps#52
Conversation
- Finding 1: Remove responseUrl from error log in AuthService to prevent JWT leakage - Finding 2: Validate assetId format and remove isManualRetry side-effect in handleAssetUpload - Finding 3: Validate dataUrl prefix and add max canvas dimension check in offscreen.ts - Finding 4: Add deleteAccount() to NumbersApiManager that clears persistent storage - Finding 5: Replace direct token restoration with numbersApi.initialize() for validation Co-authored-by: numbers-official <181934381+numbers-official@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [Security] Fix auth lifecycle gaps related to token leak and validation
fix: address five medium-severity auth lifecycle security gaps
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Five medium-severity security issues across auth lifecycle, payload validation, and data handling: potential OIDC JWT leakage to logs, unvalidated message payloads, SSRF/DoS vectors in the offscreen document, incomplete persistent storage cleanup on account deletion, and bypassed token validation on restoration.
Changes
Token leak in logs (
AuthService.ts)responseUrlfrom the error log inauthenticateWithGoogle()— the URL's hash fragment may contain the OIDC ID token (JWT with email, name, Google ID)Unvalidated
assetIdpayload (service-worker.ts)ASSET_ID_PATTERN = /^screenshot_\d+_[a-z0-9]+$/constant and validatesassetIdbefore IndexedDB access inhandleAssetUploadisManualRetry=truefromaddToQueue()— a craftedUPLOAD_ASSETmessage could otherwise unpause a queue the user intentionally paused (e.g. due to insufficient credits)Unvalidated image data URLs (
offscreen.ts)validateImagePayload()helper (called in bothcropImageandaddWatermark) that enforcesdataUrl.startsWith('data:image/')and caps dimensions atMAX_CANVAS_DIMENSION = 16384new Image()and DoS through oversized canvas allocationsIncomplete account deletion (
NumbersApiManager.ts)deleteAccount()toNumbersApiManager— the existingAuthService.deleteAccount()only cleared the in-memory token; email, username, and token persisted inchrome.storage.localAuth token restoration bypassing validation (
service-worker.ts)numbersApi.setAuthToken(storedAuth.token)withawait numbersApi.initialize(), which validates the restored token against the API and clears it if expired/revokedOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.