mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 19:28:28 +00:00
fix(security): block shell-wrapper line-continuation allowlist bypass
This commit is contained in:
@@ -16,6 +16,11 @@ import {
|
||||
validateSafeBinArgv,
|
||||
} from "./exec-safe-bin-policy.js";
|
||||
import { isTrustedSafeBinPath } from "./exec-safe-bin-trust.js";
|
||||
|
||||
function hasShellLineContinuation(command: string): boolean {
|
||||
return /\\(?:\r\n|\n|\r)/.test(command);
|
||||
}
|
||||
|
||||
export function normalizeSafeBins(entries?: string[]): Set<string> {
|
||||
if (!Array.isArray(entries)) {
|
||||
return new Set();
|
||||
@@ -375,6 +380,12 @@ export function evaluateShellAllowlist(params: {
|
||||
segmentSatisfiedBy: [],
|
||||
});
|
||||
|
||||
// Keep allowlist analysis conservative: line-continuation semantics are shell-dependent
|
||||
// and can rewrite token boundaries at runtime.
|
||||
if (hasShellLineContinuation(params.command)) {
|
||||
return analysisFailure();
|
||||
}
|
||||
|
||||
const chainParts = isWindowsPlatform(params.platform) ? null : splitCommandChain(params.command);
|
||||
if (!chainParts) {
|
||||
const analysis = analyzeShellCommand({
|
||||
|
||||
Reference in New Issue
Block a user