Yuri Slobodyanyuk Blog on Information Security 2024年09月12日
50,000 VPN usernames and their passwords from Fortigates around the world were leaked last week – what you can do to prevent it from happening to you
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文探讨了 Fortigate VPN 账户泄露事件,并提出了降低风险和防止远程攻击的建议。作者建议通过更改默认端口、使用身份验证、限制地理位置访问、使用静态 IP 地址、禁用休眠账户、实施密码策略、启用安全通信等方法来提高 Fortigate 的安全性。文章还强调了定期扫描端口、关闭不必要的端口以及使用安全证书的重要性。

🤔 **更改默认端口**:攻击者通常会扫描默认端口来寻找漏洞,因此更改默认端口可以有效地降低被发现的风险。例如,将管理 HTTPS 端口更改为 12771,将 SSH 端口更改为 5533,将 VPN SSL 端口更改为 13771。

🔐 **身份验证和授权**:尽量避免在 Fortigate 上存储敏感信息,例如本地用户密码、SNMP 字符串、预共享密钥等。建议使用 LDAP 身份验证、双因素身份验证或用户证书身份验证来提高安全性。

🌎 **地理位置限制**:限制来自特定地理位置的远程访问,例如只允许来自公司所在国家的访问。虽然可以通过代理服务器绕过地理位置限制,但可以有效地阻止大多数机会主义攻击者。

🔒 **静态 IP 地址和 SSL 证书**:只允许来自静态 IP 地址的访问,并使用来自可信提供商的有效 SSL 证书。这可以帮助识别合法的用户并防止攻击者伪造身份。

😴 **禁用休眠账户**:定期检查 VPN 账户,禁用长时间未使用的账户。攻击者可能会尝试使用暴力破解攻击来获取休眠账户的密码。

👮 **密码策略**:为管理员用户设置密码策略,例如强制使用强密码、定期更换密码等。

🛡️ **安全通信**:启用安全通信,例如使用 SSL/TLS 连接到 Active Directory 域控制器,避免使用明文传输密码。

⛔ **不要使用域管理员帐户**:不要使用域管理员帐户来查询 Active Directory,可以使用具有读取权限的普通用户帐户来完成此操作。

📧 **配置变更提醒**:设置电子邮件提醒,以便在 Fortigate 配置发生更改时收到通知。

🧹 **端口扫描和关闭不必要的端口**:定期扫描 Fortigate 的端口,关闭不必要的端口。

🤝 **使用安全工具**:使用 FortiAnalyzer 等安全工具来监控 VPN 用户行为,识别异常行为,并及时采取措施。

🔑 **其他建议**:使用强密码、定期更新 FortiOS 系统、使用安全证书、定期进行安全审计等。

Around 50,000 Fortigate VPN accounts from around the globe were leaked to the public Internet last week. Not really news anymore, you can learn details elsewhere. What I asked myself about that was – is there anything to be done to prevent or lower the damage of such vulnerabilities? The remotely exploitable vulnerabilities after all are that – remote, if you have to provide remote services on your Fortigate (VPN/Port Forwarding, etc), and no one can predict what the next vulnerability is going to be – how can we possible prepare? The short answer we can’t, the long answer – depends.

Below are some ideas of mine to lower the risk/damage or even prevent remote exploitations by built-in Fortigate means. Would these measures prevent such leaks? Not sure, but believe for many of these 50,000 it would.

“Security through obscurity” was the label for such measures in the early 2000s, but not anymore, not at all. Let’s have a look at possible path to such public leaks/dumps. It starts with a script kid Joe hearing some vulnerabilities in Fortinet-something firewall/or “whatever they called the device on the Twitter”. He goes to shodan.io, puts “Fortinet” in the search box and voila – 79,171 devices found! Zero effort. Conveniently for Joe, Nessus has already published the plugin https://www.tenable.com/plugins/nessus/128552 for that (he couldn’t even know that all he needed was curl/wget in a loop), again, zero effort for Joe. He runs the automatic scan and gets the list of vulnerable Fortigates with no idea what to do with them. So, naturally he brags about “pwn1ng” lots of Pentagon firewalls on social networks. This list of devices gradually spreads, until someone bored enough to run a wget downloading VPN users caches from those Fortigates finds it amusing to post the dump online. Again – zero effort on the attacker part. The Fortigates haven’t been compromised yet, but now each and every vulnerable Fortigate, which could go unnoticed for years, is being probed/watched by tens, then hundreds, then thousands Joe/Jane on the Internet until someone sees a benefit and connects with the stolen VPN credentials for real and pivots into the LAN.

All this “chain of contagion” could have been prevented should the Fortigate admin had implemented the “masks protection”, of course first of all updates to the FortiOS, but even the measures below would do the trick.

Change the default listening ports of the Fortigate services.

Internet is being scanned all the time by multiple parties. The aforementioned search in Shodan.io, if you noticed, shows most popular services as well, and most of them are default ports for default Fortigate services. The same goes for other scanners – doing the wide scan on all 65K ports is very, very expensive. Only large organizations can afford it, but then, we will categorize them as an APT threat and beyond scope of this article. The majority, though, scan only well-known ports in general, and to a lesser degree well-known ports for a given vendor. By changing the listening ports of such services, you stop the “chain reaction” I depicted above because even being vulnerable, your Fortigate will not be discovered by such scans. Here is how to change some of the services:

Here I change admin HTTPS port to 12771 and SSH port to 5533:

config system globalset admin-sport 12771set admin-telnet disableset admin-ssh-port 5533

Here I change VPN SSL listening port from the default 10443 to 13771:

config vpn ssl settingsset port 13771

Any sensitive information stored on the perimeter is bad. Authorize/authenticate users remotely.

We cannot reliably predict which remotely exploitable vulnerability will affect what next time, service-wise. We can, nevertheless, say with certainty that the first (and probably the only) device to be affected by such a vulnerability will be the Fortigate itself and everything stored in its configuration. This includes any “secret” information like local users’ passwords, SNMP strings, pre-shared keys, Active Domain query domain user, etc. The only remedy here is to move as much of such secret data away from Fortigate as possible.

Local users (admin/VPN) options:
- Local users but LDAP authentication against Active Directory.
- (Ideal) No local users: everything is stored on Active Directory server.
- Local/remote user but with Two Factor Authentication enabled (free for 2 FortiTokens Mobile, unlimited free for email, and almost free for SMS authentication when purchased in bulk from your SMS Gateway provider, not to say Duo and others are there as well).
- Local user but with the user certificate authentication (free of charge).

Use Geo Location to limit remote access.

In most of the cases your remote workers work from the same country. So, if you are an Israeli company with all your Remote VPN connections coming from Israel – why allow the whole world to connect to the VPN Portal? Use Geo addresses to limit access to the VPN portal or any other service limitation. It can be circumvented by using local country proxy/VPN-for-hire servers, but we are talking about opportunistic attackers, not resolved ones.

Consider allowing access to SSL VPN only from static IPs.

If you, the IT admin, cannot say for sure to what device you are logging in, how can the your less technical users tell? They can’t. Unless you tell them to enter VPN SSL portal only via FQDN name (and please, refrain from vpn.example.com, vpnssl.example.com or remote.example.com) and present their browser/FortiClient with valid SSL certificate bought from a trusted provider for some 20$/year. I use valid SSL certificates even to connect to my labs, and paid some 8$ for it. People even made Fortigate work with Let’s encrypt free certificate, just Google it.

Also, nothing screams “I am Fortigate” to the network scan as the default SSL certificate issued by “Fortinet, CA, USA”.

Dormant remote access accounts are your “sleeper agents”, find and shut them.

An attacker needs no vulnerability if she has access to the VPN with local users and enough time to guess the user and its password. I’ve seen enough of local VPN accounts not used for YEARS, but still being active. Brute forcing takes time, but a dedicated attacker will continue guessing passwords for days/months and in the end she will succeed. With FortiAnalyzer you can have report auto-send to you on VPN users’ behavior and filter those that are not in use. But even plain System Events/User Events logs are good enough to weed out dormant VPN users.

Use password policy at least for admin users.

Unfortunately, Fortigate doesn’t provide currently for password policy for local SSL VPN users yet, but for admins they have existed for a long time. So, no real reason not to use them at least for admins who connect from the Internet to prevent password guessing.

Enable secure communication with Active Directory Domain Controller.

I see it, unfortunately, all the time in 2021 as well – Domain Admin user is configured in Fortigate for querying AD DC and … over the port 389 without “Secure connection” turned on. Fortunately for an attacker that manages to get CLI access to the firewall it means now he has password for Domain Admin ready and served. All he needs to do is to run a sniffer in Fortigate diagnose sniffer packet any ‘port 389’ 6 and see Domain Admin pass being sent in clear text for LDAP binding. Great (not).

Do not use Domain Admin account to query the Active Directory.

The untold truth is that you only need an AD user that can READ, not write, the Directory Tree where the VPN users are located. That is, a REGULAR AD user will do the job just well, no need for Domain Admin at all for VPN authentication.

Alert email on firewall configuration changes.

Production-level firewalls do not change every day, so every configuration change should be noticed and accounted for. In older FortiOS version we have Alert Email in Logs settings to be sent each time the configuration changes. The newer ones also have Automation stitches that can send email each time the configuration changed (and not only).

Port scan your Fortigate and close open ports in Local Policy.

Fortigate has quite a few ports open by default. They can only be seen in GUI after enabling “Local Policy” in Feature visibility, and changed only on CLI. Do not panic once you look there and see lots of open ports – not all of them/may be none of them are exploitable, but anyway as a hygiene rule – close everything on a need-to-work basis. You can read more about this on Fortigate Local in Policy what it does and how to change/configure it . Here is a typical list of open ports:

Follow me on https://www.linkedin.com/in/yurislobodyanyuk/ not to miss what I publish on Linkedin, Github, blog, and more.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Fortigate VPN 安全漏洞 网络安全 安全建议
相关文章