Skip to content

Commit b21acab

Browse files
committed
Merge #15993: net: Drop support of the insecure miniUPnPc versions
59cb722 Update configure to reject unsafe miniUPnPc API ver (Hennadii Stepanov) ab21905 doc: Add release notes for 15993 (Hennadii Stepanov) 02709e9 Align formatting with clang-format (Hennadii Stepanov) 91a1b85 Use PACKAGE_NAME in UPnP description (Hennadii Stepanov) 9f76e45 Drop support of insecure miniUPnPc versions (Hennadii Stepanov) Pull request description: 1. Minimum supported miniUPnPc API version is set to 10: - https://packages.ubuntu.com/xenial/libminiupnpc-dev - https://packages.debian.org/jessie/libminiupnpc-dev Refs: - #6583 - #6789 - #10414 2. The hardcoded "Bitcoin" replaced with `PACKAGE_NAME`: ![Screenshot from 2019-05-06 23-10-29](https://user-images.githubusercontent.com/32963518/57253178-afc60780-7056-11e9-83c9-e85670c58c1e.png) 3. Also style-only commit applied. Pardon: could not reopen my previous PR #15966. ACKs for top commit: ryanofsky: utACK 59cb722. Changes since last review: adding a new commit which updates configure script to fall back to disabling upnp if version is too old, adding a requested comment explaining static_assert condition, and fixing a spelling (jessy/jessie) Tree-SHA512: 42ed11bc2fb2ec83d5dd58e2383da5444a24fd572707f6cf10b622cb8943e28adfcca4750d06801024c4472625b5ea9279516fbd9d2ccebc9bbaafe1d148e80d
2 parents 74ea1f3 + 59cb722 commit b21acab

File tree

4 files changed

+43
-33
lines changed

4 files changed

+43
-33
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ jobs:
144144
env: >-
145145
HOST=x86_64-unknown-linux-gnu
146146
DOCKER_NAME_TAG=ubuntu:14.04
147-
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libicu-dev libpng-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.1++-dev libminiupnpc-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
147+
PACKAGES="python3-zmq qtbase5-dev qttools5-dev-tools libicu-dev libpng-dev libssl-dev libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev libdb5.1++-dev libzmq3-dev libprotobuf-dev protobuf-compiler libqrencode-dev"
148148
NO_DEPENDS=1
149149
RUN_FUNCTIONAL_TESTS=false
150150
GOAL="install"

configure.ac

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,26 @@ if test x$use_upnp != xno; then
994994
[AC_CHECK_LIB([miniupnpc], [upnpDiscover], [MINIUPNPC_LIBS=-lminiupnpc], [have_miniupnpc=no])],
995995
[have_miniupnpc=no]
996996
)
997+
dnl The minimum supported miniUPnPc API version is set to 10. This keeps compatibility
998+
dnl with Ubuntu 16.04 LTS and Debian 8 libminiupnpc-dev packages.
999+
if test x$have_miniupnpc != xno; then
1000+
AC_MSG_CHECKING([whether miniUPnPc API version is supported])
1001+
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
1002+
@%:@include <miniupnpc/miniupnpc.h>
1003+
]], [[
1004+
#if MINIUPNPC_API_VERSION >= 10
1005+
// Everything is okay
1006+
#else
1007+
# error miniUPnPc API version is too old
1008+
#endif
1009+
]])],[
1010+
AC_MSG_RESULT(yes)
1011+
],[
1012+
AC_MSG_RESULT(no)
1013+
AC_MSG_WARN([miniUPnPc API version < 10 is unsupported, disabling UPnP support.])
1014+
have_miniupnpc=no
1015+
])
1016+
fi
9971017
fi
9981018

9991019
if test x$build_bitcoin_wallet$build_bitcoin_cli$build_bitcoin_tx$build_bitcoind$bitcoin_enable_qt$use_tests$use_bench = xnonononononono; then
@@ -1387,9 +1407,10 @@ dnl enable upnp support
13871407
AC_MSG_CHECKING([whether to build with support for UPnP])
13881408
if test x$have_miniupnpc = xno; then
13891409
if test x$use_upnp = xyes; then
1390-
AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
1410+
AC_MSG_ERROR("UPnP requested but cannot be built. Use --without-miniupnpc.")
13911411
fi
13921412
AC_MSG_RESULT(no)
1413+
use_upnp=no
13931414
else
13941415
if test x$use_upnp != xno; then
13951416
AC_MSG_RESULT(yes)

doc/release-notes-15993.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Build system changes
2+
--------------------
3+
The minimum supported miniUPnPc API version is set to 10. This keeps compatibility with Ubuntu 16.04 LTS and Debian 8 `libminiupnpc-dev` packages. Please note, on Debian this package is still vulnerable to [CVE-2017-8798](https://security-tracker.debian.org/tracker/CVE-2017-8798) (in jessie only) and [CVE-2017-1000494](https://security-tracker.debian.org/tracker/CVE-2017-1000494) (both in jessie and in stretch).

src/net.cpp

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
#include <miniupnpc/miniwget.h>
3838
#include <miniupnpc/upnpcommands.h>
3939
#include <miniupnpc/upnperrors.h>
40+
// The minimum supported miniUPnPc API version is set to 10. This keeps compatibility
41+
// with Ubuntu 16.04 LTS and Debian 8 libminiupnpc-dev packages.
42+
static_assert(MINIUPNPC_API_VERSION >= 10, "miniUPnPc API version >= 10 assumed");
4043
#endif
4144

4245
#include <unordered_map>
@@ -1404,16 +1407,10 @@ static void ThreadMapPort()
14041407
struct UPNPDev * devlist = nullptr;
14051408
char lanaddr[64];
14061409

1407-
#ifndef UPNPDISCOVER_SUCCESS
1408-
/* miniupnpc 1.5 */
1409-
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0);
1410-
#elif MINIUPNPC_API_VERSION < 14
1411-
/* miniupnpc 1.6 */
14121410
int error = 0;
1411+
#if MINIUPNPC_API_VERSION < 14
14131412
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error);
14141413
#else
1415-
/* miniupnpc 1.9.20150730 */
1416-
int error = 0;
14171414
devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error);
14181415
#endif
14191416

@@ -1427,43 +1424,32 @@ static void ThreadMapPort()
14271424
if (fDiscover) {
14281425
char externalIPAddress[40];
14291426
r = UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, externalIPAddress);
1430-
if(r != UPNPCOMMAND_SUCCESS)
1427+
if (r != UPNPCOMMAND_SUCCESS) {
14311428
LogPrintf("UPnP: GetExternalIPAddress() returned %d\n", r);
1432-
else
1433-
{
1434-
if(externalIPAddress[0])
1435-
{
1429+
} else {
1430+
if (externalIPAddress[0]) {
14361431
CNetAddr resolved;
1437-
if(LookupHost(externalIPAddress, resolved, false)) {
1432+
if (LookupHost(externalIPAddress, resolved, false)) {
14381433
LogPrintf("UPnP: ExternalIPAddress = %s\n", resolved.ToString().c_str());
14391434
AddLocal(resolved, LOCAL_UPNP);
14401435
}
1441-
}
1442-
else
1436+
} else {
14431437
LogPrintf("UPnP: GetExternalIPAddress failed.\n");
1438+
}
14441439
}
14451440
}
14461441

1447-
std::string strDesc = "Bitcoin " + FormatFullVersion();
1442+
std::string strDesc = PACKAGE_NAME " " + FormatFullVersion();
14481443

14491444
do {
1450-
#ifndef UPNPDISCOVER_SUCCESS
1451-
/* miniupnpc 1.5 */
1452-
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
1453-
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0);
1454-
#else
1455-
/* miniupnpc 1.6 */
1456-
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype,
1457-
port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0");
1458-
#endif
1445+
r = UPNP_AddPortMapping(urls.controlURL, data.first.servicetype, port.c_str(), port.c_str(), lanaddr, strDesc.c_str(), "TCP", 0, "0");
14591446

1460-
if(r!=UPNPCOMMAND_SUCCESS)
1461-
LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n",
1462-
port, port, lanaddr, r, strupnperror(r));
1463-
else
1447+
if (r != UPNPCOMMAND_SUCCESS) {
1448+
LogPrintf("AddPortMapping(%s, %s, %s) failed with code %d (%s)\n", port, port, lanaddr, r, strupnperror(r));
1449+
} else {
14641450
LogPrintf("UPnP Port Mapping successful.\n");
1465-
}
1466-
while(g_upnp_interrupt.sleep_for(std::chrono::minutes(20)));
1451+
}
1452+
} while (g_upnp_interrupt.sleep_for(std::chrono::minutes(20)));
14671453

14681454
r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0);
14691455
LogPrintf("UPNP_DeletePortMapping() returned: %d\n", r);

0 commit comments

Comments
 (0)