Skip to content

BUG - Dangerous use of aas_expandpathbyvars in aa_init #288

Open

Description

@AljenU

In aa_init, the full aap structure is parsed and updated through aas_expandpathbyvars, without any checks whether the fields are meant as paths, or are another type of information. This can lead to unexpected content in the aap, where contents of a meant-as-literal string are replaced due to aas_expandpathbyvars, if they happen to match an environment variable expression in part of the content of the string.

Activity

  1. tiborauer commented on Nov 8, 2021

    @tiborauer
    Member

    I think it only acts when "$" is detected, which is not a typical character in any setting.

  2. AljenU commented on Nov 9, 2021

    @AljenU
    CollaboratorAuthor

    That is true, so in practice it may not happen often, but it is possible. Also, for #289 the chance is higher.

    As for a solution, I noticed that in aas_validatepaths, the content type of the xml fields is taken into account. Since aas_expandpathbyvars is meant to expand paths only, it would appear that for the full-aap-as-input case, a similar way of checking could be used.

    Additionally, and given that aas_expandpathbyvars is only used in two cases in the code currently, it could be simplified to only accept char-vectors or aap structs (which then need to provide an accompanying schema input). The case where there is a char matrix input has probably not been tested, because that one will give an error unless the size of the replaced part is exactly the same as the size of the replacement. Which only leaves cell array input as an extra and currently unused option, which can easily be handled on the outside.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions