Skip to content

fix(security): validate offscreen sender origin and enforce audio chunk size limit#885

Open
Siddh2024 wants to merge 3 commits into
shouri123:mainfrom
Siddh2024:fix/875-offscreen-origin-validation
Open

fix(security): validate offscreen sender origin and enforce audio chunk size limit#885
Siddh2024 wants to merge 3 commits into
shouri123:mainfrom
Siddh2024:fix/875-offscreen-origin-validation

Conversation

@Siddh2024

@Siddh2024 Siddh2024 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

🚀 Pull Request: Origin Validation & Size Enforcement for Audio Chunks (#875)

Issue: Critical: Offscreen audio chunk messages lack origin validation — any extension page can inject fake audio data (#875)

Problem:
The OFFSCREEN_AUDIO_CHUNK message handler in src/background.ts accepted audio data from any extension page without verifying the sender was the legitimate offscreen document. This created a defense-in-depth gap where a compromised extension page could:

  1. Flood the background worker with fake chunks -> memory exhaustion
  2. Drive up API costs by injecting fabricated audio sent to ElevenLabs/OpenAI
  3. Starve legitimate processing by exhausting the audio chunk queue

Additionally, there was no maximum size cap on the base64 payload, enabling multi-megabyte chunk attacks.

What Changed:

Origin Validation (src/background.ts):

  • Added sender URL check — rejects chunks not originating from offscreen.html
  • Provides clear console warning with the offending sender URL
  • Returns { success: false, error: "Unauthorized sender" } response

Size Enforcement:

  • Added MAX_CHUNK_SIZE_BYTES = 10 * 1024 * 1024 (10 MB) to src/config.ts
  • Early rejection before enqueue — prevents memory exhaustion
  • Warns in console with actual chunk size

Defense Layers:
1 - URL origin check - background.ts
2 - Payload size cap - background.ts
3 - Session active check (existing) - background.ts
4 - Queue capacity check (existing) - background.ts

Testing:

  • Messages from offscreen.html: accepted as before
  • Messages from popup/dashboard/unknown URLs: rejected with "Unauthorized sender"
  • Chunks > 10 MB: rejected with "Chunk exceeds maximum allowed size"
  • Null/undefined sender.url: allowed through (graceful fallback for edge cases)
  • Existing session-active and queue-capacity checks still function

Summary by CodeRabbit

  • Bug Fixes

    • Improved audio processing reliability by rejecting oversized audio chunks.
    • Added validation to ensure audio data is received from the authorized source.
  • Accessibility

    • Added a visible tooltip to the Settings button for clearer interaction guidance.

Several icon-only buttons (toggle visibility, settings) lacked aria-label
attributes, making them inaccessible to screen readers.

Adds descriptive aria-label to:
- Toggle key visibility button in popup
- Settings button in popup header
- Toggle visibility buttons in options page

Fixes shouri123#865
@Siddh2024
Siddh2024 requested a review from shouri123 as a code owner July 20, 2026 16:04
@github-actions github-actions Bot added gssoc Official GSSoC contribution issue gssoc:approved GSSoC: PR approved and scored labels Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Thank You for Contributing to Late-Meet

Please ensure that:

  • the issue was assigned to you before opening this PR
  • the PR references the related issue
  • your changes follow repository contribution guidelines
  • the project builds successfully before submission

Unassigned, duplicate, or low-quality PRs may be closed.

Thank you for contributing 💙

@github-actions github-actions Bot added bug Something isn't working size/S type:testing Type: Testing (Optional bonus) needs-issue labels Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you @Siddh2024 for your contribution to Late-Meet!

⚠️ Warning: This PR does not seem to link to an open issue. Please edit the PR description to include Closes #XX to ensure your contribution counts for GSSoC points.

Please review any automated suggestions or code review comments that may appear below! We will review your PR as soon as possible!


Please consider starring the repository ⭐ to show your support!

@github-actions github-actions Bot added type:code Type: Code change security-review Requires security review before merge labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The service worker now authorizes audio chunk senders and rejects payloads exceeding a 10 MB limit before queueing. The popup settings button adds a title attribute while retaining its aria-label.

Changes

Audio chunk validation

Layer / File(s) Summary
Audio chunk acceptance gates
src/config.ts, src/background.ts
The audio pipeline defines a 10 MB chunk limit and rejects chunks from unauthorized senders or exceeding that limit before transcription queueing.

Settings button tooltip

Layer / File(s) Summary
Settings button metadata
src/popup.html
The settings button adds a title="Settings" attribute and reformats its emoji markup.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

Suggested labels: type:security, component:audio

Suggested reviewers: shouri123

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: validating offscreen sender origin and enforcing an audio chunk size limit.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/background.ts`:
- Around line 2031-2036: Update the sender validation in the message handler
around senderUrl to compare sender.url against the existing
OFFSCREEN_DOCUMENT_URL value, rather than accepting any URL ending with
"offscreen.html". Preserve the unauthorized response and early return for every
sender whose URL does not exactly match the extension’s offscreen document URL.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ec340936-a391-4ed7-950f-c8de24885a48

📥 Commits

Reviewing files that changed from the base of the PR and between d216444 and daa3d01.

📒 Files selected for processing (3)
  • src/background.ts
  • src/config.ts
  • src/popup.html

Comment thread src/background.ts
Comment on lines +2031 to +2036
const senderUrl = sender.url ?? "";
if (senderUrl && !senderUrl.endsWith("offscreen.html")) {
console.warn("[LateMeet] chunk rejected — unauthorized sender:", senderUrl);
sendResponse({ success: false, error: "Unauthorized sender" });
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Strengthen sender origin validation.

Validating the sender by checking if the URL ends with "offscreen.html" is vulnerable to spoofing. A content script running on an external website with a matching path (e.g., https://evil-website.com/offscreen.html) would pass this check and could spam or overflow the audio queue.

Since OFFSCREEN_DOCUMENT_URL is already defined at line 44, you should use it to ensure the message strictly originates from your extension's offscreen document.

🔒️ Proposed fix to strictly validate the extension's offscreen URL
         const senderUrl = sender.url ?? "";
-        if (senderUrl && !senderUrl.endsWith("offscreen.html")) {
+        if (senderUrl && !senderUrl.startsWith(OFFSCREEN_DOCUMENT_URL)) {
           console.warn("[LateMeet] chunk rejected — unauthorized sender:", senderUrl);
           sendResponse({ success: false, error: "Unauthorized sender" });
           return;
         }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const senderUrl = sender.url ?? "";
if (senderUrl && !senderUrl.endsWith("offscreen.html")) {
console.warn("[LateMeet] chunk rejected — unauthorized sender:", senderUrl);
sendResponse({ success: false, error: "Unauthorized sender" });
return;
}
const senderUrl = sender.url ?? "";
if (senderUrl && !senderUrl.startsWith(OFFSCREEN_DOCUMENT_URL)) {
console.warn("[LateMeet] chunk rejected — unauthorized sender:", senderUrl);
sendResponse({ success: false, error: "Unauthorized sender" });
return;
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/background.ts` around lines 2031 - 2036, Update the sender validation in
the message handler around senderUrl to compare sender.url against the existing
OFFSCREEN_DOCUMENT_URL value, rather than accepting any URL ending with
"offscreen.html". Preserve the unauthorized response and early return for every
sender whose URL does not exactly match the extension’s offscreen document URL.

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

Labels

bug Something isn't working gssoc:approved GSSoC: PR approved and scored gssoc Official GSSoC contribution issue needs-issue security-review Requires security review before merge size/S type:code Type: Code change type:testing Type: Testing (Optional bonus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant