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
Config server resolves placeholders incorrectly for JSON and YAML endpoints #480
I am seeing problems with the resolvePlaceholder functionality in Spring Cloud Config Server. A set of examples is best. First here is an example yml file I have in my git repo....
When I call the server using the path used by the Spring Client the correct results are returned with the ${catalina.home:.} placeholder not being resolved.
To be honest I am not sure which one is correct. If the properties version is the correct one then it exposes a dangerous security vulnerability since any client could start examining the server's environment variables.
changed the title [-]resolvePlaceholder functionality incorrect and inconsistent depending on format[/-][+]resolvePlaceholder functionality incorrect and inconsistent when serving alternative formats[/+]on Aug 19, 2016
I THINK this is a bug, I am able to reproduce the problem, but i am unfamiliar with the code. I also dont see any tests that test this specific scenario. I will check with the team next week and provide more info.
Looking at the code this seems to be centralized to the EnvironmentController class. For the labelledProperties() method return there is a convertToProperties function which simply converts the environment to a map of properties but does not alter the value of the properties. For json and yml (labeledYaml() and labeledJson()) there is a convertToMap function which along with converting the structure of the environment to a nested map it also alters the property values....
PropertiesConfigurationFactory<Map<String, Object>> factory = new PropertiesConfigurationFactory<>(
//.... some structuring code....
factory.setPropertySources(propertySources);
factory.bindPropertiesToTarget();
//... other stuff....
Its during the bindPropertiesToTarget that the placeholder resolution occurs regardless of if the resolvePlaceholders value is true or false. Because the convertToMap function alters the value of the properties and the convertToProperties function does not you get the inconsistant behavior. What I haven't determined is if there is a valid reason the convertToMap tries to alter the property values for a use case I am not thinking of.
I was going to look into this myself but I am having trouble running the unit tests as I am getting weird errors from Mockito.
One last comment. It concerns me that we don't have the ability to completely eliminate place holder resolution on the server side. As it stands right now a malicious hacker could probe the server and potentially use it to retrieve any environment property set on the config server regardless of its relevance for outside configurations. This seems like a huge security vulnerability.
I think "huge security vulnerability" is a bit of an exaggeration (the config server should be secure in any reasonable environment, so only its authenticated clients can probe it, and only the ones that can write to its backend), but we can certainly correct this because it is not the intended behaviour. See f8fc4e1.
changed the title [-]resolvePlaceholder functionality incorrect and inconsistent when serving alternative formats[/-][+]Config server resolves placeholders incorrectly for JSON and YAML endpoints[/+]on Aug 22, 2016
Activity
[-]resolvePlaceholder functionality incorrect and inconsistent depending on format[/-][+]resolvePlaceholder functionality incorrect and inconsistent when serving alternative formats[/+]ryanjbaxter commentedon Aug 19, 2016
I THINK this is a bug, I am able to reproduce the problem, but i am unfamiliar with the code. I also dont see any tests that test this specific scenario. I will check with the team next week and provide more info.
rlynch commentedon Aug 19, 2016
Looking at the code this seems to be centralized to the EnvironmentController class. For the labelledProperties() method return there is a convertToProperties function which simply converts the environment to a map of properties but does not alter the value of the properties. For json and yml (labeledYaml() and labeledJson()) there is a convertToMap function which along with converting the structure of the environment to a nested map it also alters the property values....
Its during the bindPropertiesToTarget that the placeholder resolution occurs regardless of if the resolvePlaceholders value is true or false. Because the convertToMap function alters the value of the properties and the convertToProperties function does not you get the inconsistant behavior. What I haven't determined is if there is a valid reason the convertToMap tries to alter the property values for a use case I am not thinking of.
I was going to look into this myself but I am having trouble running the unit tests as I am getting weird errors from Mockito.
rlynch commentedon Aug 19, 2016
One last comment. It concerns me that we don't have the ability to completely eliminate place holder resolution on the server side. As it stands right now a malicious hacker could probe the server and potentially use it to retrieve any environment property set on the config server regardless of its relevance for outside configurations. This seems like a huge security vulnerability.
ryanjbaxter commentedon Aug 19, 2016
That is my analysis as well, hopefully I will have more information for you soon.
dsyer commentedon Aug 22, 2016
I think "huge security vulnerability" is a bit of an exaggeration (the config server should be secure in any reasonable environment, so only its authenticated clients can probe it, and only the ones that can write to its backend), but we can certainly correct this because it is not the intended behaviour. See f8fc4e1.
[-]resolvePlaceholder functionality incorrect and inconsistent when serving alternative formats[/-][+]Config server resolves placeholders incorrectly for JSON and YAML endpoints[/+]acbd3b7 rlynch2 on 9/5/16 at 10:38 PM Fixes handling of default value…
Fixes handling of default values in placeholders for json and yaml fi…
Fixes handling of default values in placeholders for json and yaml fi…
Fixes handling of default values in placeholders for json and yaml fi…
Ensure EnvironmentController does not leak system properties