Skip to content

hostkeys clobbers known_hosts entries that have unknown keytypes #435

Open

Description

@mimecuvalo

Bringing this upstream to Paramiko from ParamikoJS:
https://github.com/mimecuvalo/fireftp/issues/98

When calling load() in hostkeys.py, this line:
https://github.com/paramiko/paramiko/blob/master/paramiko/hostkeys.py#L331
prevents adding known_host entries with unknown key-types to _entries

Thus, when the file is saved out, those entries get scrubbed.

In ParamikoJS's case I don't support ECDSA just yet so those get scrubbed. You can imagine the future where this will break for other keytypes for Paramiko as well.

Activity

  1. bitprophet commented on Nov 12, 2014

    @bitprophet
    Member

    Thanks for the report!

    (Had no idea ParamikoJS was a thing, that's interesting :))

    I feel like I've seen this or a related issue before (re: loading, incorrectly mutating, then re-writing known_hosts files) but I can't find it in a quick search.

    The correct fix for this feels like it needs to preserve enough info that it can just write the data back out w/o losing it, but also not violate any assumptions the rest of the code is making about the contents of the HostKeys object.

    With luck this just means adding an attribute or two to HostKey (for the write side - right now I believe we rely on stringification of the resultant PKey objects) and tweaking either HostKeys or the other accesses to it, depending on what might blow up when handed a HostKey which doesn't have a valid PKey-subclass .key attribute.

    I don't have time to attack this right now (and it might be considered part of #387 kinda) but would consider a PR from somebody.

  2. mimecuvalo commented on Jan 15, 2015

    @mimecuvalo
    Author

    Sorry to not respond earlier. This was the patch on the ParamikoJS side fwiw (was linked to from the issue up above): mimecuvalo/paramikojs@7bbe853

    The solution was to create an UnknownKey class - perhaps that'll make for a similar solution on the python end of things.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions