MIR: libssh2

Bug #1991650 reported by Simon Chopin
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
libssh2 (Ubuntu)
Fix Released
High
Unassigned

Bug Description

[Availability]
The package libssh2 is already in Ubuntu universe (and even was in main for a time).
It builds on the architectures it is designed to work on:
i386 amd64 armhf arm64 s390x ppc64el riscv64
Link to package: https://launchpad.net/ubuntu/+source/libssh2

[Rationale]

The package libssh2 is required in Ubuntu main as a dependency of src:cargo,
which will be the object of its own MIR.

It should NOT be promoted to main until the cargo MIR is accepted.

It would be great and useful to community/processes to have the
package libssh2 in Ubuntu main, but there is no definitive deadline.

[Security]
libssh2 had 13 known security issues in the past:
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-1782 lack of validation of network-supplied LENGTH, causing read past the packet buffer. Fixed in 1.5.0, see https://www.libssh2.org/adv_20150311.html for their advisory.
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2016-0787 "bits/bytes confusion bug", weaker crypto (MitM risks). Fixed in 1.7.0, see https://www.libssh2.org/adv_20160223.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3855 Remote execution due to integer overflow leading to out-of-bounds write flaw. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3855.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3856 Remote execution due to integer overflow leading to out-of-bounds write flaw. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3856.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3857 Remote execution due to integer overflow leading to out-of-bounds write flaw. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3857.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3858 DoS, memory read due to out-of-bound read. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3858.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3859 DoS, memory read due to out-of-bound read. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3859.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3860 DoS, memory read due to out-of-bound read. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3860.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3861 DoS, memory read due to out-of-bound read. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3861.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3862 DoS, memory read due to out-of-bound read. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3862.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-3863 Remote execution due to integer overflow leading to out-of-bounds write flaw. Fixed in 1.8.1, see https://www.libssh2.org/CVE-2019-3863.html
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-13115 In libssh2 before 1.9.0, kex_method_diffie_hellman_group_exchange_sha256_key_exchange in kex.c has an integer overflow that could lead to an out-of-bounds read in the way packets are read from the server. A remote attacker who compromises a SSH server may be able to disclose sensitive information or cause a denial of service condition on the client system when a user connects to the server. This is related to an _libssh2_check_length mistake, and is different from the various issues fixed in 1.8.1, such as CVE-2019-3855.
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-13115 DoS, memory read due to out-of-bound read. Fixed in 1.9.0, no advisory has been published in the libssh2 website.
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-17498 DoS, memory read due to integer overflow leading to out-of-bound read. Fixed in 1.10.0, but no advisory has been published on the libssh2 website.

CVE-2019-3855 to -3863 have all been reported by Chris Coulson, presumable from an earlier security review from a previous MIR?

- no `suid` or `sgid` binaries
- no executables in `/sbin` and `/usr/sbin`
- Packages does not open privileged ports (ports < 1024)
- Packages does not contain extensions to security-sensitive software
  (filters, scanners, plugins, UI skins, ...)

[Quality assurance - function/usage]
- The package works well right after install (as a library)

[Quality assurance - maintenance]
- The package is maintained well in Debian/Ubuntu and has not too many
  and long term critical bugs open
- Ubuntu https://bugs.launchpad.net/ubuntu/+source/libssh2/+bug
- Debian https://bugs.debian.org/cgi-bin/pkgreport.cgi?src=libssh2
- The package does not deal with exotic hardware we cannot support

[Quality assurance - testing]
- The package runs a test suite on build time, if it fails
  it makes the build fail
Build logs: https://launchpadlibrarian.net/588624160/buildlog_ubuntu-jammy-amd64.libssh2_1.10.0-3_BUILDING.txt.gz

The package runs an autopkgtest, and is currently passing on
all architectures but i386 (never succeeded there, fails due to depending gcc:i386)
The autopkgtests are just the unit tests run against the installed library.

[Quality assurance - packaging]
- debian/watch is present and works (but outputs a warning, which trips up tracker.debian.org somehow)
- debian/control defines a correct Maintainer field

Here are the logs of a recent rebuild:

https://launchpadlibrarian.net/627042984/buildlog_ubuntu-kinetic-amd64.libssh2_1.10.0-3~ppa2_BUILDING.txt.gz
Note that there are massive deprecation warnings as the package uses OpenSSL APIs that have been deprecated in OpenSSL 3.0. Upstream doesn't have concrete plans to handle OpenSSL 3.0 yet. All other warnings are only on example code.

I wasn't able to produce a --pedantic lintian run on my local builder as the package
FTBFS on it (presumably due to recent changes in openssh-server breaking things on my system, since it builds
fine on LP builders). I'm still investigating that, but in the mean time, there are these results:

https://lintian.debian.org/sources/libssh2

The package doesn't have any overrides.

- This package does not rely on obsolete or about to be demoted packages.
- This package has no python2 or GTK2 dependencies
- The package will not be installed by default
- Packaging and build is easy:
https://sources.debian.org/src/libssh2/1.10.0-3/debian/rules/

[UI standards]
- Application is not end-user facing (does not need translation)

[Dependencies]
- No further depends or recommends dependencies that are not yet in main

[Standards compliance]
- This package correctly follows FHS and Debian Policy

[Maintenance/Owner]
- Owning Team will be Foundations
- Team is already subscribed to the package

- This does not use static builds
- This does not use vendored code
- This package is not rust based

- The package was test rebuilt in PPA recently:
https://launchpad.net/~schopin/+archive/ubuntu/rebuilds/+sourcepub/13981899/+listing-archive-extra

[Background information]
The Package description explains the package well
Link to upstream project: https://www.libssh2.org/

Regarding the feature duplication between libssh1 and libssh2, the Rust bindings for the latter are well-maintained and see substantial usage, whereas the former are barely used:

https://crates.io/crates/libssh-sys
https://crates.io/crates/libssh2-sys

Given that FFI bindings are one of the trickiest area of Rust in terms of unsafe code, I believe it safer not to try and port cargo to libssh1.

Tags: sec-1351
Simon Chopin (schopin)
description: updated
Changed in libssh2 (Ubuntu):
assignee: nobody → Ioanna Alifieraki (joalif)
Revision history for this message
Ioanna Alifieraki (joalif) wrote :
Download full text (3.3 KiB)

Review for Package: libssh2

[Summary]
MIR team ACK
This does need a security review, so I'll assign ubuntu-security
List of specific binary packages to be promoted to main: libssh2-1, libssh2-1-dev

Notes:
- The package should get a team bug subscriber before being promoted

[Duplication]
There is libssh already in main. libssh and libssh2 provide more or less the same
functionality. However, the argument presented by the bug reporter that libssh2
is better maintained and substantially more used versus libssh is satisfying and
therefore promoting libssh2 to main is justified.

[Dependencies]
OK:
- no other Dependencies to MIR due to this
   - libssh2 checked with `check-mir`
   - all dependencies can be found in `seeded-in-ubuntu` (already in main)
   - none of the (potentially auto-generated) dependencies (Depends
     and Recommends) that are present after build are not in main
- no -dev/-debug/-doc packages that need exclusion
- No dependencies in main that are only superficially tested requiring
  more tests now.

Problems: None

[Embedded sources and static linking]
OK:
- no embedded source present
- no static linking
- does not have unexpected Built-Using entries
OK:
- not a go package, no extra constraints to consider in that regard
- not a rust package, no extra constraints to consider in that regard
- Does not include vendored code

Problems: None

[Security]
OK:
- history of CVEs does not look concerning
- does not run a daemon as root
- does not use webkit1,2
- does not use lib*v8 directly
- does not process arbitrary web content
- does not use centralized online accounts
- does not integrate arbitrary javascript into the desktop
- does not deal with system authentication (eg, pam), etc)
- does not deal with security attestation (secure boot, tpm, signatures)

Problems:
- does deal with cryptography (en-/decryption, certificates, signing, ...)
- does open a port/socket
- does parse data formats (files [images, video, audio,
  xml, json, asn.1], network packets, structures, ...) from
  an untrusted source.

[Common blockers]
OK:
- does not FTBFS currently
- does have a test suite that runs at build time
  - test suite fails will fail the build upon error.
- does have a non-trivial test suite that runs as autopkgtest
- no new python2 dependency

Problems: None

[Packaging red flags]
OK:
- Ubuntu does not carry a delta (existing patches come from debian)
- symbols tracking is in place
- d/watch is present and looks ok (if needed, e.g. non-native)
- Upstream update history is good
- Debian/Ubuntu update history is good
- the current release is packaged
- promoting this does not seem to cause issues for MOTUs that so far
  maintained the package
- no massive Lintian warnings
- d/rules is rather clean
- It is not on the lto-disabled list

Problems: None

[Upstream red flags]
OK:
- no incautious use of malloc/sprintf (as far as we can check it)
- no use of sudo, gksu, pkexec, or LD_LIBRARY_PATH (usage is OK inside
  tests)
- no use of user nobody
- no use of setuid
- no important open bugs (crashers, etc) in Debian or Ubuntu
- no dependency on webkit, qtwebkit, seed or libgoa-*
- not part of the UI for extra checks
- no translation pre...

Read more...

Changed in libssh2 (Ubuntu):
assignee: Ioanna Alifieraki (joalif) → nobody
assignee: nobody → Ubuntu Security Team (ubuntu-security)
Revision history for this message
Steve Beattie (sbeattie) wrote :

The prior MIR attempt(s) for libssh2 was in https://bugs.launchpad.net/ubuntu/+source/libssh2/+bug/681423 and the security team was strongly opposed to including it in main because of the easily found security issues and generally low code quality. I'm not sure if upstream has improved in the three years since.

Steve Beattie (sbeattie)
tags: added: sec-1351
Revision history for this message
Mark Esler (eslerm) wrote :

cargo is no longer being promoted to main: https://bugs.launchpad.net/ubuntu/+source/rustc/+bug/1957932

Unassigning Security Team as rationale is no longer valid.

Changed in libssh2 (Ubuntu):
assignee: Ubuntu Security Team (ubuntu-security) → nobody
Revision history for this message
Mark Esler (eslerm) wrote :
Changed in libssh2 (Ubuntu):
assignee: nobody → Ubuntu Security Team (ubuntu-security)
Revision history for this message
Nishit Majithia (0xnishit) wrote (last edit ):
Download full text (3.3 KiB)

I reviewed libssh2 1.10.0-3 as checked into kinetic. This shouldn't be
considered a full audit but rather a quick gauge of maintainability.

libssh2 is a client-side C library implementing the SSH2 protocol

- CVE History:
  - CVE-2015-1782
  - CVE-2016-0787
  - CVE-2019-13115
  - CVE-2019-17498
  - CVE-2019-3855
  - CVE-2019-3856
  - CVE-2019-3857
  - CVE-2019-3858
  - CVE-2019-3859
  - CVE-2019-3860
  - CVE-2019-3861
  - CVE-2019-3862
  - CVE-2019-3863
- Build-Depends?
  - Optional dependency on GnuPG, libgcrypt and OpenSSH
  - Build produces many deprecation warnings because of openssl, but upstream
    hasn't decided how to deal with it.
- pre/post inst/rm scripts?
  - none
- init scripts?
  - none
- systemd units?
  - none
- dbus services?
  - none
- setuid binaries?
  - none
- binaries in PATH?
  - none
- sudo fragments?
  - none
- polkit files?
  - none
- udev rules?
  - none
- unit tests / autopkgtests?
  - yes
- cron jobs?
  - none
- Build logs:
  - Many compailer warnings mentioned in log.txt
  - Lintian failed
- Processes spawned?
  - Yes, libssh2 client is using libssh2_channel_exec() and
    libssh2_channel_subsystem() calls in libssh2.h file
- Memory management?
  - Yes, libssh2 is mainly using [c/m/re]alloc(), memcpy(), memmove() and
    memory functions of mbedtls_. Use of these functions looks safe
- File IO?
  - Few file IO calls to readand write contect in channel.c, sftp.c, packet.c,
    openssl.c, libcrypt.c, userauth.c and scp.c
- Logging?
  - logging looks fine and logs are informative
- Environment variable usage?
  - Just one at /include/libssh2.h:762
- Use of privileged functions?
  - ioctl function used in src/session.c, looks fine
- Use of cryptography / random number sources etc?
  - Majority of the use in openssl.c
- Use of temp files?
  - none, just in examples
- Use of networking?
  - Use multiple places to start/stop socket connections.
- Use of WebKit?
  - none
- Use of PolicyKit?
  - none
- Any significant cppcheck results?
  - none
- Any significant Coverity results?
  - Few deadcode issues, few buffer overrun issues in userauth.c,
    bcrypt_pbkdf.c, knownhost.c and transport.c
- Any significant shellcheck results?
  - none
- Any significant bandit results?
  - none

Found NULL pointer dereference issue in openssl.c when session object is NULL
and calling \_libssh2_error() method will cause the null pointer dereference
resulting crash of the client application.
They fixed the issue in no time: https://github.com/libssh2/libssh2/pull/796

There are 50+ open bugs and 25 PRs pending on upstream to fix the code.

Security team ACK for promoting libssh2 to main conditional upon improving code
quality(remove dead codes and improve code comments) reported by coverity and fix this possible issue

1. NULL pointer derefernce issue in openssl.c of `decrypted` pointer
src/openssl.c:3082:29:
  deref_ptr_in_call: Dereferencing pointer "decrypted".
src/misc.c:772:5:
  deref_parm_in_call: Function "_libssh2_get_u32" dereferences "buf".
src/misc.c:737:5:
  deref_parm_in_call: Function "_libssh2_check_length" dereferences "buf".
src/misc.c:849:5:
  deref_parm: Directly dereferencing parameter "buf".
src/openssl.c:3148:...

Read more...

Changed in libssh2 (Ubuntu):
assignee: Ubuntu Security Team (ubuntu-security) → nobody
status: New → In Progress
Revision history for this message
Nishit Majithia (0xnishit) wrote :

The bug has been filed upstream for NULL pointer dereference issue here: https://github.com/libssh2/libssh2/issues/802

Revision history for this message
Mark Esler (eslerm) wrote :

I am altering Security's conditional ACK.

Security team propose a conditional ACK for promoting libssh2 to main
upon Foundations team's acknowledgment of their commitment in assisting with
the development of security fixes, in the absence of upstream support, as
well as their responsibility to ask for demoting the package in the future
once a suitable alternative is identified and deemed feasible.

Please see https://bugs.launchpad.net/ubuntu/+source/http-parser/+bug/1990655
for discussion of this conditional ACK.

Revision history for this message
Zixing Liu (liushuyu-011) wrote (last edit ):

Hi, Mark (@eslerm),

The Foundations Team is committed to assisting with the development of security fixes in the absence of upstream support or demoting the package if an alternative is identified in the future.

Revision history for this message
Mark Esler (eslerm) wrote :

thanks for confirming Zixing

since rustc (containing cargo) has already been promoted in LP#1993819, please promote this ack'd dependency

Revision history for this message
Didier Roche-Tolomelli (didrocks) wrote :

Based on the above discussion, and both MIR team and Security team ACK, changing the status.

Changed in libssh2 (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Steve Langasek (vorlon) wrote :

foundations-bugs subscribed.

Revision history for this message
Steve Langasek (vorlon) wrote :

Override component to main
libssh2 1.11.0-2 in mantic: universe/libs -> main
libssh2-1 1.11.0-2 in mantic amd64: universe/libs/optional/100% -> main
libssh2-1 1.11.0-2 in mantic arm64: universe/libs/optional/100% -> main
libssh2-1 1.11.0-2 in mantic armhf: universe/libs/optional/100% -> main
libssh2-1 1.11.0-2 in mantic i386: universe/libs/optional/100% -> main
libssh2-1 1.11.0-2 in mantic ppc64el: universe/libs/optional/100% -> main
libssh2-1 1.11.0-2 in mantic riscv64: universe/libs/optional/100% -> main
libssh2-1 1.11.0-2 in mantic s390x: universe/libs/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic amd64: universe/libdevel/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic arm64: universe/libdevel/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic armhf: universe/libdevel/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic i386: universe/libdevel/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic ppc64el: universe/libdevel/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic riscv64: universe/libdevel/optional/100% -> main
libssh2-1-dev 1.11.0-2 in mantic s390x: universe/libdevel/optional/100% -> main
15 publications overridden.

Changed in libssh2 (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.