You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature option values are changed before install.sh sees them: quotes are stripped, and $… is expanded or executed #1324
A Feature can receive a different string option value from the one configured in devcontainer.json. Quotes are removed, $VAR is expanded, $(…) and backticks are executed, and backslashes are consumed. The build still succeeds, so nothing
signals that the value changed.
Repro (devcontainer CLI 0.89.0)
A local Feature with one string option, value, whose install.sh prints it:
#!/bin/shprintf'%s\n'"$VALUE"
"features": { "./echo-opt": { "value": "say \"hi\" to $HOME as $(id -un)" } }
Expected: say "hi" to $HOME as $(id -un)
Actual: say hi to /root as root
A value with a space inside quotes, such as A="two words", fails the build instead,
with devcontainer-features.env: line 1: words: not found.
Cause
getFeatureEnvVariables (src/spec-node/containerFeatures.ts) writes each option as NAME="value" without escaping. The install wrapper then sources the file
(set -a; . ./devcontainer-features.env), so the shell interprets the value. Issue #148
and PR #149 fixed this for spaces, but not for ", $, backticks or \.
Suggested fix
Write each value in single quotes, with ' escaped as '\''. That's what escapeQuotesForShell already does for the wrapper's Options echo. This changes
behaviour for anyone relying on $ being expanded in option values today.
I ran into this today. I was very surprised to see a basic shell escaping issue in a project of this importance. Here's the line in all its naive glory.
We can actually workaround it in a most terrible way by breaking out of double quotes into single quotes, and then escaping single quotes in bash style ('\''). From the report this would become:
"value": "\"'say "hi" to $HOME as $(id -un)'\""
I might even go so far as to report this as a security issue. This would allow someone to execute arbitrary code in the container using only a option flag as an attack vector. Option flags are not considered as shell execution vectors so this would be surprising to someone who placed user input in this field.
Activity
feat(container-env): add per-device environment variables Feature (#29)
laverdet commentedon Oct 27, 2026
I ran into this today. I was very surprised to see a basic shell escaping issue in a project of this importance. Here's the line in all its naive glory.
cli/src/spec-node/containerFeatures.ts
Lines 410 to 413 in 1245d72
We can actually workaround it in a most terrible way by breaking out of double quotes into single quotes, and then escaping single quotes in bash style (
'\''). From the report this would become:I might even go so far as to report this as a security issue. This would allow someone to execute arbitrary code in the container using only a option flag as an attack vector. Option flags are not considered as shell execution vectors so this would be surprising to someone who placed user input in this field.