Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zyxel Firewall Unauthenticated Command Injection (CVE-2022-30525) #16563

Conversation

jbaines-r7
Copy link
Contributor

@jbaines-r7 jbaines-r7 commented May 12, 2022

This module exploits CVE-2022-30525, an unauthenticated and remote command injection vulnerability affecting Zyxel firewalls with zero touch provisioning (ZTP) support. This module exploits a command injection exposed by the /ztp/cgi-bin/handler when handling setWanPortSt commands. The module adds OS commands to the mtu field of the setWanPortSt request in order to achieve command execution as nobody.

Affected Zyxel models are:

  • USG FLEX 50, 50W, 100W, 200, 500, 700 using firmware 5.21 and below
  • USG20-VPN and USG20W-VPN using firmware 5.21 and below
  • ATP 100, 200, 500, 700, 800 using firmware 5.21 and below

Check method

The command injection is blind, so I wrote the check function to key off of two elements in the management interface's index.html:

  • The title tag. It reliably contains the model (e.g. USG FLEX 100).
  • A timestamp indicating when the firmware was compiled. The fixed firmware all have a timestamp of April 20, 2022.

I wrote a test server to validate that works across all affected versions. The test server uses some index.html I snagged off of Shodan. The check function works fine on all of those.

Another Thing

I set the disclosure date to April 28, 2022. That's the date Zyxel released the patched firmware. 🤷

Verification

If you have a test target:

  • Follow setup steps above.
  • Do: use exploit/linux/http/zyxel_ztp_rce
  • Do: set RHOST <ip>
  • Do: check
  • Verify the remote host is vulnerable.
  • Do: set LHOST <ip>
  • Do: run
  • Verify the module acquires a nobody shell

PoC Video || GTFO

https://youtu.be/ATdh-TW934k

PCAP || GTFO

zyxel_cve_2022_30525_twice.zip

Perhaps useful to some, the following Suricata rule triggers for both exploitation attempts in the pcap (one for reverse bash, one for reverse meterpreter).

alert http any any -> any any ( \
    msg:"Possible Zyxel ZTP setWanPortSt mtu Exploit Attempt"; \
    flow:to_server; \
    http.method; content:"POST"; \
    http.uri; content:"/ztp/cgi-bin/handler"; \
    http.request_body; content:"setWanPortSt"; \
    http.request_body; content:"mtu"; \
    http.request_body; pcre:"/mtu["']\s*:\s*["']\s*[^0-9]+/i";
    classtype:misc-attack; \
    sid:221270;)

modules/exploits/linux/http/zyxel_ztp_rce.rb Outdated Show resolved Hide resolved
modules/exploits/linux/http/zyxel_ztp_rce.rb Outdated Show resolved Hide resolved
modules/exploits/linux/http/zyxel_ztp_rce.rb Outdated Show resolved Hide resolved
@gwillcox-r7 gwillcox-r7 self-assigned this May 13, 2022
@gwillcox-r7
Copy link
Contributor

Revisions look good, and PCAP and video have been verified. Will go ahead and land this after tests pass.

@gwillcox-r7 gwillcox-r7 merged commit 133b9e3 into rapid7:master May 13, 2022
@gwillcox-r7 gwillcox-r7 added the rn-modules release notes for new or majorly enhanced modules label May 13, 2022
@gwillcox-r7
Copy link
Contributor

Release Notes

A new module has been added to exploit CVE-2022-30525, an unauthenticated remote command injection vulnerability affecting Zyxel firewalls with zero touch provisioning (ZTP) support. Successful exploitation results in remote code execution as the nobody user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs module rn-modules release notes for new or majorly enhanced modules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants