CVE-2020-11710 (published 2020-04-12T17:15Z)

An issue was discovered in docker-kong (for Kong) through 2.0.3. The admin API port may be accessible on interfaces other than 127.0.0.1. NOTE: The vendor argue that this CVE is not a vulnerability because it has an inaccurate bug scope and patch links. “1) Inaccurate Bug Scope - The issue scope was on Kong's docker-compose template, and not Kong's docker image itself. In reality, this issue is not associated with any version of the Kong gateway. As such, the description stating ‘An issue was discovered in docker-kong (for Kong) through 2.0.3.’ is incorrect. This issue only occurs if a user decided to spin up Kong via docker-compose without following the security documentation. The docker-compose template is meant for users to quickly get started with Kong, and is meant for development purposes only. 2) Incorrect Patch Links - The CVE currently points to a documentation improvement as a “Patch” link: https://github.com/Kong/docs.konghq.com/commit/d693827c32144943a2f45abc017c1321b33ff611.This link actually points to an improvement Kong Inc made for fool-proofing. However, instructions for how to protect the admin API were already well-documented here: https://docs.konghq.com/2.0.x/secure-admin-api/#network-layer-access-restrictions , which was first published back in 2017 (as shown in this commit: https://github.com/Kong/docs.konghq.com/commit/e99cf875d875dd84fdb751079ac37882c9972949) Lastly, the hyperlink to https://github.com/Kong/kong (an unrelated Github Repo to this issue) on the Hyperlink list does not include any meaningful information on this topic.

Severity: HIGH
CVSS v2 base score: 7.5 (AV:N/AC:L/Au:N/C:P/I:P/A:P)
CVSS v3 base score: 9.8, CRITICAL (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H)

Weakness information:
cwe_id: NVD-CWE-Other
cwe_name: Other
description: NVD is only using a subset of CWE for mapping instead of the entire CWE, and the weakness type is not covered by that subset.
extended_description: Insufficient Information

Fix information:
repo_url: https://github.com/Kong/docs.konghq.com
commit_details: repo_url: https://github.com/Kong/docs.konghq.com
author: Colin Hutchinson
author_date: 2020-03-25 14:05:28-04:00
msg: fix(admin) bind the kong admin api port to 127 (#1869)
repository: repo_url: https://github.com/Kong/docs.konghq.com
repo_name: Kong/docs.konghq.com
description: 🦍 Source code for docs.konghq.com website.
repo_language: Ruby
owner: Kong
file_changes: filename: docker.md
change_type: ModificationType.MODIFY
diff: @@ -113,8 +113,8 @@ $ docker run -d --name kong-ee --network=kong-ee-net \
   -e "KONG_ADMIN_GUI_URL=http://<DNSorIP>:8002" \
   -p 8000:8000 \
   -p 8443:8443 \
-  -p 8001:8001 \
-  -p 8444:8444 \
+  -p 127.0.0.1:8001:8001 \
+  -p 127.0.0.1:8444:8444 \
   -p 8002:8002 \
   -p 8445:8445 \
   -p 8003:8003 \

programming_language: Markdown
filename: docker.md
change_type: ModificationType.MODIFY
diff: @@ -91,8 +91,8 @@ Here is a quick example showing how to connect a Kong container to a Cassandra o
         -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
         -p 8000:8000 \
         -p 8443:8443 \
-        -p 8001:8001 \
-        -p 8444:8444 \
+        -p 127.0.0.1:8001:8001 \
+        -p 127.0.0.1:8444:8444 \
         kong:latest
     ```
 
@@ -190,8 +190,8 @@ The steps involved in starting Kong in [DB-less mode] are the following:
         -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
         -p 8000:8000 \
         -p 8443:8443 \
-        -p 8001:8001 \
-        -p 8444:8444 \
+        -p 127.0.0.1:8001:8001 \
+        -p 127.0.0.1:8444:8444 \
         kong:latest
     ```
 

programming_language: Markdown
repo_url: https://github.com/Kong/docker-kong
commit_details: repo_url: https://github.com/Kong/docker-kong
author: Colin Hutchinson
author_date: 2020-03-20 10:57:33-04:00
msg: chore(admin) restrict the admin port to 127 (#350)

* fix(admin) bind admin port to 127 only

* tests need to adjust the compose file for swarm vs docker-compose
repository: repo_url: https://github.com/Kong/docker-kong
repo_name: Kong/docker-kong
description: :monkey: Docker distribution for Kong
repo_language: Shell
owner: Kong
file_changes: filename: docker-compose.yml
change_type: ModificationType.MODIFY
diff: @@ -71,9 +71,9 @@ services:
       - kong-net
     ports:
       - "8000:8000/tcp"
-      - "8001:8001/tcp"
+      - "127.0.0.1:8001:8001/tcp"
       - "8443:8443/tcp"
-      - "8444:8444/tcp"
+      - "127.0.0.1:8444:8444/tcp"
     healthcheck:
       test: ["CMD", "kong", "health"]
       interval: 10s

programming_language: CoffeeScript
filename: tests.sh
change_type: ModificationType.MODIFY
diff: @@ -29,7 +29,7 @@ done
 
 sleep 20
 curl -I localhost:8001 | grep 'Server: openresty'
-
+sed -i -e 's/127.0.0.1://g' docker-compose.yml
 KONG_DOCKER_TAG=${KONG_DOCKER_TAG} docker stack deploy -c docker-compose.yml kong
 sleep 20
 until docker ps | grep ${KONG_DOCKER_TAG}:latest | grep -q healthy; do
@@ -45,6 +45,7 @@ docker stack rm kong
 sleep 20
 docker swarm leave --force
 docker volume prune -f
+git checkout -- docker-compose.yml
 popd
 
 # Validate Kong is running as the Kong user

programming_language: Shell
repo_url: https://github.com/Kong/docs.konghq.com
commit_details: repo_url: https://github.com/Kong/docs.konghq.com
author: Robert Paprocki
author_date: 2017-06-01 14:42:49-07:00
msg: docs(admin-api) securing the admin api
repository: repo_url: https://github.com/Kong/docs.konghq.com
repo_name: Kong/docs.konghq.com
description: 🦍 Source code for docs.konghq.com website.
repo_language: Ruby
owner: Kong
file_changes: filename: docs_nav_0.10.x.yml
change_type: ModificationType.MODIFY
diff: @@ -41,6 +41,9 @@
     - text: Public Lua API reference
       url: /lua-reference/
 
+    - text: Securing the Admin API
+      url: /secure-admin-api
+
     - text: Plugin Development Guide
       url: /plugin-development
       items:

programming_language: CoffeeScript
filename: admin-api.md
change_type: ModificationType.MODIFY
diff: @@ -68,6 +68,11 @@ keep the configuration consistent across all nodes.
 - `8001` is the default port on which the Admin API listens.
 - `8444` is the default port for HTTPS traffic to the Admin API.
 
+This API is designed for internal use and provides full control over Kong, so
+care should be taken when setting up Kong environments to avoid undue public
+exposure of this API. See [this document][secure-admin-api] for a discussion
+of methods to secure the Admin API.
+
 ## Supported Content Types
 
 The Admin API accepts 2 content types on every endpoint:
@@ -1878,3 +1883,4 @@ HTTP 204 No Content
 
 [clustering]: /docs/{{page.kong_version}}/clustering
 [cli]: /docs/{{page.kong_version}}/cli
+[secure-admin-api]: /docs/{{page.kong_version}}/secure-admin-api

programming_language: Markdown
filename: secure-admin-api.md
change_type: ModificationType.ADD
diff: @@ -0,0 +1,142 @@
+---
+title: Securing the Admin API
+---
+
+# Overview
+
+Kong's Admin API provides a RESTful interface for administration and
+configuration of APIs, plugins, consumers, and credentials. Because this
+API allows full control of Kong, it is important to secure this API against
+unwanted access. This document describes a few possible approaches to securing
+the Admin API.
+
+## Table of Contents
+
+- [Network Layer Access Restrictions](#network-layer-access-restrictions)
+  - [Reduce Listening Footprint](#reduce-listening-footprint)
+  - [Layer 3/4 Network Controls](#layer-34-network-controls)
+- [Kong API Loopback](#kong-api-loopback)
+- [Custom Nginx Configuration](#custom-nginx-configuration)
+
+## Network Layer Access Restrictions
+
+### Reduce Listening Footprint
+
+By default, Kong will accept requests for both the public-facing entrypoint, and
+the Admin API, on `0.0.0.0`, which will bind to all available interfaces on the
+host. Reducing this exposure footprint by limiting the interfaces by which the
+Admin API can be accessed is a foundational step. This setting can be adjusted
+via the `admin_listen` Kong configuration directive. For example:
+
+`admin_listen 127.0.0.1:8001`
+
+This will define the Nginx `listen` directive used by Kong to the prescribed
+value, instructing Kong to only respond to requests received on the localhost
+interface.
+
+[Back to TOC](#table-of-contents)
+
+### Layer 3/4 Network Controls
+
+In cases where the Admin API must be exposed beyond a localhost interface,
+network security best practices dictate that network-layer access be restricted
+as much as possible. Consider an environment in which Kong listens on a private
+network interface, but should only be accessed by a small subset of an IP range.
+In such a case, host-based firewalls (e.g. iptables) are useful in limiting
+input traffic ranges. For example:
+
+
+```bash
+# assume that Kong is listening on the address defined below, as defined as a
+# /24 CIDR block, and only a select few hosts in this range should have access
+
+$ grep admin_listen /etc/kong/kong.conf
+admin_listen 10.10.10.3
+
+# explicitly allow TCP packets on port 8001 from the Kong node itself
+# this is not necessary if Admin API requests are not sent from the node
+$ iptables -A INPUT -s 10.10.10.3 -m tcp -p tcp --dport 8001 -j ACCEPT
+
+# explicitly allow TCP packets on port 8001 from the following addresses
+$ iptables -A INPUT -s 10.10.10.4 -m tcp -p tcp --dport 8001 -j ACCEPT
+$ iptables -A INPUT -s 10.10.10.5 -m tcp -p tcp --dport 8001 -j ACCEPT
+
+# drop all TCP packets on port 8001 not in the above IP list
+$ iptables -A INPUT -m tcp -p tcp --dport 8001 -j DROP
+
+```
+
+Additional controls, such as similar ACLs applied at a network device level, are
+encouraged, but fall outside the scope of this document.
+
+[Back to TOC](#table-of-contents)
+
+## Kong API Loopback
+
+Kong's routing design allows it to serve as a proxy for the Admin API itself. In
+this manner, Kong itself can be used to provide fine-grained access control to
+the Admin API. Such an environment requires bootstrapping a new API that defines
+the `admin_listen` address as the API's `upstream_url`. For example:
+
+```bash
+# assume that Kong has defined admin_listen as 127.0.0.1:8001, and we want to
+# reach the Admin API via the url `/admin-api`
+
+$ curl http://localhost:8001/apis \
+  --data name=admin-api \
+  --data uris=/admin-api \
+  --data upstream_url=http://localhost:8001
+
+# we can now transparently reach the Admin API through the proxy server
+$ curl localhost:8000/admin-api/apis
+{  
+   "data":[  
+      {  
+         "uris":[  
+            "\/admin-api"
+         ],
+         "id":"653b21bd-4d81-4573-ba00-177cc0108dec",
+         "upstream_read_timeout":60000,
+         "preserve_host":false,
+         "created_at":1496351805000,
+         "upstream_connect_timeout":60000,
+         "upstream_url":"http:\/\/localhost:8001",
+         "strip_uri":true,
+         "https_only":false,
+         "name":"admin-api",
+         "http_if_terminated":true,
+         "upstream_send_timeout":60000,
+         "retries":5
+      }
+   ],
+   "total":1
+}
+```
+
+From here, simply apply desired Kong-specific security controls (such as
+[basic][basic-auth] or [key authentication][key-auth],
+[IP restrictions][ip-restriction], or [access control lists][acl]) as you would
+normally to any other Kong API.
+
+[Back to TOC](#table-of-contents)
+
+## Custom Nginx Configuration
+
+Kong is tightly coupled with Nginx as an HTTP daemon, and can thus be integrated
+into environments with custom Nginx configurations. In this manner, use cases
+with complex security/access control requirements can use the full power of
+Nginx/OpenResty to build server/location blocks to house the Admin API as
+necessary. This allows such environments to leverage native Nginx authorization
+and authentication mechanisms, ACL modules, etc., in addition to providing the
+OpenResty environment on which custom/complex security controls can be built.
+
+For more information on integrating Kong into custom Nginx configurations, see
+[Custom Nginx configuration & embedding Kong][custom-configuration].
+
+[Back to TOC](#table-of-contents)
+
+[acl]: /plugins/acl
+[basic-auth]: /plugins/basic-authentication/
+[custom-configuration]: /docs/{{page.kong_version}}/configuration/#custom-nginx-configuration
+[ip-restriction]: /plugins/ip-restriction
+[key-auth]: /plugins/key-authentication

programming_language: Markdown