Hardening FortiGate Management Access with Local-in Policy


Most FortiGate compromises of the last few years started the same way: an exposed management interface or SSL VPN portal on the WAN, and a critical CVE published before anyone had time to patch. Firmware upgrades fix the bug, but they don’t fix the exposure.

When I audited the FortiGates I manage, I found everything from perfect configurations to devices with an empty local-in policy and HTTPS admin open to the whole internet. This post is the standard I now apply to every box.

What a local-in policy actually is

Normal firewall policies control transit traffic – packets passing through the FortiGate between interfaces. Local-in policies control traffic whose destination is the FortiGate itself: admin GUI, SSH, SNMP, ping, SSL VPN, IKE.

If you come from Linux, it’s the INPUT chain in iptables, while regular policies are FORWARD.

A few things worth knowing:

  • Local-in policies are evaluated before regular policies and apply only to incoming traffic towards a FortiGate IP.
  • They’re configured from the CLI. The GUI can only list them (and only after enabling Local In Policy in Feature Visibility).
  • The default action is deny, but you’ll only see that with show full-configuration.

Why not just trusted hosts?

set trustedhost1 on the admin account limits who can log in, but the FortiGate still accepts the TCP connection and serves the login page. Several pre-auth vulnerabilities were exploitable exactly in that window. Local-in drops the packet before the daemon ever sees it.

I use both: trusted hosts per admin, local-in per interface.

Step 1 – An inverted address group

The trick is to define the group backwards. Instead of listing who is blocked (everyone), you list who is allowed, and then flip the logic with exclude.

All_Except_MGMT
│   member: "all"
│   exclude: enable
└── MGMT_SOURCES
    ├── MGMT_MONITORING   → 198.51.100.21/32
    ├── MGMT_OFFICE_WAN   → 198.51.100.170/32
    ├── MGMT_JUMPHOSTS    → 198.51.100.112/28
    └── MGMT_VPN          → 203.0.113.112/28
config firewall address
    edit "MGMT_MONITORING"
        set subnet 198.51.100.21 255.255.255.255
    next
    edit "MGMT_OFFICE_WAN"
        set subnet 198.51.100.170 255.255.255.255
    next
    edit "MGMT_JUMPHOSTS"
        set subnet 198.51.100.112 255.255.255.240
    next
    edit "MGMT_VPN"
        set subnet 203.0.113.112 255.255.255.240
    next
end

config firewall addrgrp
    edit "MGMT_SOURCES"
        set member "MGMT_MONITORING" "MGMT_OFFICE_WAN" "MGMT_JUMPHOSTS" "MGMT_VPN"
    next
    edit "All_Except_MGMT"
        set member "all"
        set exclude enable
        set exclude-member "MGMT_SOURCES"
        set comment "Everyone except management sources"
    next
end

The big advantage: when you add a new monitoring server or office, you only add one object to MGMT_SOURCES. The policy itself never changes – which matters when you have the same template on 20+ devices.

Step 2 – Service objects

If you moved admin HTTPS or SSH to non-default ports (you should), create matching services. Same for SSL VPN and IKE over TCP:

config firewall service custom
    edit "MGMT_HTTPS"
        set tcp-portrange 8443
    next
    edit "SSL_VPN"
        set tcp-portrange 10443
    next
end

Step 3 – The deny rule for management

config firewall local-in-policy
    edit 100
        set intf "wan1" "wan2"
        set srcaddr "All_Except_MGMT"
        set dstaddr "all"
        set service "SSH" "HTTPS" "MGMT_HTTPS" "SNMP" "ALL_ICMP"
        set schedule "always"
        set action deny
    next
end

Read it as: on the WAN interfaces, drop SSH, HTTPS, SNMP and ICMP from everyone who isn’t a management source. Notice ALL_ICMP – your monitoring still pings the device because it’s in the allowed group, random scanners don’t.

Step 4 – GeoIP for SSL VPN

If the device still runs SSL VPN (see why you should migrate away), restrict it to the countries your users actually are in:

config firewall address
    edit "GEO_SK"
        set type geography
        set country "SK"
    next
    edit "GEO_CZ"
        set type geography
        set country "CZ"
    next
end

config firewall addrgrp
    edit "VPN_ALLOWED_COUNTRIES"
        set member "GEO_SK" "GEO_CZ"
    next
end

config firewall local-in-policy
    edit 102
        set intf "wan1" "wan2"
        set srcaddr "VPN_ALLOWED_COUNTRIES"
        set dstaddr "all"
        set service "SSL_VPN"
        set schedule "always"
        set action accept
    next
    edit 103
        set intf "wan1" "wan2"
        set srcaddr "all"
        set dstaddr "all"
        set service "SSL_VPN"
        set schedule "always"
        set action deny
    next
end

Order matters – accept (102) has to be above deny (103). In practice this alone cut the brute-force noise in the VPN logs by well over 90 %.

GeoIP is not a security boundary – anyone can rent a VPS in your country – but it removes the automated mass scanning, and that’s most of the traffic.

Topology gotchas

A template is only useful if you know where it breaks:

  • Single WAN models – the interface is called wan, not wan1.
  • Aggregated uplinks – use the aggregate name (e.g. Outside), not the member ports.
  • MPLS on wan1 – if wan1 is a private carrier network, apply the policy only to the internet-facing interface. Otherwise you may block your own monitoring that comes over MPLS.

Verify – and don’t lock yourself out

show firewall local-in-policy
show full-configuration firewall local-in-policy
diagnose firewall iprope list 100001

Before applying on a remote device, make sure the IP you’re connected from is in MGMT_SOURCES, or have out-of-band access ready. If something gets dropped by local-in, diagnose debug flow shows it as iprope_in_check() check failed on policy 0, drop – more on that in my debug flow cheat sheet.

Audit checklist

When I went through the fleet, these were the typical findings:

  • empty local-in policy (rule exists, no address group) – effectively nothing blocked
  • rule only on wan1, wan2 forgotten after a second ISP was added
  • rule present but set status disable
  • non-standard IDs and per-device ACLs that nobody remembers

None of these show up in the GUI, which is exactly why they survive for years. Put local-in into your standard build and check it during every firmware upgrade.