Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ELEVENLABS_STT_MODEL,
JOINER_MESSAGE_MAX_TOKENS,
MAX_PENDING_AUDIO_CHUNKS,
MAX_CHUNK_SIZE_BYTES,
MAX_PROMPT_LENGTH,
MIN_MEETING_DURATION_FOR_WELCOME,
SUMMARIZATION_MAX_TOKENS,
Expand Down Expand Up @@ -67,7 +68,7 @@
label: string; // for debug logging
}

class ApiTransactionManager {

Check warning on line 71 in src/background.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Mark these members as `readonly`.

See more on https://sonarcloud.io/project/issues?id=shouri123_Late-Meet&issues=AZ-ARdeBi_a6BKYeZleN&open=AZ-ARdeBi_a6BKYeZleN&pullRequest=885
private static instance: ApiTransactionManager | null = null;
private static readonly MAX_RETRIES = 5;
private static readonly BASE_DELAY_MS = 1_000;
Expand Down Expand Up @@ -2027,13 +2028,25 @@
return;
}

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;
}
Comment on lines +2031 to +2036

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.


if (typeof message.audioBase64 !== "string" || !message.audioBase64) {
sendResponse({ success: false, error: "Missing audio chunk payload" });
return;
}

const base64Len = message.audioBase64?.length ?? 0;
const approxBytes = Math.round((base64Len * 3) / 4);
if (approxBytes > MAX_CHUNK_SIZE_BYTES) {
console.warn("[LateMeet] chunk rejected β€” exceeds max size:", approxBytes);
sendResponse({ success: false, error: "Chunk exceeds maximum allowed size" });
return;
}
if (DEBUG) {
console.log(
`[LateMeet] chunk received β€” ~${approxBytes} bytes mimeType=${message.mimeType}`,
Expand Down
3 changes: 3 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ export const MAX_PENDING_CHUNKS = 20;

/** Timeout in milliseconds for draining pending audio chunks before dropping them. */
export const DRAIN_TIMEOUT_MS = 30000;

/** Maximum size in bytes for a single audio chunk payload. Prevents memory exhaustion from oversized chunks. */
export const MAX_CHUNK_SIZE_BYTES = 10 * 1024 * 1024;
4 changes: 3 additions & 1 deletion src/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ <h1 class="setup-title">Initialize Copilot</h1>
</div>
</div>
</div>
<button id="settings-btn" class="icon-btn" aria-label="Settings">βš™οΈ</button>
<button id="settings-btn" class="icon-btn" title="Settings" aria-label="Settings">
βš™οΈ
</button>
</header>

<!-- Content Sections -->
Expand Down
Loading