Know every vulnerabilitybefore it knows you.
DevGuard continuously monitors your dependencies and alerts you when CVEs like this one affect your stack — with real-time threat intelligence built for developers.
GHSA-gjw9-34gf-rp6m
No affected components available
Location: packages/server/src/automations/steps/bash.ts
Description
The bash automation step executes user-provided commands using execSync without proper sanitization or validation. User input is processed through processStringSync which allows template interpolation, potentially allowing arbitrary command execution.
Code Reference
const command = processStringSync(inputs.code, context)
let stdout,
success = true
try {
stdout = execSync(command, {
timeout: environment.QUERY_THREAD_TIMEOUT,
}).toString()
Attack Vector
An attacker with access to create or modify automations can inject malicious shell commands by including template syntax that evaluates to command injection payloads (e.g., $(rm -rf /), ; malicious-command, | malicious-command).
Impact
- Remote code execution (RCE)
- Complete system compromise
- Data exfiltration
- Lateral movement within the infrastructure
Recommendation
- Immediate: Disable bash automation step in production until fixed
- Implement a whitelist of allowed commands
- Use parameterized command execution with proper escaping
- Implement command argument validation
- Consider using a restricted shell or command sandboxing
- Add rate limiting and monitoring for command execution
Example Fix
import { spawn } from "child_process"
// Validate against whitelist
const ALLOWED_COMMANDS = ["echo", "date", "pwd"] // Extend as needed
function sanitizeCommand(input: string): string {
// Remove dangerous characters and command chaining
return input.replace(/[;&|`$(){}[\]]/g, "").trim()
}
function validateCommand(cmd: string): boolean {
const parts = cmd.split(/\s+/)
return ALLOWED_COMMANDS.includes(parts[0])
}
export async function run({ inputs, context }) {
if (!inputs.code) {
return { stdout: "Budibase bash automation failed: Invalid inputs" }
}
const processedCommand = processStringSync(inputs.code, context)
const sanitized = sanitizeCommand(processedCommand)
if (!validateCommand(sanitized)) {
return {
success: false,
stdout: "Command not allowed"
}
}
// Use spawn instead of execSync with proper argument handling
return new Promise((resolve) => {
const [command, ...args] = sanitized.split(/\s+/)
const proc = spawn(command, args, {
timeout: environment.QUERY_THREAD_TIMEOUT,
})
let stdout = ""
proc.stdout.on("data", (data) => { stdout += data })
proc.on("close", (code) => {
resolve({ stdout, success: code === 0 })
})
})
}
The vulnerability can be exploited over the network without needing physical access. It is easy for an attacker to exploit this vulnerability. An attacker needs basic access or low-level privileges. No user interaction is needed for the attacker to exploit this vulnerability. The impact is confined to the system where the vulnerability exists. There is a high impact on the confidentiality of the information. There is a high impact on the integrity of the data. There is a high impact on the availability of the system.
Exploitation activity has been observed. Apply available patches or mitigations urgently.
The exploit probability is very low. The vulnerability is unlikely to be exploited in the next 30 days.
We did not find any exploit available. Neither in GitHub repositories nor in the Exploit-Database.
Browse More
Continuously monitor your dependencies and get alerted when vulnerabilities like this one affect your stack.
Checkout DevGuard