projectkudu / kudu

Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites. It can also run outside of Azure.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exe triggered web jobs do not have argument correctly escaped

thegrahamking opened this issue · comments

Triggering a .exe (triggered) web job with argument that include windows special characters (& \ < > ^ |) does not pass the arguments as specified to the exe on the command line (although they are set correctly in WEBJOBS_COMMAND_ARGUMENTS environment variable) because the special characters are not escaped

Repro steps.

Create a command line exe that will output the arguments passed to exe and output WEBJOBS_COMMAND_ARGUMENTS environment variable
e.g.

public static int Main(string[] args)
{
      Console.WriteLine("Received arguments:" + string.Join(' ', args));
      Console.WriteLine("WEBJOBS_COMMAND_ARGUMENTS: " + Environment.GetEnvironmentVariable("WEBJOBS_COMMAND_ARGUMENTS"));
}

Trigger the exe web job using the /api/triggeredwebjobs/{jobName}?arguments={arguments} API endpoint using the command line args including special characters e.g. http://some-host.com/abc?a=1&b=2 http://some--other-host.com/def?c=3&d=4 (correctly query string encoded of course)

Expected outcome:
The tool outputs the arguments as specified from both args and WEBJOBS_COMMAND_ARGUMENTS
e.g.

Received arguments: http://some-host.com/abc?a=1&b=2 http://some--other-host.com/def?c=3&d=4
WEBJOBS_COMMAND_ARGUMENTS: http://some-host.com/abc?a=1&b=2 http://some--other-host.com/def?c=3&d=4

Actual outcome:
The tool outputs the arguments as specified WEBJOBS_COMMAND_ARGUMENTS but not from args
e.g.

Received arguments: http://some-host.com/abc?a=1
WEBJOBS_COMMAND_ARGUMENTS: http://some-host.com/abc?a=1&b=2 http://some--other-host.com/def?c=3&d=4

Mention any other details that might be useful.

This obviously means that the full arguments don't make it into the tool via the usual expected route (e.g. static void Main(string[] args).
I drilled down into the WindowsScriptHost (that runs exes) and the underlying issue is that the special characters are not escaped (e.g. & replaced with ^&).

Hi

If the problem persists and is related to running it on Azure App Service, please open a support incident in Azure:
https://learn.microsoft.com/en-us/azure/azure-portal/supportability/how-to-create-azure-support-request

This way we can better track and assist you on this case

Thanks,

Joaquin Vano
Azure App Service