From 5846ae3525cf7f9d6024edc330b2cf58f4b8ffbc Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Sun, 8 Nov 2026 17:45:14 +0100 Subject: op-mode: T9587: reject control characters in operator commands The special character check for operator-level users allowed any whitespace, including newlines. Tag node values are substituted into a shell command which runs as root, so an operator could append arbitrary commands, e.g. "vyos-op-run show interfaces ethernet $'eth0\nid'". Only plain spaces are accepted now, everything else is rejected before privileges are raised. The operator smoketest covers this case. --- smoketest/scripts/cli/test_op-mode_show.py | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'smoketest/scripts/cli') diff --git a/smoketest/scripts/cli/test_op-mode_show.py b/smoketest/scripts/cli/test_op-mode_show.py index 2af176b3e..977946ab0 100755 --- a/smoketest/scripts/cli/test_op-mode_show.py +++ b/smoketest/scripts/cli/test_op-mode_show.py @@ -97,6 +97,13 @@ class TestOPModeShow(VyOSUnitTestSHIM.TestCase): op_user, op_password) self.assertFalse(out) self.assertIn('You do not have a permission to execute VyOS command', err) + + # Tag node values end up in a shell command run as root, a newline + # must not be able to start a second command + out, err = self.ssh_send_cmd(f"{op_runner} show interfaces ethernet $'eth0\\nid'", + op_user, op_password) + self.assertFalse(out) + self.assertIn('contains special characters', err) finally: self.cli_delete(login_path + ['user', op_user]) self.cli_delete(login_path + ['operator-group', op_group]) -- cgit v1.2.3