T05 · Unauthorized Access and Privilege Escalation
Error
- Location
- server.js:10
- Finding
- Unrestricted Backend RPC Method Dispatch## Vulnerability Details **File Location**: `server.js:10-31` **Vulnerability Type**: Unrestricted invocation of undocumented or privileged backend methods **Risk Level**: High ```js const _method = process.argv[2] const _paramsRaw = process.argv[3] if (!_method) { handleError(new Error('请传入方法名,例如: node server.js getDevices')) } if (!/^[a-zA-Z0-9_]+$/.test(_method)) { handleError(new Error('方法名只能包含字母、数字、下划线')) } try { await iclick.connect() const _params = _paramsRaw ? JSON.parse(_paramsRaw) : {} let _result = null try { const _cmd = require(path.join(__dirname, 'command', _method + '.js')) _result = await _cmd.run(_params) } catch (_error) { _result = await iclick.invoke(_method, _params) } ``` ### Technical Analysis The dispatcher verifies only that the supplied method consists of letters, numbers, and underscores. This prevents direct path traversal through the method name, but it does not restrict the operation to an approved set of documented commands. If loading or executing a local command handler throws any exception, the broad `catch` forwards the same attacker-controlled method and parameters directly to `iclick.invoke()`. Consequently, any method recognized by the underlying `iclick-auto` backend can potentially be invoked, including undocumented, future, administrative, or destructive methods that were not reviewed as part of the Skill interface. The exception handling also conflates two distinct conditions: 1. The requested local command module does not exist. 2. A legitimate local command module exists but fails during loading or execution. In the second case, the code can unexpectedly retry the operation through the generic backend interface. This may bypass validation or safety logic implemented by the local handler and could produce an unintended alternative operation. ### Attack Path 1. An attacker, untrusted c ...[truncated 1390 chars]
- Remediation
- ## Remediation Suggestions 1. Define an explicit allowlist of supported method names and reject every method not present in that list. 2. Map method names to handlers directly rather than forwarding arbitrary strings to the backend. 3. If generic backend invocation is required, maintain a separate allowlist for approved backend methods. 4. Fall back to generic invocation only when module resolution specifically indicates that the requested command module is absent. 5. Propagate errors thrown while loading dependencies or executing an existing handler; do not reinterpret them as a missing command. 6. Add schema validation for parameters accepted by every operation. 7. Require explicit authorization or user confirmation for destructive actions such as deleting media, clearing files, terminating applications, or controlling input. 8. Add tests confirming that undocumented method names are rejected and that handler failures never trigger generic backend invocation.
