Skip to content

feat(#653): add strict CSP directives for security hardening - #904

Open
Shan7Usmani wants to merge 4 commits into
shouri123:mainfrom
Shan7Usmani:fix/653-strict-csp-directives
Open

feat(#653): add strict CSP directives for security hardening#904
Shan7Usmani wants to merge 4 commits into
shouri123:mainfrom
Shan7Usmani:fix/653-strict-csp-directives

Conversation

@Shan7Usmani

@Shan7Usmani Shan7Usmani commented Jul 25, 2026

Copy link
Copy Markdown

Description

Adds missing CSP directives to the MV3 manifest to block unauthorized external scripts, base tag injection, and form-based exfiltration vectors.

Changes

  • Added \worker-src 'self'\ — restricts Web Workers and Service Workers to extension files only
  • Added \�ase-uri 'self'\ — prevents <base>\ tag injection attacks
  • Added \ orm-action 'self'\ — blocks forms from submitting to external URLs

Testing

  • TypeScript compiles clean (\ sc --noEmit)
  • Existing tests pass
  • CSP directives verified against Chrome MV3 documentation

Fixes #653

Summary by CodeRabbit

  • Security

    • Strengthened extension security protections.
    • Improved handling of transcript content, topic summaries, action counts, and status messages to prevent unsafe content from appearing in the interface.
  • Documentation

    • Added troubleshooting guidance for audio capture, API authorization, meeting detection, build caching, and extension error logs.
    • Updated instructions for customizing global keyboard shortcuts.

Shan7Usmani and others added 4 commits June 24, 2026 20:02
…icipant names

- Fix initials derivation in createTranscriptEntryHTML to use escaped speaker
- Use sanitizeDataAttr for data-* attributes instead of escapeHtml
- Consolidate duplicate escapeHtml: deprecate sanitize.ts version, keep domHelpers.ts canonical
- Harden getEmptyStateHTML and truncatedNoticeHtml with escapeHtml for defense-in-depth
- Add domHelpers.test.ts with XSS, attribute-context, and regression tests
- Update sanitize.test.ts to import escapeHtml from canonical source
- Remove redundant DOM mock from sanitize.test.ts

Audit result: 0 active XSS vulnerabilities across all 47 innerHTML assignments.
@Shan7Usmani
Shan7Usmani requested a review from shouri123 as a code owner July 25, 2026 07:42
@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 gssoc Official GSSoC contribution issue gssoc:approved GSSoC: PR approved and scored type:docs Type: Documentation type:code Type: Code change type:test Type: Test files security-review Requires security review before merge size/L type:feature Type: New Feature type:testing Type: Testing (Optional bonus) and removed gssoc Official GSSoC contribution issue gssoc:approved GSSoC: PR approved and scored labels Jul 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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

✅ Verified: You are assigned to the linked issue #653.

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!

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR centralizes HTML escaping, applies sanitization across dashboard-rendered values, expands utility tests, strengthens the extension-page CSP, and replaces troubleshooting documentation with scenario-based guidance.

Changes

Security hardening and documentation

Layer / File(s) Summary
Centralized escaping and validation coverage
src/utils/domHelpers.test.ts, src/utils/sanitize.ts, src/utils/sanitize.test.ts
escapeHtml is re-exported from domHelpers, with expanded coverage for HTML, attribute, injection, duration, and topic-status handling.
Dashboard output sanitization
src/dashboard.ts
Rendered notices, transcript speakers, transcript dataset attributes, and empty-state messages now escape or sanitize embedded values.
CSP and troubleshooting guidance
src/manifest.json, README.md
The extension CSP adds worker-src, base-uri, and form-action restrictions; README troubleshooting and shortcut guidance are updated.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested labels: component:manifest, type:config, level:intermediate

Suggested reviewers: shouri123

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR includes unrelated dashboard/sanitize refactors and README updates beyond the manifest CSP work requested by #653. Trim the PR to the manifest CSP change, or split the README and sanitization/test refactors into separate follow-ups.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and clearly describes the main change: adding strict CSP directives for security hardening.
Linked Issues check ✅ Passed The manifest update adds strict CSP directives that restrict workers, bases, and forms to self, matching #653.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/dashboard.ts (1)

1075-1102: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep raw transcript values separate from HTML-escaped display values.

sanitizeDataAttr(speaker/timeStr/text) escapes the & introduced by escapeHtml; after HTML parsing, dataset still contains entity text (for example, &amp; rather than &), so copied transcript content is corrupted. The same sequencing produces & as the avatar initial for speakers beginning with an escapable character.

  • src/dashboard.ts#L1075-L1102: retain raw speaker/time/text values; derive initials and isAudio from raw speaker, pass raw values to sanitizeDataAttr, and use escapeHtml only for rendered text.
  • src/utils/domHelpers.test.ts#L50-L70: update the regression test to derive initials from the raw speaker and escape only the final rendered initial.
🤖 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/dashboard.ts` around lines 1075 - 1102, Separate raw transcript values
from escaped display values in createTranscriptEntryHTML: derive initials and
isAudio from raw speaker, pass raw speaker/time/text to sanitizeDataAttr, and
apply escapeHtml only when rendering visible HTML. Update
src/utils/domHelpers.test.ts lines 50-70 to derive initials from the raw speaker
and escape only the final rendered initial; both sites require changes.
🤖 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 `@README.md`:
- Line 1019: Update the “Background Script Errors” troubleshooting instruction
in README.md to direct users to click the service worker link under “Inspect
views” for Late-Meet, instead of referencing background.ts/background.js
filenames. Keep the existing chrome://extensions and Developer mode navigation
intact.

---

Outside diff comments:
In `@src/dashboard.ts`:
- Around line 1075-1102: Separate raw transcript values from escaped display
values in createTranscriptEntryHTML: derive initials and isAudio from raw
speaker, pass raw speaker/time/text to sanitizeDataAttr, and apply escapeHtml
only when rendering visible HTML. Update src/utils/domHelpers.test.ts lines
50-70 to derive initials from the raw speaker and escape only the final rendered
initial; both sites require changes.
🪄 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 Plus

Run ID: fd78f68f-9a1b-4066-8a9f-1eaabe11cc6a

📥 Commits

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

📒 Files selected for processing (6)
  • README.md
  • src/dashboard.ts
  • src/manifest.json
  • src/utils/domHelpers.test.ts
  • src/utils/sanitize.test.ts
  • src/utils/sanitize.ts

Comment thread README.md
If an error persists or you run into a transcript drop mid-meeting, check the hidden developer logs to find the exact error code:

- **Popup Errors:** Right-click anywhere inside the extension popup window and select **Inspect**. Look at the _Console_ tab.
- **Background Script Errors:** Go to `chrome://extensions/`, enable **Developer mode** (top right toggle), find **Late-Meet**, and click on the `background.ts` / `background.js` link next to "Inspect views".

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "README snippet:"
sed -n '1015,1022p' README.md || true

echo
echo "Manifest/package hints:"
for f in manifest.json manifest.json5 manifest.v3.json package.json; do
  if [ -f "$f" ]; then
    echo "--- $f ---"
    sed -n '1,180p' "$f"
  fi
done

echo
echo "Background-related files tracked:"
git ls-files | grep -Ei '\b(background|service_worker|sw)\.(ts|js|tsx|jsx)$|manifest\.(json|json5|v3\.json)$' || true

Repository: shouri123/Late-Meet

Length of output: 3219


🌐 Web query:

Chrome extensions Manifest V3 debug background service worker Inspect views service worker inactive

💡 Result:

In Chrome Manifest V3, the "service worker (inactive)" status is expected behavior rather than an error [1][2]. Chrome automatically terminates extension service workers after approximately 30 seconds of inactivity to conserve system resources [3][4]. The worker will automatically restart when a registered event (such as an extension API call, browser action, or alarm) occurs [2][5]. To debug or inspect your background service worker, use the following methods: 1. Standard Inspection: Go to chrome://extensions, enable "Developer mode," and click the blue "service worker" link under your extension's "Inspect views." This opens a DevTools window that keeps the service worker active for the duration of the session [1][2][6]. 2. Lifecycle Management: Within the DevTools window for the service worker, navigate to the Application panel and select "Service Workers" from the sidebar [7][2][6]. Here, you can manually "Start" or "Stop" the worker to simulate its lifecycle and test how your extension handles termination [2][8][9]. 3. Advanced Monitoring: For low-level details, including registration scope, status, and error logs, you can visit chrome://serviceworker-internals/ and filter for your extension's ID [10][2][11]. 4. Tips for Effective Debugging: - Persistence: If you need to retain logs across service worker restarts, check the "Preserve log" box in the DevTools Console tab [2]. - Testing Termination: To ensure your extension is resilient to termination (i.e., it does not rely on global variables that disappear when the worker stops), remember to close the DevTools window after debugging, as the presence of an active inspector prevents the worker from going idle [1][6][5]. - Debugging without DevTools: If you need to debug without keeping the worker permanently active, you can open DevTools for another context (like a popup or options page) and access the service worker through the Application tab there, which allows you to switch between contexts without forcing the background script to stay alive [7][8].

Citations:


Refer to the service worker link, not the background filename.

Chrome MV3 extensions are inspected via the service worker link under “Inspect views” on chrome://extensions/; the filename (src/background.ts or background.js) is not the visible link users need.

Proposed wording
-  - **Background Script Errors:** Go to `chrome://extensions/`, enable **Developer mode** (top right toggle), find **Late-Meet**, and click on the `background.ts` / `background.js` link next to "Inspect views".
+  - **Background Script Errors:** Go to `chrome://extensions/`, enable **Developer mode** (top right toggle), find **Late-Meet**, and click the **service worker** link next to "Inspect views".
📝 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
- **Background Script Errors:** Go to `chrome://extensions/`, enable **Developer mode** (top right toggle), find **Late-Meet**, and click on the `background.ts` / `background.js` link next to "Inspect views".
- **Background Script Errors:** Go to `chrome://extensions/`, enable **Developer mode** (top right toggle), find **Late-Meet**, and click the **service worker** link next to "Inspect views".
🤖 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 `@README.md` at line 1019, Update the “Background Script Errors”
troubleshooting instruction in README.md to direct users to click the service
worker link under “Inspect views” for Late-Meet, instead of referencing
background.ts/background.js filenames. Keep the existing chrome://extensions and
Developer mode navigation intact.

@Shan7Usmani

Copy link
Copy Markdown
Author

Hi @shouri123! Friendly ping — this PR along with #905, #906, #907, #908 were opened 3 days ago with all checks green. Would love to get these reviewed before they go stale like the previous batch. Happy to address any feedback. Thanks!

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

Labels

security-review Requires security review before merge size/L type:code Type: Code change type:docs Type: Documentation type:feature Type: New Feature type:test Type: Test files type:testing Type: Testing (Optional bonus)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Implement strict Content Security Policy (CSP) headers in manifest

2 participants