Przejdź do głównej zawartości

How to hack a LTE Router? Just text it!

How to hack a LTE Router? Just text it!

The ZTE MF258 router can be taken over by an unauthenticated user through an SMS payload.

LTE routers are equipped with SIM cards and phone numbers, allowing for the sending and receiving of SMS messages. During my testing, I discovered a vulnerability in which unauthenticated Stored XSS could occur by sending certain text messages to the router. I reported this bug to ZTE and it has been registered as CVE-2023–41781.

The following firmware versions are vulnerable:
1) ZTE_STD_V1.0.0B10
2) ZTE_STD_V1.0.0B08

Exploitation

is a straightforward process…

Prerequisites

This vulnerability can be exploited without authentication.
All that is required is a phone (router) number and for the user to take action by reading new SMS messages through the Web Interface (as shown in picture 1).

Vulnerability

The table view displaying received SMS messages (picture 1) is vulnerable.

1. Vulnerable view — list of received messages

As no escaping has been added to the SMS content column, exploitation is quite easy. I only had to overcome two obstacles:

  1. the displayed message’s content is limited to 35 characters (as shown in picture 2),
  2. newer message is displayed on the top (as shown in picture 3).
2. First obstacle — 35 characters limit per message
3. Second obstacle — reversed order of messages

Due to the aforementioned characteristics, I had to take the following
actions:

  1. split the payload into several messages,
  2. store it in a variable,
  3. for long payloads, load an external script,
  4. execute it with eval function,
  5. send payload in reversed order.
4. On left — prepared “alert” payload in natural order, on right — “alert” payload in reserved order
5. Payload to load external script in reversed order

Impact

By exploiting this vulnerability, I was able to take control of the router. The method used will be explained in the next chapter.

Backup and restore configuration

While it is not possible to change the admin password without knowledge of the current password (as shown in picture 6), it is possible to modify the current device configuration using the ‘download and restore backup configuration’ function (as shown in picture 7).

6. Change password view
7. Backup and restore configuration view

Restoring configuration functionality also restores users and passwords, for Web Panel and SSH. It is important to note that this process does not require any additional authentication or knowledge of the current admin credentials.

The configuration file may appear to be a binary file, but it is actually a simple tar.gz archive. To extract the configuration, follow below steps (shown also in picture 8):

1) rename config.cfg file to config.gz,

2) extract archive with

gzid -d config.gz

3) use the following command to extract the contents of the tar archive:

tar -xf config
8. Extracting device configuration

/etc — SSH access to router

There are two interesting files located in the ‘etc’ folder (see picture 9).

  1. shadow (contains passwords)
  2. passwd (contains users definitions)
9. Structure of etc directory and 2 files — passwd and shadow

The first line of the shadow file contains the root password hash, which consists of two parts:

  1. N1FL.GjU — salt,
  2. hidden (red color) — password hashed in MD5.

The root password can be changed to a password of our choice. An example is presented in picture 10.

10. How to generate new password hash

/www — web panel configuration

Web configuration is a bit easier and contains only one file auth.txt with few lines.

11. Web auth configuration

Changing passwords over here is similar to the /etc directory.

Full vulnerability timeline:

  1. 29th May 2023 —I discovered that the SMS tab was vulnerable and successfully executed an attack,
  2. 30th May 2023 — I reported the issue to ZTE Corporation, however, despite my efforts, no action was taken by ZTE and the only response I received was that the product was excluded from the bug bounty program,
  3. 9th September 2023 — I decided to report the issue to CERT Poland,
  4. 10th September 2023 — Fortunately, CERT Polska took immediate action and pushed ZTE Corporation to fix the issue,
  5. 11th September 2023 — ZTE promised to fix the issue as soon as possible,
  6. January 2024 — a patched firmware release and FOTA update began,
  7. 10th January 2024 — ZTE Corporation conducted a disclosure in security bulletins and CVE database,
  8. 11th February 2024 — full information with PoC became available,
  9. 19th February 2024 — my device was upgraded to the new, patched firmware version ZTE_STD_V1.0.0B11.

ZTE Security bulletin & CVE Mitre

12. ZTE Security Builetin

ZTE Security Bulletins: https://support.zte.com.cn/support/news/LoopholeInfoDetail.aspx?newsId=1034684

13. CVE Mitre record

CVE details: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-41781

Bounty and reward

There was no reward (other than joy and good humor) for the time spent on the study and report.

#cve #cybersecurity #zte #xss #hack #bugbounty

Komentarze

Popularne posty z tego bloga

WordPress -> SQL Injection poprzez plugin Webdorado SpiderCalendar

W zeszłym roku sprawdziłem jakość kodu oraz poprawność przetwarzania danych wejściowych przez plugin „Form Maker” przygotowany przez wydawcę Webdorado. Tym razem postanowiłem sprawdzić czy autor poprawił jakoś kodu swoich produktów. Należy tutaj nadmienić, że poza wersjami darmowymi opartymi na licencji GNU/GPLv2 oferuje on również wersję płatne z dodatkowymi szablonami. Tym razem postaram się opisać wszelkie przeszkody, które musiałem pokonać aby n apisać działającego exploita. Zacząłem zabawę tak, że program był dla mnie black-boxem, ale niestety skończyło się na przejrzeniu kodu. Zapraszam do lektury. Poniżej można zobaczyć jeden z widoków częściowych kalendarza, który domyślnie jest wywoływany z JavaScriptu jako XHR, można jednak go z powodzeniem otworzyć w przeglądarce jako widok główny: http://localhost:8888/wp/wp-admin/admin-ajax.php?action=spiderbigcalendar_month&theme_id=13&calendar=1&select=month,list,week,day,&date=2015-02&many_sp_calend

Inkscape - Ikona koperty

Podstawą naszej pracy będzie oczywiście narysowanie koperty. Lepszy efekt uzyskamy, jeśli narysujemy ją pod pewnym kątem. Musimy jednak oczywiście pamiętać, że konieczne będzie zachowanie proporcji oraz prawidłowe użycie rzutu. Rysujemy najpierw zewnętrzne kontury, potem wewnętrzne elementy, do momentu uzyskania podobnych efektów jak na poniższym zrzucie szkieletowym. By uzyskać widok szkieletowy włączamy opcję Widok -> Tryb Wyświetlania -> Szkieletowy . Z powyginanych trójkątów postaramy się zrobić coś w rodzaju cieni. Grubość linii koperty, które należy narysować u siebie ustawiłem na 4 - tak,by przy mniejszym rozmiarze ikony koperta była bardziej widoczna. Zresztą porównajcie to z oczekiwanym efektem końcowym. Po narysowaniu koperty przejdźmy do tworzenia tła pod kopertę. Jak widać na powyższym załączniku, będzie ono okrągłe. Korzystając z narzędzia "owal" by uzyskać idealne koło przytrzymujemy Ctrl+Shift, podczas gdy rysujemy. Wykorzystany gradient to gradient typu

Przydatne skrypty w MS SQL Server dla platformy Azure

 Jak przygotować skrypt, który wyłączy "Constrainty" w MS SQL Azure:     SELECT 'ALTER TABLE [' + s.name + '].[' + o.name + '] NOCHECK CONSTRAINT ' + i.name AS a     FROM sys.foreign_keys i     INNER JOIN sys.objects o ON i.parent_object_id = o.OBJECT_ID     INNER JOIN sys.schemas s ON o.schema_id = s.schema_id Jak przygotować skrypt, który wycziści wszystkie tabele, po tym jak wyłączysz "Constrainty" w MS SQL Azure:     SELECT DISTINCT 'DELETE FROM  [' + t.name + '] ' AS a     FROM sys.tables t     WHERE t.name <> 'appusers' AND t.name <> 'flyway_schema_history'; Jak przygotować skrypt, który włączy "Constrainty" w MS SQL Azure:     SELECT 'ALTER TABLE [' + s.name + '].[' + o.name + '] CHECK CONSTRAINT ' + i.name AS a     FROM sys.foreign_keys i     INNER JOIN sys.objects o ON i.parent_object_id = o.OBJECT_ID     INNER JOIN sys.schemas s ON o.schema_id = s.schema_i