Further restrict API names character set and prevent shell expansion#2827
Merged
Further restrict API names character set and prevent shell expansion#2827
Conversation
Since some of those names may be passed to a shell either on the client or server side, let's avoid getting into potential variable expansions. Signed-off-by: Stéphane Graber <[email protected]> Reported-by: Rory McNamara <[email protected]>
Signed-off-by: Stéphane Graber <[email protected]> Suggested-by: Rory McNamara <[email protected]>
This avoids potential shell expansion of the strings should some special characters manage to make it through. Signed-off-by: Rory McNamara <[email protected]>
This was referenced Jan 26, 2026
tomponline
added a commit
to canonical/lxd
that referenced
this pull request
Feb 3, 2026
Based on lxc/incus#2827 Related to https://github.com/lxc/incus/security/advisories/GHSA-8h3p-58qv-8p53 From @stgraber : > The LXC driver generates an LXC config file which includes some LXC hooks. > Those get run through a shell and may therefore get expanded if special characters are allowed. > > Some care was taken around that by using strconv.Quote, but this only leads to double quoted rather than single quoted strings (equivalent to "%q" in fmt.Sprintf) when for something exposed to a shell, we really want single quoted strings. > > To address potential issues, this branch: > > - Introduces a new util.SingleQuote function (sadly strconv doesn't provide this directly) > - Makes use of util.SingleQuote where strconv.Quote was previously used > > This issue came out from security research work by @rmcnamara-snyk but as any exploitation of this requires full admin privileges on Incus, it didn't qualify as a security issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The LXC driver generates an LXC config file which includes some LXC hooks.
Those get run through a shell and may therefore get expanded if special characters are allowed.
Some care was taken around that by using
strconv.Quote, but this only leads to double quoted rather than single quoted strings (equivalent to"%q"in fmt.Sprintf) when for something exposed to a shell, we really want single quoted strings.To address potential issues, this branch:
$anywhere in the Incus API object namesutil.SingleQuotefunction (sadlystrconvdoesn't provide this directlyutil.SingleQuotewherestrconv.Quotewas previously usedThis issue came out from security research work by @rmcnamara-snyk but as any exploitation of this requires full admin privileges on Incus, it didn't qualify as a security issue.