The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(plugins): grant plugin children the network on Node 25 and newer
John Jahna9d11ccb2e23
diff --git a/server/src/nest/plugins/paths.ts b/server/src/nest/plugins/paths.tsindex 51e849841..93945f73e 100644--- a/server/src/nest/plugins/paths.ts+++ b/server/src/nest/plugins/paths.ts@@ -126,6 +126,24 @@ export function serverCodeRoot(): string {return path.resolve(__dirname, '../..');}+/**+ * The network grant for a plugin child, on the Node versions that need one.+ *+ * Up to Node 24 `--permission` leaves the network alone. From Node 25 it covers the+ * network too, and a child started without `--allow-net` gets ERR_ACCESS_DENIED on+ * every lookup and connect, so no plugin can reach even a host it was granted (#3045).+ * Node 24 exits with "bad option" when given the flag, so it is passed only where+ * this Node knows it.+ *+ * This restores what Node 24 does and widens nothing: which hosts a plugin may reach+ * is decided by the egress guard inside the child, from its granted `egress[]`.+ */+export function pluginNetPermissionArgs(+ knownFlags: { has(flag: string): boolean } = process.allowedNodeEnvironmentFlags,+): string[] {+ return knownFlags.has('--allow-net') ? ['--allow-net'] : [];+}+/*** Node OS-level permission-model flags for a plugin child (#plugins, #2 security* hardening). `--permission` denies filesystem write, child_process, worker@@ -171,5 +189,6 @@ export function pluginPermissionArgs(pluginId: string): string[] {`--allow-fs-read=${path.join(codeRoot, '..', 'package.json')}`,// The plugin's own code, by REAL path (see pluginRealCodeDir).`--allow-fs-read=${pluginRealCodeDir(pluginId)}`,+ ...pluginNetPermissionArgs(),];}diff --git a/server/tests/unit/plugins/protocol-paths.test.ts b/server/tests/unit/plugins/protocol-paths.test.tsindex ffb76de06..13a1de712 100644--- a/server/tests/unit/plugins/protocol-paths.test.ts+++ b/server/tests/unit/plugins/protocol-paths.test.ts@@ -11,6 +11,7 @@ import {resolveChildEntry,serverCodeRoot,pluginPermissionArgs,+ pluginNetPermissionArgs,pluginRealCodeDir,ensurePluginModuleType,} from '../../../src/nest/plugins/paths';@@ -90,6 +91,19 @@ describe('paths', () => {expect(serverCodeRoot()).not.toContain(`${require('node:path').sep}data`);});+ // From Node 25 the permission model covers the network, and a child without the+ // grant cannot reach any host (#3045). Node 24 refuses the flag as a bad option.+ it('grants the network only on a Node that knows --allow-net', () => {+ expect(pluginNetPermissionArgs(new Set(['--permission', '--allow-net']))).toEqual(['--allow-net']);+ expect(pluginNetPermissionArgs(new Set(['--permission']))).toEqual([]);+ });++ it('passes the network grant to a plugin child exactly when this Node needs it', () => {+ delete process.env.TREK_PLUGIN_PERMISSIONS;+ const args = pluginPermissionArgs('flight-tracker');+ expect(args.includes('--allow-net')).toBe(process.allowedNodeEnvironmentFlags.has('--allow-net'));+ });+it('lets an operator opt out of the permission model', () => {process.env.TREK_PLUGIN_PERMISSIONS = 'off';expect(pluginPermissionArgs('flight-tracker')).toEqual([]);