Orchestrator Runbooks and PowerShell literals
This specific strategy hasn't had much field testing yet, so this is a proof-of-concept overview.
Our admin who runs System Center Orchestrator realized a logical flaw in a lot of Orchestrator PowerShell examples and templates.
Most examples show something like this:
What orchestrator runs that script; it performs inline concatenation of its variables into the PowerShell script and executes it.
Since double quotes in PowerShell represents and expandable string then any $ in the Orchestrator variables means that execution will try to interpret a PowerShell variable from the string.
This opens up the potential for 2 problems:
- intentional injection - It would take a very precisely targeted, high knowledge attack... which does happen, but it's probably not the top risk for most companies.
- unintentional injection - We can never count on external systems to sanitize their inputs for us.
This is the exact conversation from my Designing for Application Security is designing for Data Validation post.
"No one's going to inject you like the AS/400 will."
So when a SharePoint form sent an unexpected $ it gave the admin a nasty surprise. He asked me to help test his solution, and to both of us it looks like a better choice.
By going to a literal string he gains protection against accidental expansion of anything that looks like a PowerShell variable.
By going a step further and using a Here-String literal he gains protection against all types of special characters. (This even includes protection against the presence of '@ as long as it's not the beginning characters of a new line.)
It seems like an improvement, and he may consider making a general template for his runbook scripts like this:
The transformation section is an example of where I personally would handle any further manipulation of the inputs before getting into the core of the script.
It seems like an improvement, and he may consider making a general template for his runbook scripts like this:
The transformation section is an example of where I personally would handle any further manipulation of the inputs before getting into the core of the script.
Comments
Post a Comment