socket_vmnet icon indicating copy to clipboard operation
socket_vmnet copied to clipboard

client segfault with crafted arguments

Open tamird opened this issue 1 year ago • 2 comments

tamird@Mac socket_vmnet % $(brew --prefix socket_vmnet)/bin/socket_vmnet_client $(brew --prefix)/var/run/socket_vmnet --               
zsh: segmentation fault  $(brew --prefix socket_vmnet)/bin/socket_vmnet_client  --

this is caused by the special handling of --: https://github.com/lima-vm/socket_vmnet/blob/f486d475d4842bbddfe8f66ba09f7d1cb10cfbed/client/main.c#L36

I think the cleanest thing is to remove this. Typically -- is used to separate positional arguments from flags e.g. <cmd> --foo --bar -- pos1 pos2 but that is not how it works for the client.

tamird avatar Nov 10 '24 19:11 tamird

-- is typically used to separate the command arguments from sub command arguments. For example kubectl exec pod -- command to exec inside the pod.

This is not really needed in the client, since our command is trivial, but it is nice to support this since users may already using this format. You are correct that the issue is not considering the special -- option - when we consume it we need to decrease argc, and fail if no argument left for execve().

nirs avatar Nov 10 '24 19:11 nirs

This issue is possibly obsoleted by #76. The client can be removed after a deprecation period.

tamird avatar Nov 17 '24 16:11 tamird