Skip to content

Commit

Permalink
mgt_cli: Don't pass unknown commands to the child
Browse files Browse the repository at this point in the history
Since mgt is aware of all known cli commands, unknown commands should
be blocked by mgt and not forwarded to the child process to prevent
any malicious command smuggling (using quotes for example).
  • Loading branch information
walid-git committed Nov 10, 2023
1 parent be95bc5 commit 5ac900a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/varnishd/mgt/mgt_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv)
}

cmd = mgt_cmd_lookup(av[1]);
if (cmd != NULL && CMD_INTERNAL(cmd)) {
if (cmd == NULL || CMD_INTERNAL(cmd)) {
VCLI_Out(cli, "Unknown request.\nType 'help' for more info.\n");
VCLI_SetResult(cli, CLIS_UNKNOWN);
return;
Expand Down
2 changes: 2 additions & 0 deletions bin/varnishtest/tests/b00008.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ varnish v1 -cliexpect 60 "param.show first_byte_timeout"
varnish v1 -cliok "param.set cli_limit 128"

varnish v1 -clierr 201 "param.show"

varnish v1 -clierr 101 "\"vcl.use foo\""

0 comments on commit 5ac900a

Please sign in to comment.