Skip to content

feat: add Socket Firewall integration for secure package installation#1880

Open
MarshallOfSound wants to merge 4 commits intomainfrom
claude/slack-session-LrFFw
Open

feat: add Socket Firewall integration for secure package installation#1880
MarshallOfSound wants to merge 4 commits intomainfrom
claude/slack-session-LrFFw

Conversation

@MarshallOfSound
Copy link
Copy Markdown
Member

@MarshallOfSound MarshallOfSound commented Apr 2, 2026

Summary

Integrates Socket Firewall into Electron Fiddle to protect against supply chain attacks when installing npm dependencies from fiddle gists. The sfw CLI is embedded with the app — no global install required.

When enabled (the default), package installations are routed through sfw, which scans packages during installation and blocks malicious dependencies before they can execute (e.g., node sfw.mjs npm install instead of npm install).

Slack thread: https://electronhq.slack.com/archives/C3ANJ97H6/p1775171094186889?thread_ts=1775164754.105949&cid=C3ANJ97H6

Key Changes

  • Embedded sfw CLI: The sfw npm package's bundled script (sfw.mjs) is copied into the webpack output via CopyPlugin, so it ships with the packaged app
  • Runtime resolution via getSfwPath() in src/main/npm.ts — resolves the embedded script path relative to __dirname and verifies it exists with fs.existsSync
  • Execution via system Node.js: Runs as node sfw.mjs npm install ... using the system node (not process.execPath, which is the Electron binary)
  • New UI toggle in Execution Settings for enabling/disabling Socket Firewall, with isUsingSocketFirewall persisted to localStorage (defaults to true)
  • Graceful fallback: If the embedded sfw script is missing, falls back to direct npm/yarn execution with a console warning
  • IPC plumbing: New NPM_IS_SFW_INSTALLED event, useSocketFirewall flag threaded through PMOperationOptions and the module installation pipeline
  • License attribution: THIRD_PARTY_NOTICES.md with the full PolyForm Shield License 1.0.0 text (for the sfw-free binary downloaded at runtime by the sfw wrapper)
  • Tests: Comprehensive coverage for getSfwPath(), getIsSfwInstalled(), and addModules() with sfw enabled/disabled/missing scenarios

Test plan

  • Verify sfw script is copied to webpack output during build
  • Run a fiddle with npm dependencies — confirm sfw wraps the install (check console output)
  • Disable Socket Firewall in Settings > Execution — confirm direct npm/yarn is used
  • Package the app and verify sfw works in the packaged build
  • Run yarn test — all npm.spec.ts tests pass

https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw

claude added 2 commits April 2, 2026 23:14
Integrates Socket Firewall (https://github.com/SocketDev/sfw-free) to
protect against supply chain attacks when installing npm dependencies
from Fiddle gists.

Changes:
- Add `sfw` as a dependency for wrapping npm/yarn commands
- Add `isUsingSocketFirewall` setting (enabled by default)
- Modify `addModules` to use sfw when enabled and available
- Add IPC handler `NPM_IS_SFW_INSTALLED` to check sfw availability
- Add settings toggle in Execution settings panel
- Add comprehensive tests for sfw integration

When enabled, Fiddle runs `sfw npm install` instead of `npm install`,
which scans packages during installation and blocks malicious ones.
Falls back to direct npm/yarn if sfw is not installed on the system.

https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw
The sfw npm wrapper is MIT licensed, but the sfw-free binary it
downloads at runtime is under the PolyForm Shield License 1.0.0.
Include the full license text to satisfy the Notices provision.

https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw
@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 2, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​sfw@​2.0.4771007791100

View full report

@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 2, 2026

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Medium
Low adoption: npm sfw

Location: Package overview

From: package.jsonnpm/sfw@2.0.4

ℹ Read more on: This package | This alert | What are unpopular packages?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Unpopular packages may have less maintenance and contain other problems.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/sfw@2.0.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 2, 2026

Coverage Status

coverage: 89.461% (-0.01%) from 89.475%
when pulling e03c60b on claude/slack-session-LrFFw
into 9030f27 on main.

Bundle the sfw CLI script (node_modules/sfw/dist/sfw.mjs) into the
webpack output via CopyPlugin so it ships with the packaged Electron
app. At runtime, resolve the embedded path and run it via the system
Node.js (`node sfw.mjs npm install ...`) rather than relying on a
globally installed `sfw` binary.

This means Socket Firewall works out of the box — users no longer
need to `npm install -g sfw`.

https://claude.ai/code/session_01K6g5VZoNQRGLr4stRvHEVw
@MarshallOfSound MarshallOfSound marked this pull request as ready for review April 2, 2026 23:34
@MarshallOfSound MarshallOfSound requested review from a team and codebytere as code owners April 2, 2026 23:34
@MarshallOfSound MarshallOfSound changed the title Add Socket Firewall integration for secure package installation feat: add Socket Firewall integration for secure package installation Apr 2, 2026
sfw.mjs reads ../package.json at runtime to populate its version string,
so the bundled layout must mirror node_modules/sfw/ (dist/sfw.mjs plus
a sibling package.json) — copying just sfw.mjs leaves it looking for
package.json one directory too high and crashes with ENOENT.

In packaged builds, sfw.mjs also has to live outside the asar archive
because system Node can't read asar. Mark .webpack/sfw/** as unpacked
and translate app.asar -> app.asar.unpacked when resolving the path.
The glob needs the explicit .webpack segment because minimatch's
globstar skips dot-prefixed directories by default.

Also update the settings copy now that sfw ships with the app.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants