Ensure Gitlab::Popen raises error for incorrect arguments
What does this MR do and why?
A HackerOne report which arose due to developers using .join()
on an array of system command, and then using it for Gitlab::Popen
as [command]
, essentially bypassing the point of Gitlab::Popen
. I am adding a check to ensure that there are no whitespaces in the array, if there is only one item in the array. The vulnerable code snippet was like so:
command = %W("kubectl #{user_input}")
Gitlab::Popen.popen([command.join(' ')]) # this is essentially popen(["kubectl #{user_input}"])
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
Edited by Ameya Darshan