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

LibGit2: patch to pass hostkey & port to host verify callback #39324

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

StefanKarpinski
Copy link
Sponsor Member

@StefanKarpinski StefanKarpinski commented Jan 19, 2021

It seems that no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

  • It doesn't give the actual host key fingerprint, but rather three
    different hashes thereof. This means we cannot distinguish a known
    hosts entry that has a different type (ssh-rsa, ssh-dsa, etc.)
    from an entry with a matching type and a fingerprint mismatch: the
    former should be treated as an unknown host whereas the latter is a
    host key mismatch; they cannot be distinguished without this patch.

  • If the user connects on a non-default port (i.e. not 22), this is not
    passed to the callback in any way. Since there can be different known
    host entries for different ports and they should be treated as
    distinct, this also means the current API cannot be used to verify
    hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.

@StefanKarpinski StefanKarpinski changed the title LibGit2: patch to pass hostkey & port to host verify callback [ci skip] LibGit2: patch to pass hostkey & port to host verify callback Jan 19, 2021
Fixes #38777.
Might fix JuliaLang/Pkg.jl#2334.

It seems likely no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

- It doesn't give the actual host key fingerprint, but rather three
  different hashes thereof; this means we cannot distinguish a known
  hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.)
  versus an entry with a matching type and a fingerprint mismatch. The
  former should be treated as an unknown host whereas the latter is a
  host key mismatch; they cananot be distinguished with this patch.

- If the user connects on a non-default port (i.e. not 22), this is not
  passed to the callback in any way. Since there can be different known
  host entries for different ports and they should be treated as
  distinct, this also means the current API cannot be used to verify
  hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.
@StefanKarpinski StefanKarpinski added the backport 1.6 Change should be backported to release-1.6 label Jan 21, 2021
@StefanKarpinski StefanKarpinski added this to the 1.6 blockers milestone Jan 21, 2021
@StefanKarpinski StefanKarpinski merged commit 2b13234 into master Jan 21, 2021
@StefanKarpinski StefanKarpinski deleted the sk/libgit2-hostkey-patch branch January 21, 2021 16:09
KristofferC pushed a commit that referenced this pull request Jan 22, 2021
It seems that no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

- It doesn't give the actual host key fingerprint, but rather three
  different hashes thereof. This means we cannot distinguish a known
  hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.)
  from an entry with a matching type and a fingerprint mismatch: the
  former should be treated as an unknown host whereas the latter is a
  host key mismatch; they cannot be distinguished without this patch.

- If the user connects on a non-default port (i.e. not 22), this is not
  passed to the callback in any way. Since there can be different known
  host entries for different ports and they should be treated as
  distinct, this also means the current API cannot be used to verify
  hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.

Fixes #38777.
Might fix JuliaLang/Pkg.jl#2334.

(cherry picked from commit 2b13234)
@KristofferC KristofferC mentioned this pull request Jan 22, 2021
60 tasks
@KristofferC KristofferC removed the backport 1.6 Change should be backported to release-1.6 label Feb 1, 2021
KristofferC pushed a commit that referenced this pull request Feb 1, 2021
It seems that no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

- It doesn't give the actual host key fingerprint, but rather three
  different hashes thereof. This means we cannot distinguish a known
  hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.)
  from an entry with a matching type and a fingerprint mismatch: the
  former should be treated as an unknown host whereas the latter is a
  host key mismatch; they cannot be distinguished without this patch.

- If the user connects on a non-default port (i.e. not 22), this is not
  passed to the callback in any way. Since there can be different known
  host entries for different ports and they should be treated as
  distinct, this also means the current API cannot be used to verify
  hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.

Fixes #38777.
Might fix JuliaLang/Pkg.jl#2334.

(cherry picked from commit 2b13234)
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
…ang#39324)

It seems that no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

- It doesn't give the actual host key fingerprint, but rather three
  different hashes thereof. This means we cannot distinguish a known
  hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.)
  from an entry with a matching type and a fingerprint mismatch: the
  former should be treated as an unknown host whereas the latter is a
  host key mismatch; they cannot be distinguished without this patch.

- If the user connects on a non-default port (i.e. not 22), this is not
  passed to the callback in any way. Since there can be different known
  host entries for different ports and they should be treated as
  distinct, this also means the current API cannot be used to verify
  hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.

Fixes JuliaLang#38777.
Might fix JuliaLang/Pkg.jl#2334.
antoine-levitt pushed a commit to antoine-levitt/julia that referenced this pull request May 9, 2021
…ang#39324)

It seems that no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

- It doesn't give the actual host key fingerprint, but rather three
  different hashes thereof. This means we cannot distinguish a known
  hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.)
  from an entry with a matching type and a fingerprint mismatch: the
  former should be treated as an unknown host whereas the latter is a
  host key mismatch; they cannot be distinguished without this patch.

- If the user connects on a non-default port (i.e. not 22), this is not
  passed to the callback in any way. Since there can be different known
  host entries for different ports and they should be treated as
  distinct, this also means the current API cannot be used to verify
  hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.

Fixes JuliaLang#38777.
Might fix JuliaLang/Pkg.jl#2334.
staticfloat pushed a commit that referenced this pull request Dec 23, 2022
It seems that no one actually verifies SSH host identity with libgit2
because the callback doesn't give enough information do so correctly:

- It doesn't give the actual host key fingerprint, but rather three
  different hashes thereof. This means we cannot distinguish a known
  hosts entry that has a different type (`ssh-rsa`, `ssh-dsa`, etc.)
  from an entry with a matching type and a fingerprint mismatch: the
  former should be treated as an unknown host whereas the latter is a
  host key mismatch; they cannot be distinguished without this patch.

- If the user connects on a non-default port (i.e. not 22), this is not
  passed to the callback in any way. Since there can be different known
  host entries for different ports and they should be treated as
  distinct, this also means the current API cannot be used to verify
  hosts serving SSH on non-standard ports. This patch passes the port.

I will try to upstream some version of this patch to libgit2. The same
patch has already been applied to the LibGit2 JLL.

Fixes #38777.
Might fix JuliaLang/Pkg.jl#2334.

(cherry picked from commit 2b13234)
@fxcoudert
Copy link
Contributor

I have created an upstream PR for this: libgit2/libgit2#6503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants