@remcp/runtime 0.2.106 → 0.2.108

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -221,8 +221,10 @@ export async function interactWithProcessTool(args, extra = {}) {
221
221
  const session = getProcessSession(pid);
222
222
  if (!session) fail(`No ReMCP session with pid ${pid}`);
223
223
  if (session.exited) fail(`Process ${pid} already exited`);
224
- const input = typeof args.input === 'string' ? args.input : fail('input must be a string');
225
- const timeoutMs = clampInteger(args.timeout_ms, 1000, 0, 120000);
224
+ const input = typeof args.input === 'string' ? args.input : fail('input must be a string');
225
+ assertAllowedCommand(input);
226
+ const timeoutMs = clampInteger(args.timeout_ms, 1000, 0, 120000);
227
+
226
228
  session.cursor = session.droppedLines + session.lines.length;
227
229
  session.waitCursor = session.cursor;
228
230
  session.lastPartialRead = null;
package/src/util.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import os from 'node:os';
2
2
  import path from 'node:path';
3
- import { realpath } from 'node:fs/promises';
3
+ import { lstat, realpath } from 'node:fs/promises';
4
4
  import { liveConfig, runtimeConfig } from './config.mjs';
5
5
 
6
6
  export class ToolError extends Error {}
@@ -93,6 +93,12 @@ export async function resolveSafePath(value, field = 'path') {
93
93
  const absolute = path.resolve(raw);
94
94
  if (!runtimeConfig.allowedRoots.length) return absolute;
95
95
 
96
+ const leaf = await lstat(absolute).catch(error => {
97
+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') return null;
98
+ throw error;
99
+ });
100
+ if (leaf?.isSymbolicLink()) fail(`Path is a symbolic link: ${absolute}`);
101
+
96
102
  // Canonicalize both sides before enforcing confinement. This matters on macOS where
97
103
  // /var is a symlink to /private/var: a safe path returned by an earlier canonicalization
98
104
  // must not be rejected merely because its lexical prefix differs from the configured root.