Giter Club home page Giter Club logo

Comments (6)

bagder avatar bagder commented on June 18, 2024 1

The known_hosts format is a weakly specified format, I am not aware of any clear documentation or effort to specify how an IPv6 address should be canonicalized for it. I imagine that reading the OpenSSH source code to figure out what they do is the best way.

Also, the known hosts check is actually performed by the SSH library using the name curl passes to the library so if there is any massaging of the host name to be done, it should actually be done within the SSH library. Or the their knownhost APIs should document exactly how to provide IPv6 host names. Since I wrote the libssh2 one, I'm fairly sure it does not because it was not on my mind when I did that. Many years ago.

from curl.

bagder avatar bagder commented on June 18, 2024

When curl parses a URL with an IPv6 numeral address, it canonicalizes it and converts it into the shortest possible version. Since a single IPv6 address can be written in a nearly infinite number of ways, this is a way to increase the chances that an IPv6 address ends up the same way independently of how it is provided.

You could argue that the known_hosts file format is notoriously bad for handling IPv6 addresses because of their "flexible" nature.

from curl.

Krisscut avatar Krisscut commented on June 18, 2024

Yes I think it's fair to proceed this way, but maybe curl should also try to apply the same canonicalization on the ip listed in the known_hosts before comparing them to make sure they are in the same format ?

I don't know if there is a specification/documentation on how the ip should be formatted in the know_hosts file, maybe they should always be put in their short form in the first place. (Meaning it would be the responsibility of our app to canonicalize the ip)

from curl.

Krisscut avatar Krisscut commented on June 18, 2024

Yes it's what I was checking in the code, indeed it seems I created the issue on the wrong component, sorry.

In our case with libssh2 it would happen here I guess:

const char *remotekey = libssh2_session_hostkey(sshc->ssh_session,

Then here:
keycheck = libssh2_knownhost_checkp(sshc->kh,

And the location where maybe some canonicalization could be added is here in libssh2:
https://github.com/libssh2/libssh2/blob/master/src/knownhost.c#L409

Do you think I should raise a new issue on libssh2 to go at the bottom of this ?
On my side I worked around for now by formatting the ipv6 in its shortest form in the know_hosts but I think semantically it should have worked as well without changes.

from curl.

bagder avatar bagder commented on June 18, 2024

Do you think I should raise a new issue on libssh2 to go at the bottom of this ?

Yes, I think that is the right thing to do.

from curl.

bagder avatar bagder commented on June 18, 2024

I think we do the right thing in curl. We should look into canonicalizing the IPv6 addresses inside libssh2.

from curl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.