Documentation
¶
Overview ¶
Package shell decides what the exec node is permitted to run.
This exists because of what the exec node is. Node-RED's threat model is that anyone who can deploy a flow already owns the box, and the exec node is the proof: it runs an arbitrary command line through a shell. That model held when Node-RED was a thing you ran on your own Pi. It does not hold for an App Store app on a customer's plant floor, where the editor is reachable by anyone with a dashboard login, and it is the mechanism behind CVE-2025-41656 — unauthenticated remote code execution against a default Node-RED, achieved by deploying a flow with an exec node in it.
So the node ships disabled, an operator has to name the commands it may run, and there is no shell. Those three together mean a flow author cannot turn "can edit a flow" into "can run anything", which is the property that makes the node shippable at all.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrDisabled = fmt.Errorf("the exec node is disabled; enable it and list the " +
"commands a flow may run")
ErrDisabled is returned when the exec node is switched off.
Functions ¶
func SplitArgs ¶
SplitArgs splits a command line into arguments the way a shell would, honouring single quotes, double quotes and backslash escapes — and nothing else.
Deliberately not a shell. There is no expansion, no substitution, no globbing, no pipes and no operators, because every one of those is a way to turn one allowed command into an arbitrary one. A command line containing an unquoted shell metacharacter is refused rather than being run with the character taken literally, since a flow author who typed it plainly expected it to do something.
Types ¶
type ErrNotAllowed ¶
ErrNotAllowed is returned for a command outside the allowlist.
func (*ErrNotAllowed) Error ¶
func (e *ErrNotAllowed) Error() string
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy is the allowlist the exec node is checked against.
func NewPolicy ¶
NewPolicy builds a policy from the configuration.
An enabled policy with no commands is an error rather than "anything". The permissive reading of an empty list is how a deliberately narrow capability becomes a general-purpose shell, and it would be the single worst default in this codebase.
func (*Policy) Allowed ¶
Allowed lists the configured commands, for the error message when one is refused. Sorted, so the message is the same every time.
func (*Policy) Resolve ¶
Resolve checks a command and returns the absolute path to execute.
The comparison is on the resolved absolute path, not on the string the flow typed. Comparing strings would let a flow name "curl" and get whichever curl happens to be first on the PATH of the process — and PATH is something a Function node can read and a sidecar can influence. Resolving first means the allowlist names a file on disk, which is the thing an operator thought they were allowing.
func (*Policy) Unresolved ¶
Unresolved lists allowed commands that were not found on the PATH at startup, so the operator can be told at boot rather than at the first message.