Skip to contentSkip to conversation

dropbear: Fix host key loading with 521 bit ecdsa keys

PATCH New Stefan Sørensen 3 participants 9 messages May 3, 2018 – Aug 27, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dropbear: Fix host key loading with 521 bit ecdsa keys

Dropbear 2018.76 changed the default ecdsa host key size form 521 to 256 bits, but this breaks systems with an existing 521 bit key, blocking ssh logins.

Apply the upstream fix from https://secure.ucc.asn.au/hg/dropbear/rev/0dc3103a5900 :

Only advertise a single server ecdsa key when -R (generate as required) is specified. Fixes -R now that default ecdsa key size has changed.

---
 package/dropbear/dropbear.hash | 3 +++
 package/dropbear/dropbear.mk   | 1 +
 2 files changed, 4 insertions(+)
package/dropbear/dropbear.hash +3 -0
index ef2011d907..ba42d6bd0c 100644
@@ -1,2 +1,5 @@
 # From https://matt.ucc.asn.au/dropbear/releases/SHA256SUM.asc
 sha256 f2fb9167eca8cf93456a5fc1d4faf709902a3ab70dd44e352f3acbc3ffdaea65 dropbear-2018.76.tar.bz2
+
+# Locally calculated
+sha256 d4a63567465f2bae9fd5e575e022587f832647fb41b023513ac880c4eb647fdd 0dc3103a5900
package/dropbear/dropbear.mk +1 -0
index 1da1a559a3..6bfc05fb2b 100644
@@ -7,6 +7,7 @@
 DROPBEAR_VERSION = 2018.76
 DROPBEAR_SITE = https://matt.ucc.asn.au/dropbear/releases
 DROPBEAR_SOURCE = dropbear-$(DROPBEAR_VERSION).tar.bz2
+DROPBEAR_PATCH = https://secure.ucc.asn.au/hg/dropbear/raw-rev/0dc3103a5900
 DROPBEAR_LICENSE = MIT, BSD-2-Clause-like, BSD-2-Clause
 DROPBEAR_LICENSE_FILES = LICENSE
 DROPBEAR_TARGET_BINS = dropbearkey dropbearconvert scp
Signature · 1 line
2.17.0
#1 lore raw

PATCH 1/1 dropbear: Do not build static binary

Dropbear 2018.76 now uses the --enable-static option to indicate that a static binary should be built. This will incorrectly pick up the generic buildroot option intended for building static libraries, causing an unwanted static binary build with BR2_STATIC_LIBS/BR2_SHARED_STATIC_LIBS.

Fix by appending an --disable-static configure flag, overriding the buildroot default.

---
 package/dropbear/dropbear.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
package/dropbear/dropbear.mk +4 -3
index 6bfc05fb2b..f47f97d036 100644
@@ -28,9 +28,10 @@ DROPBEAR_MAKE = \
 	$(MAKE) MULTI=1 SCPPROGRESS=1 \
 	PROGRAMS="$(DROPBEAR_PROGRAMS)"
 
-ifeq ($(BR2_STATIC_LIBS),y)
-DROPBEAR_CONF_OPTS += --enable-static
-endif
+# The generic --enable-static flags is only intended for use when building
+# libraries, but dropbear will be built as a static executeable with this
+# flag, so we overide it here
+DROPBEAR_CONF_OPTS += --disable-static
 
 # Ensure that dropbear doesn't use crypt() when it's not available
 define DROPBEAR_SVR_PASSWORD_AUTH
Signature · 1 line
2.17.0
#2 lore raw

PATCH 1/1 dropbear: Do not build static binary

Hi Stefan,

Quoted 7 lines · Stefan S?rensen

Dropbear 2018.76 now uses the --enable-static option to indicate that a static binary should be built. This will incorrectly pick up the generic buildroot option intended for building static libraries, causing an unwanted static binary build with BR2_STATIC_LIBS/BR2_SHARED_STATIC_LIBS.

Fix by appending an --disable-static configure flag, overriding the buildroot default.

Your sign-off is missing here.

Quoted 9 lines
---
 package/dropbear/dropbear.mk | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
package/dropbear/dropbear.mk +0 -0
index 6bfc05fb2b..f47f97d036 100644

package/dropbear/dropbear.mk DROPBEAR_MAKE = \ · line 34

Quoted 10 lines
package/dropbear/dropbear.mk +4 -3
@@ -28,9 +28,10 @@ DROPBEAR_MAKE = \
 	$(MAKE) MULTI=1 SCPPROGRESS=1 \
 	PROGRAMS="$(DROPBEAR_PROGRAMS)"
 
-ifeq ($(BR2_STATIC_LIBS),y)
-DROPBEAR_CONF_OPTS += --enable-static
-endif
+# The generic --enable-static flags is only intended for use when building
+# libraries, but dropbear will be built as a static executeable with this
+# flag, so we overide it here
+DROPBEAR_CONF_OPTS += --disable-static

You add --disable-static unconditionally, but we do want to build statically when BR2_STATIC_LIBS=y. So maybe add --disable-static only for BR2_SHARED_STATIC_LIBS=y to counter the effect of --enable-static that Buildroot adds automatically. Would that work for you?

package/dropbear/dropbear.mk DROPBEAR_MAKE = \ · line 37

Quoted 2 lines
package/dropbear/dropbear.mk +0 -0
 # Ensure that dropbear doesn't use crypt() when it's not available
 define DROPBEAR_SVR_PASSWORD_AUTH

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#3 lore raw

PATCH 1/1 dropbear: Do not build static binary

Quoted 7 lines · Baruch Siach
Quoted 7 lines
package/dropbear/dropbear.mk +1 -3
-ifeq ($(BR2_STATIC_LIBS),y)
-DROPBEAR_CONF_OPTS += --enable-static
-endif
+# The generic --enable-static flags is only intended for use when

building
+# libraries, but dropbear will be built as a static executeable with this

Quoted 8 lines

package/dropbear/dropbear.mk DROPBEAR_MAKE = \ · line 34

Quoted 2 lines
package/dropbear/dropbear.mk +2 -0
+# flag, so we overide it here
+DROPBEAR_CONF_OPTS += --disable-static

You add --disable-static unconditionally, but we do want to build statically
when BR2_STATIC_LIBS=y. So maybe add --disable-static only for BR2_SHARED_STATIC_LIBS=y to counter the effect of --enable-static that Buildroot adds automatically. Would that work for you?

The --disable-static causes dropbear to do nothing, i.e. just do a normal link, so that will also work with BR2_STATIC_LIBS=y.

Stefan

#4 lore raw

PATCH 1/1 dropbear: Do not build static binary

Hi S?rensen,

Quoted 17 lines · Stefan
Quoted 7 lines · Baruch Siach
Quoted 7 lines
package/dropbear/dropbear.mk +1 -3
-ifeq ($(BR2_STATIC_LIBS),y)
-DROPBEAR_CONF_OPTS += --enable-static
-endif
+# The generic --enable-static flags is only intended for use when

building
+# libraries, but dropbear will be built as a static executeable with this

Quoted 8 lines

package/dropbear/dropbear.mk DROPBEAR_MAKE = \ · line 34

Quoted 2 lines
package/dropbear/dropbear.mk +2 -0
+# flag, so we overide it here
+DROPBEAR_CONF_OPTS += --disable-static

You add --disable-static unconditionally, but we do want to build statically
when BR2_STATIC_LIBS=y. So maybe add --disable-static only for BR2_SHARED_STATIC_LIBS=y to counter the effect of --enable-static that Buildroot adds automatically. Would that work for you?

Quoted 2 lines

The --disable-static causes dropbear to do nothing, i.e. just do a normal link, so that will also work with BR2_STATIC_LIBS=y.

So if --disable-static is a NOP why do we need it at all?

As far as I can see, the only effect of --enable-static is to add -static to dropbear binaries link command line via LDFLAGS. This is the expected behaviour for BR2_STATIC_LIBS=y. Since BR2_STATIC_LIBS=y is sometimes used with external toolchains that provide both shared and static libraries, the -static link option is required to produce static binaries. Your patch seems to break this use case.

What is this patch meant to fix?

baruch

Signature · 3 lines
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -
#5 lore raw

PATCH v2 1/1 dropbear: Disable legacy/insecure options

In reply to Stefan Sørensen

Dropbear by default enables a number of algorithms that are now considered insecure and should only be used when legacy support is required:
3DES encryption
Blowfish encryption
SHA1-96 message integrity
CBC encryption mode
DSA public keys
Diffie-Hellman Group1 key exchange

So disable them by default, but add a config option for bringing them back.

---
Changes in v2:
- Update for 2018.76
- Use single option for legacy/insecure algorithms

 package/dropbear/Config.in   | 10 ++++++++++
 package/dropbear/dropbear.mk | 12 +++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
package/dropbear/Config.in +10 -0
index 5d6b83b6d1..8c121d0d72 100644
@@ -56,4 +56,14 @@ config BR2_PACKAGE_DROPBEAR_LASTLOG
 	  Enable logging of dropbear access to lastlog. Notice that
 	  Buildroot does not generate lastlog by default.
 
+config BR2_PACKAGE_DROPBEAR_LEGACY_CRYPTO
+	bool "enable legacy crypto"
+	help
+	  Enable legacy and possbibly insecure algorithms:
+	    3DES encryption
+	    SHA1-96 message integrity
+	    CBC encryption mode
+	    DSA public keys
+	    Diffie-Hellman Group1 key exchange
+
 endif
package/dropbear/dropbear.mk +11 -1
index f47f97d036..de29d16e74 100644
@@ -41,13 +41,23 @@ define DROPBEAR_SVR_PASSWORD_AUTH
 endef
 DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_SVR_PASSWORD_AUTH
 
+define DROPBEAR_DISABLE_LEGACY_CRYPTO
+	echo '#define DROPBEAR_3DES 0'                  >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_ENABLE_CBC_MODE 0'       >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_SHA1_96_HMAC 0'          >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_DSS 0'                   >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_DH_GROUP1 0'             >> $(@D)/localoptions.h
+endef
+ifneq ($(BR2_PACKAGE_DROPBEAR_LEGACY_CRYPTO),y)
+DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_DISABLE_LEGACY_CRYPTO
+endif
+
 define DROPBEAR_ENABLE_REVERSE_DNS
 	echo '#define DO_HOST_LOOKUP 1'                 >> $(@D)/localoptions.h
 endef
 
 define DROPBEAR_BUILD_FEATURED
 	echo '#define DROPBEAR_SMALL_CODE 0'            >> $(@D)/localoptions.h
-	echo '#define DROPBEAR_BLOWFISH 1'              >> $(@D)/localoptions.h
 	echo '#define DROPBEAR_TWOFISH128 1'            >> $(@D)/localoptions.h
 	echo '#define DROPBEAR_TWOFISH256 1'            >> $(@D)/localoptions.h
 endef
Signature · 1 line
2.17.0
#6 lore raw

PATCH v2 1/1 dropbear: Disable legacy/insecure options

Quoted 28 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan S?rensen <[email protected]> writes:

Dropbear by default enables a number of algorithms that are now considered insecure and should only be used when legacy support is required:
3DES encryption
Blowfish encryption
SHA1-96 message integrity
CBC encryption mode
DSA public keys
Diffie-Hellman Group1 key exchange

So disable them by default, but add a config option for bringing them back.

---
Changes in v2:
- Update for 2018.76
- Use single option for legacy/insecure algorithms

 package/dropbear/Config.in   | 10 ++++++++++
 package/dropbear/dropbear.mk | 12 +++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
package/dropbear/Config.in +0 -0
index 5d6b83b6d1..8c121d0d72 100644

package/dropbear/Config.in config BR2_PACKAGE_DROPBEAR_LASTLOG · line 62

Quoted 7 lines
package/dropbear/Config.in +4 -0
@@ -56,4 +56,14 @@ config BR2_PACKAGE_DROPBEAR_LASTLOG
 	  Enable logging of dropbear access to lastlog. Notice that
 	  Buildroot does not generate lastlog by default.
 
+config BR2_PACKAGE_DROPBEAR_LEGACY_CRYPTO
+	bool "enable legacy crypto"
+	help
+	  Enable legacy and possbibly insecure algorithms:

s/possbibly/possibly/

Quoted 23 lines
package/dropbear/Config.in +6 -0
+	    3DES encryption
+	    SHA1-96 message integrity
+	    CBC encryption mode
+	    DSA public keys
+	    Diffie-Hellman Group1 key exchange
+
 endif
package/dropbear/dropbear.mk +8 -0
index f47f97d036..de29d16e74 100644
@@ -41,13 +41,23 @@ define DROPBEAR_SVR_PASSWORD_AUTH
 endef
 DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_SVR_PASSWORD_AUTH
 
+define DROPBEAR_DISABLE_LEGACY_CRYPTO
+	echo '#define DROPBEAR_3DES 0'                  >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_ENABLE_CBC_MODE 0'       >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_SHA1_96_HMAC 0'          >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_DSS 0'                   >> $(@D)/localoptions.h
+	echo '#define DROPBEAR_DH_GROUP1 0'             >> $(@D)/localoptions.h
+endef
+ifneq ($(BR2_PACKAGE_DROPBEAR_LEGACY_CRYPTO),y)

package/dropbear/dropbear.mk define DROPBEAR_SVR_PASSWORD_AUTH · line 50

Quoted 10 lines
package/dropbear/dropbear.mk +3 -1
+DROPBEAR_POST_EXTRACT_HOOKS += DROPBEAR_DISABLE_LEGACY_CRYPTO
+endif
+
 define DROPBEAR_ENABLE_REVERSE_DNS
 	echo '#define DO_HOST_LOOKUP 1'                 >> $(@D)/localoptions.h
 endef
 
 define DROPBEAR_BUILD_FEATURED
 	echo '#define DROPBEAR_SMALL_CODE 0'            >> $(@D)/localoptions.h
-	echo '#define DROPBEAR_BLOWFISH 1'              >> $(@D)/localoptions.h

This is not mentioned in the commit description. If this is also considered a legacy algorithm then I guess it is OK to drop it unconditioanlly, but it should be mentioned.

Signature · 1 line
Bye, Peter Korsgaard
#7 lore raw

PATCH 1/1 dropbear: Fix host key loading with 521 bit ecdsa keys

In reply to Stefan Sørensen
Quoted 22 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan S?rensen <[email protected]> writes:

Dropbear 2018.76 changed the default ecdsa host key size form 521 to 256 bits, but this breaks systems with an existing 521 bit key, blocking ssh logins.

Apply the upstream fix from https://secure.ucc.asn.au/hg/dropbear/rev/0dc3103a5900 :

Only advertise a single server ecdsa key when -R (generate as required) is specified. Fixes -R now that default ecdsa key size has changed.

---
 package/dropbear/dropbear.hash | 3 +++
 package/dropbear/dropbear.mk   | 1 +
 2 files changed, 4 insertions(+)
package/dropbear/dropbear.hash +0 -0
index ef2011d907..ba42d6bd0c 100644

package/dropbear/dropbear.hash line 5

Quoted 5 lines
package/dropbear/dropbear.hash +3 -0
@@ -1,2 +1,5 @@
 # From https://matt.ucc.asn.au/dropbear/releases/SHA256SUM.asc
 sha256 f2fb9167eca8cf93456a5fc1d4faf709902a3ab70dd44e352f3acbc3ffdaea65 dropbear-2018.76.tar.bz2
+
+# Locally calculated
+sha256 d4a63567465f2bae9fd5e575e022587f832647fb41b023513ac880c4eb647fdd 0dc3103a5900

Ehh, how did you test this?

Quoted 1 line
Quoted 1 line
Quoted 1 line

dropbear 2018.76 Patching

PATH=/home/peko/source/buildroot/output/host/bin:$PATH support/scripts/apply-patches.sh /home/peko/source/buildroot/output/build/dropbear-2018.76 /var/lib/downloads/dropbear 0dc3103a5900 Unsupported file type for /var/lib/downloads/dropbear/0dc3103a5900, skipping

So I've added the patch in Buildroot instead and committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#8 lore raw

PATCH 1/1 dropbear: Fix host key loading with 521 bit ecdsa keys

In reply to Stefan Sørensen
Quoted 6 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Stefan" == Stefan S?rensen <[email protected]> writes:

Dropbear 2018.76 changed the default ecdsa host key size form 521 to 256 bits, but this breaks systems with an existing 521 bit key, blocking ssh logins.

Quoted 6 lines

Apply the upstream fix from https://secure.ucc.asn.au/hg/dropbear/rev/0dc3103a5900 :

Only advertise a single server ecdsa key when -R (generate as required) is specified. Fixes -R now that default ecdsa key size has changed.

Committed to 2018.02.x, thanks.

Signature · 1 line
Bye, Peter Korsgaard