[PR #4529] [CLOSED] fix(electron): exclude scripts from unauthorized frames #6289

Closed
opened 2026-10-31 01:13:19 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4529
Author: @Siva-2517
Created: 10/16/2026
Status: ❌ Closed

Base: main ← Head: fix/electron-srcdoc-script-attribution


📝 Commits (1)

  • 880a27d fix(electron): exclude scripts from unauthorized frames

📊 Changes

2 files changed (+88 additions, -6 deletions)

View changed files

📝 src/browser/CdpElectronInspection.test.ts (+83 -2)
📝 src/browser/CdpElectronScripts.ts (+5 -4)

📄 Description

Summary

Fixes #4500 by excluding Electron scripts from known out-of-scope frames, preventing misleading attribution of inline scripts to authorized local files.

Problem and expected behavior

An Electron page can contain an about:srcdoc frame whose inline script uses a synthetic sourceURL pointing to an existing local file. Previously, the script could pass local-path authorization even though its known frame was outside the authorized scope.

Scripts from known out-of-scope frames should be excluded before their source is requested. Scripts with unknown frame attribution should retain the existing behavior.

Change and scope

  • Check known frame IDs against the authorized frame set before path authorization and source capture.
  • Record excluded scripts as out_of_target_scope in capture completeness.
  • Preserve handling of scripts with unknown frame attribution (frameId === null).
  • Add regression coverage for excluded scripts and verify that their source is never requested.

This is a focused fix to existing Electron inspection behavior. No new provider, public schema, or capability is introduced.

Followed the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). A separate advance maintainer scope decision is not applicable to this routine fix.

Contract and boundary impact

  • Semantic owner and earliest changed stage: Electron script capture, before source retrieval.
  • Contribution scope fit and linked maintainer decision: Existing Electron inspection behavior; advance decision not applicable.
  • CLI and MCP/tool-catalog contract: No intentional public contract or tool-catalog changes.
  • Provider, bridge, target-format, or platform compatibility: Electron/CDP script capture; unknown frame attribution remains supported.
  • Evidence, artifact, provenance, or reconstruction contract: Out-of-scope scripts are excluded and the exclusion is recorded in completeness.
  • Target selection, authority, upstream behavior, and cleanup details: Uses the existing authorized frame set; introduces no new target selection, process execution, injection, or mutation behavior.
  • Generated metadata, package, or installation impact: None expected; no generated metadata or package changes.

Expected effects:

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: Updated the Electron script context teardown/ID reuse test and added a regression test for unauthorized frame script exclusion.
  • Base reproduction or other evidence: The regression test models an out-of-scope frame whose script has hasSourceURL: true. It asserts that the script is excluded and Debugger.getScriptSource is never requested for it. The coding agent reported that the regression failed before the fix; a real Electron/Chromium reproduction was not established by the checks listed below.
  • User-visible CLI/MCP output: Not applicable; no intentional public output contract change.
  • Remaining proof gaps: Real Electron/Chromium end-to-end behavior was not verified in this validation run.

Evidence checks — review these before marking them complete:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:local -- src/browser/CdpElectronInspection.test.ts — passed, 4 tests.
  • npx vitest run tests/boundary/browser/cdpElectronProvider.test.ts — passed, 21 tests.
  • npm run check:fast — passed, typecheck and lint.
  • git diff --check — passed.
  • Push-time check:fast — passed; Turbo reported both tasks successful.

Compatibility, safety, and release

  • Breaking changes or migration steps: None expected.
  • Real Hopper/Ghidra, browser, or OS coverage: Focused Electron inspection source tests and the Electron provider boundary suite passed. Real Electron/Chromium end-to-end coverage was not established.
  • Package or release metadata impact: None expected.
  • Security, privacy, process, or containment review: Narrows script source capture to the authorized frame scope; no new execution or mutation capability is introduced.

Author readiness

Human owner: @Siva-2517

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4529 **Author:** [@Siva-2517](https://github.com/Siva-2517) **Created:** 10/16/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/electron-srcdoc-script-attribution` --- ### 📝 Commits (1) - [`880a27d`](https://github.com/morluto/rea/commit/880a27d7b6b6c51b243121ccae24b1b7d55adfaa) fix(electron): exclude scripts from unauthorized frames ### 📊 Changes **2 files changed** (+88 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `src/browser/CdpElectronInspection.test.ts` (+83 -2) 📝 `src/browser/CdpElectronScripts.ts` (+5 -4) </details> ### 📄 Description ## Summary Fixes #4500 by excluding Electron scripts from known out-of-scope frames, preventing misleading attribution of inline scripts to authorized local files. ## Problem and expected behavior An Electron page can contain an `about:srcdoc` frame whose inline script uses a synthetic `sourceURL` pointing to an existing local file. Previously, the script could pass local-path authorization even though its known frame was outside the authorized scope. Scripts from known out-of-scope frames should be excluded before their source is requested. Scripts with unknown frame attribution should retain the existing behavior. ## Change and scope - Check known frame IDs against the authorized frame set before path authorization and source capture. - Record excluded scripts as `out_of_target_scope` in capture completeness. - Preserve handling of scripts with unknown frame attribution (`frameId === null`). - Add regression coverage for excluded scripts and verify that their source is never requested. This is a focused fix to existing Electron inspection behavior. No new provider, public schema, or capability is introduced. Followed the [[contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope)](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). A separate advance maintainer scope decision is not applicable to this routine fix. ## Contract and boundary impact - **Semantic owner and earliest changed stage:** Electron script capture, before source retrieval. - **Contribution scope fit and linked maintainer decision:** Existing Electron inspection behavior; advance decision not applicable. - **CLI and MCP/tool-catalog contract:** No intentional public contract or tool-catalog changes. - **Provider, bridge, target-format, or platform compatibility:** Electron/CDP script capture; unknown frame attribution remains supported. - **Evidence, artifact, provenance, or reconstruction contract:** Out-of-scope scripts are excluded and the exclusion is recorded in completeness. - **Target selection, authority, upstream behavior, and cleanup details:** Uses the existing authorized frame set; introduces no new target selection, process execution, injection, or mutation behavior. - **Generated metadata, package, or installation impact:** None expected; no generated metadata or package changes. Expected effects: - [x] Read existing files or captured data. - [ ] Launch or attach to a process. - [ ] Inject instrumentation or run scripts/code. - [ ] Change process memory, registers, files, or configuration. - [ ] Contact network services. - [ ] Recover protected code or work around protections. - [ ] Documentation or usability only; no target interaction. - [ ] Not sure yet; investigation or maintainer guidance needed. ## Evidence and regression coverage - **Tests added or updated:** Updated the Electron script context teardown/ID reuse test and added a regression test for unauthorized frame script exclusion. - **Base reproduction or other evidence:** The regression test models an out-of-scope frame whose script has `hasSourceURL: true`. It asserts that the script is excluded and `Debugger.getScriptSource` is never requested for it. The coding agent reported that the regression failed before the fix; a real Electron/Chromium reproduction was not established by the checks listed below. - **User-visible CLI/MCP output:** Not applicable; no intentional public output contract change. - **Remaining proof gaps:** Real Electron/Chromium end-to-end behavior was not verified in this validation run. Evidence checks — review these before marking them complete: - [ ] Observed, derived, and inferred claims remain distinguishable. - [ ] Artifact identity, source provenance, and failed attempts remain preserved. - [ ] Unsupported, incomplete, unavailable, or uncertain outcomes remain visible. ## Validation performed - `npm run test:local -- src/browser/CdpElectronInspection.test.ts` — passed, 4 tests. - `npx vitest run tests/boundary/browser/cdpElectronProvider.test.ts` — passed, 21 tests. - `npm run check:fast` — passed, typecheck and lint. - `git diff --check` — passed. - Push-time `check:fast` — passed; Turbo reported both tasks successful. ## Compatibility, safety, and release - **Breaking changes or migration steps:** None expected. - **Real Hopper/Ghidra, browser, or OS coverage:** Focused Electron inspection source tests and the Electron provider boundary suite passed. Real Electron/Chromium end-to-end coverage was not established. - **Package or release metadata impact:** None expected. - **Security, privacy, process, or containment review:** Narrows script source capture to the authorized frame scope; no new execution or mutation capability is introduced. ## Author readiness Human owner: @Siva-2517 - [ ] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [ ] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [ ] I declare this PR ready for initial maintainer review. ## Before merge - [ ] This PR addresses a concrete problem or an agreed enhancement. - [ ] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. - [ ] The PR has one focused outcome and the title follows `type(scope): outcome`. - [ ] Related issue is linked, or the reason for not linking one is stated above. - [ ] Tests cover changed observable behavior and meaningful failure paths. - [ ] Owning docs, contracts, and generated metadata are updated where needed. - [ ] User-visible CLI/MCP changes include representative output. - [ ] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:13:19 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6289
No description provided.