{"record":{"id":"716b1fa23b87f516","repo":"ruvnet/ruflo","slug":"wgmeshservice-formatcmd-refusing-arg-with-unsafe","errorCode":null,"errorMessage":"WgMeshService.formatCmd: refusing arg with unsafe chars: ${JSON.stringify(args)}","messagePattern":"WgMeshService\\.formatCmd: refusing arg with unsafe chars: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/plugin-agent-federation/src/domain/services/wg-mesh-service.ts","lineNumber":343,"sourceCode":"          meshIP,\n          endpoint,\n          publicKey: pubkey,\n          state,\n          allowedIPs: safe && state === 'active' ? this.computeAllowedIPs(peer, safe.wgMeshIP) : [],\n        };\n      });\n  }\n\n  /**\n   * Defense-in-depth: validate that all bits we splice into a shell\n   * command are alphanumeric / base64 / WG-allowed chars. Refuses the\n   * command rather than ship a substring that might escape its slot.\n   */\n  private formatCmd(args: string): string {\n    // Allow: base64 pubkey chars [A-Za-z0-9+/=], IPv4 mesh chars\n    // [0-9./], plus a handful of fixed verbs. Reject everything else.\n    if (!/^[A-Za-z0-9+/=., \"/-]*$/.test(args)) {\n      throw new Error(`WgMeshService.formatCmd: refusing arg with unsafe chars: ${JSON.stringify(args)}`);\n    }\n    return `wg set ${this.interfaceName} ${args}`;\n  }\n}\n","sourceCodeStart":325,"sourceCodeEnd":348,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/plugin-agent-federation/src/domain/services/wg-mesh-service.ts#L325-L348","documentation":"Defense-in-depth guard inside WgMeshService.formatCmd: a string destined for a shell command (wg key material, mesh IPs, fixed verbs) contains characters outside the allowed set (base64 pubkey chars [A-Za-z0-9+/=], IPv4 chars [0-9./], and known verbs). The command is refused rather than shipping a substring that could escape its argument slot and inject shell syntax.","triggerScenarios":"formatCmd refuses to build a shell command because an argument contains unsafe characters.","commonSituations":"Interface names, keys, or endpoints containing shell metacharacters or whitespace reach command formatting.","solutions":["Validate WireGuard args (keys are base64, endpoints are host:port) before formatting commands.","Use execFile-style argument arrays instead of string-formatted shell commands to avoid injection."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}