Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PyYAML-5.1 breaks !secret tag parsing #538

Closed
mvn23 opened this issue Mar 23, 2019 · 16 comments
Closed

PyYAML-5.1 breaks !secret tag parsing #538

mvn23 opened this issue Mar 23, 2019 · 16 comments
Assignees
Labels
bug Something isn't working

Comments

@mvn23
Copy link
Contributor

mvn23 commented Mar 23, 2019

After an update with pip3 install --upgrade appdaemon, AD would not start anymore. The systemd journal shows the following:

Mar 23 19:50:45 shodan appdaemon[18236]: /opt/appdaemon/lib/python3.5/site-packages/appdaemon/admain.py:184: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsaf
Mar 23 19:50:45 shodan appdaemon[18236]:   config = yaml.load(config_file_contents)
Mar 23 19:50:45 shodan appdaemon[18236]: ERROR Error loading configuration
Mar 23 19:50:45 shodan appdaemon[18236]: ERROR parser says
Mar 23 19:50:45 shodan appdaemon[18236]: ERROR   in "<unicode string>", line 8, column 14:
Mar 23 19:50:45 shodan appdaemon[18236]:           token: !secret ha_token
Mar 23 19:50:45 shodan appdaemon[18236]:                  ^
Mar 23 19:50:45 shodan appdaemon[18236]: ERROR could not determine a constructor for the tag '!secret'

Downgrading PyYAML to 3.13 solves the issue.
This could be an upstream issue, since it looks like there are some problems with 5.1 which may be related and possibly fixed in 5.2: yaml/pyyaml#265

@acockburn
Copy link
Member

Thanks for the info - I'll look into pinning the version until they figure it out.

@acockburn acockburn added the bug Something isn't working label Mar 29, 2019
@acockburn acockburn self-assigned this Mar 29, 2019
@Luke15153
Copy link

This issue occurs also with the latest addon v2.0.1.
With v1.7 everything was fine, v2.0.1 won't start any more.

@acockburn
Copy link
Member

@Luke15153 You need to report that separately as an issue with the addon, as I have no control of the environment there.

@frenck
Copy link
Contributor

frenck commented Apr 2, 2019

@acockburn The add-on does only require AppDaemon and nothing else. See:

This add-on does only install AppDaemon:

https://github.com/hassio-addons/addon-appdaemon3/blob/master/appdaemon/requirements.txt

Dependencies of AppDaemon are not locked in by the add-on, but are defined in:

https://github.com/home-assistant/appdaemon/blob/dev/setup.py#L18

So could you please add some proper version locking instead of pointing people to the add-on?

👍

@frenck
Copy link
Contributor

frenck commented Apr 2, 2019

PS: I could do a version pin on the add-on end to help people, but IMHO, it should be fixed at the root.

@acockburn
Copy link
Member

I agree and ultimately am planning to fix it in the next release which is planned to be a version bump to 4.0 with a lot of changes in it. This may be some time yet as it needs some fixes and I am out of time to work on it, which means the addon will be broken until I can get to it. The only thing I can do in the short term is release a fix on the 3.0.x version and hope it works OK as I don't have a test environment setup for 3.x any more.

@frenck
Copy link
Contributor

frenck commented Apr 2, 2019

@acockburn Check, thanks for explaining. In that case, I'll lock the PyYAML in the add-on for now to 3.13, that will take the heat of the issue.

@acockburn
Copy link
Member

No worries - I am making the change now

@acockburn
Copy link
Member

Just about to cut the release and I'll make a PR as usual

@frenck
Copy link
Contributor

frenck commented Apr 2, 2019

No need to do the PR
That is automated now 😉

Thanks @acockburn 👍

@acockburn
Copy link
Member

Ahh, very cool :)

Well I pushed the fix to pypi so we shuld be good to go.

@mvn23
Copy link
Contributor Author

mvn23 commented Apr 2, 2019

Works like a charm. Thanks!

@mvn23 mvn23 closed this as completed Apr 2, 2019
@acockburn
Copy link
Member

@mvn23 - could you do me a favor please? I have discovered that version 3.13 of PyYaml has a serious flaw in it and I need to upgrade to at least 4.2b1 to fix it. However, I was unable to reproduce your original problem. Could you confirm that upgrading to 4.2b1 doesn't cause the original issue to return? If you can do that for me I'll release another version to upgrade PyYaml to that level., Thanks!

@acockburn acockburn reopened this Apr 3, 2019
@mvn23
Copy link
Contributor Author

mvn23 commented Apr 4, 2019

Unfortunately, everything after pyyaml==3.13 breaks the tag parsing. I assume that by 'serious flaw' you mean CVE-2017-18342, in which case the fix for this is exactly what is causing the issue.
I made a fix on the master branch which uses yaml.SafeLoader through the Loader= parameter as per the pyyaml wiki. This works with pyyaml==5.1 as well.
PR will follow in a few minutes.

edit: The same fix could be implemented on dev as well.

@acockburn
Copy link
Member

Excellent thanks! I'll merge on master and release a build then I can just merge the same commits into dev.

@acockburn
Copy link
Member

AppDaemon 3.0.4 just released with your safeloader fix and pyyaml pinned to 5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants