Living off the VPN — Exploring VPN Post-Exploitation Techniques
The article describes post-exploitation techniques that an attacker who already controls a VPN management interface can use to steal credentials and secrets. These include capturing cleartext LDAP passwords, registering a rogue authentication server to leak user credentials, and decrypting configuration file secrets using a hard-coded key or by disabling custom encryption.
Client-Side Protection & Compliance
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
This research looks at what an attacker can do after a VPN server has already been compromised, using only the VPN management interface rather than a custom implant on the device OS. The author, Ori David, calls this "living off the VPN." The test subjects were Ivanti Connect Secure and FortiGate VPN appliances.
Normally a VPN server authenticates remote users, often by forwarding their credentials to an external authentication server such as LDAP (commonly Active Directory) or RADIUS. It also stores secrets in its configuration file: local user passwords, SSH keys, certificates, and credentials for third-party service accounts. The research abuses both of these normal functions.

The framing question of the post is what an attacker can accomplish while using only the VPN management interface.
Setup
The work assumes the attacker already controls the VPN server by some other means: a vulnerability, stolen credentials, an authentication bypass, weak credentials, or phishing. No specific product versions are given. The techniques were tested against Ivanti Connect Secure and FortiGate appliances, and the author believes variations are likely to be relevant for other VPN servers and edge devices.
The tools used are the appliances' own features: the built-in packet capture, the user group and authentication realm configuration, and the configuration export. For the rogue authentication server the author used a RADIUS server under attacker control.
Finding it
The starting observation is that most VPN post-exploitation relies on dropping a custom implant on the device OS after RCE. That is expensive because appliances run custom hardened operating systems, so it has typically been the domain of top-tier nation-state actors. The author instead asked what the management interface alone allows.
Two behaviours stood out.
First, when a VPN validates LDAP credentials, FortiGate uses simple authentication, meaning it sends the password to the server in cleartext. Two sets of credentials are transmitted: the LDAP service account configured on FortiGate and the credentials supplied by the authenticating user. Ivanti supports both a normal LDAP server and an AD server; with plain LDAP it performs a simple bind and both the service account and user credentials go out in cleartext, but the default for an LDAP authentication server is TLS and LDAPS is also supported, so Ivanti instances are less likely to use plain LDAP. With an AD authentication server, Ivanti uses Kerberos, so no passwords are transmitted.
Second, the way user groups and realms resolve members does not match the user to a single authentication method. On FortiGate, once a remote group is added to a user group, any member authenticating causes FortiGate to try the local user database and the remote authentication server, and with several remote servers it tries all of them. On Ivanti, an authentication realm is limited to a single authentication server, but an "additional authentication server" can be configured for certain SSO setups, and then both servers must approve the credentials.
Exploitation
Step 1: Capture cleartext LDAP credentials with the built-in packet capture
When plain LDAP is used, any credential sent to the VPN can be compromised by an attacker between the VPN and the LDAP server, or by an attacker who controls the VPN. Both FortiGate and Ivanti include a built-in packet capture feature; capturing LDAP packets intercepts all credentials that pass through the VPN.
If a secure protocol is in use, no cleartext credentials leave the server, but an attacker who controls the VPN can modify the configuration and downgrade it. For normal LDAP servers, change the configuration to plain LDAP. To downgrade Ivanti's AD server, use the AD connection details to configure a new normal LDAP server in place of the existing one. In both cases the change should be transparent to users and causes the VPN to send passwords in cleartext.
Step 2: Register a rogue authentication server
To leak credentials of any user authenticating to FortiGate or Ivanti, add a rogue authentication server to a user group or realm. On FortiGate, create a remote group that uses the rogue server and add it to the target user group. On Ivanti, add the rogue server as an additional authentication server for the target realm. Whenever a member of the target group or realm authenticates, the VPN tries to validate their credentials against the rogue server. This covers clients connecting to the VPN and administrators connecting to the management interface; any authentication managed through a user group or realm can be hijacked this way.
A RADIUS server is convenient for capturing the credentials for two reasons: credentials are sent in the initial request without first checking whether the user exists on the server, and they are encrypted with a key the attacker chooses, so the cleartext can be recovered. The following script, based on RFC 2865, decrypts RADIUS passwords:
import hashlib
# Authenticator value can be obtained from the PCAP
authenticator = bytearray.fromhex("[redacted]")
enc = bytearray.fromhex("[redacted]")
# Pre-shared key configured by the attacker when setting up the rogue server
secret = bytes("verygoodpsk", "utf-8")
chunk_len = 16
enc_chunks = []
dec = ""
for i in range(0, len(enc), chunk_len):
enc_chunks.append(enc[i:i+chunk_len])
for chunk in enc_chunks:
dec_chunk = b""
chunk_key = hashlib.md5(secret + authenticator ).digest()
i = 0
for enc_byte in chunk:
dec_chunk += (enc_byte ^ chunk_key[i]).to_bytes(1,"big")
dec += chr(enc_byte ^ chunk_key[i])
i+=1
authenticator = chunk
print(dec)
The authenticator comes from the captured PCAP, the encrypted blob is the RADIUS password attribute, and the secret is the pre-shared key the attacker set on the rogue server. Each 16-byte chunk is XORed with MD5 of the secret plus the previous authenticator (the initial one for the first chunk), and the chunk becomes the authenticator for the next.
One caveat on Ivanti: because both servers must approve the user, a rogue server that rejects credentials would lock users out. The rogue RADIUS server must therefore be configured to approve any credentials it receives.
Step 3: Decrypt FortiGate configuration secrets
Secrets in the configuration file are stored encrypted, but integration passwords must be recoverable because the cleartext is needed to connect to the third party, so the encryption is reversible. FortiGate uses AES with a single hard-coded key shared across all appliances, as documented in Bart Dopheide's blog post on FortiGate password encryption. Fortinet assigned CVE 2019-6693 and allowed users to change the hard-coded key to a custom one, but the key was not changed, so by default appliances still use the same key. A configuration file from a default appliance can therefore be decrypted; the author points to a public implementation of the decryption process.
If the admin did set a custom key, the attacker who controls the VPN can still get the secrets. The private-data-encryption setting controls the custom key, and it can simply be disabled, with no knowledge of the current key, which reverts encryption of all secrets to the original hard-coded key:
FGT # config system global
FGT (global) # set private-data-encryption disable
FGT (global) # end
After that, download the configuration file and decrypt the secrets with the known default key. Among the secrets are credentials for the "external connector" integrations, which may cover cloud providers, SAP, Kubernetes, ESXi and more. Some require high privileges: the "Poll Active Directory Server" integration requires an account with administrative access to a domain controller, which can turn a FortiGate breach into a full domain compromise.
Step 4: Decrypt Ivanti configuration secrets
Ivanti also stores secrets with reversible encryption, and the key is again a static string found by extracting code from the device. The author redacted the full key but notes that its beginning suggests it has likely not changed since at least 2015, when Juniper last owned Connect Secure. The algorithm is more complex than FortiGate's but still reversible, so secrets across all Ivanti instances are encrypted with one static key that cannot be changed, and any Ivanti configuration file can be decrypted.
Rather than write a decryptor, the author used a dedicated attacker-owned Ivanti instance as an oracle:
- Obtain an encrypted password from an Ivanti configuration file.
- In a lab, set up an Ivanti instance and an LDAP server (for example a Windows server running Active Directory).
- On the lab Ivanti instance, configure the LDAP server as an authentication server that uses simple authentication.
- Export the lab Ivanti configuration to a file.
- Replace the existing encrypted LDAP password in the configuration file with the encrypted password to decrypt.
- Import the modified configuration file back into the Ivanti instance.
Triggering an authentication attempt to the LDAP server makes Ivanti decrypt the password from the configuration and send it in cleartext to the LDAP server; capturing the packets yields the decrypted password. The author's testing showed this works for all secrets stored in the configuration file, including AD passwords, RADIUS pre-shared keys and API keys.
Step 5: Read cleartext MDM passwords
Ivanti supports several MDM servers as authentication methods, and the integration requires credentials for the MDM server. The configuration for the MDM server contains two fields, "password-encrypted" and "password-cleartext", and despite the names both are stored in cleartext.
Root cause
The design mistakes are: authentication methods are not matched to individual users, so a rogue server added to a group or realm receives credentials for every member; LDAP simple bind sends passwords in cleartext, and a VPN administrator can downgrade a secure configuration to it; configuration secrets use reversible encryption with a single hard-coded or static key, and on FortiGate the custom key can be disabled without knowing it; and the MDM password fields are stored in cleartext regardless of their names.
Impact
An attacker who controls the VPN can obtain credentials of VPN users and administrators, service account credentials for LDAP and other integrations, and secrets such as SSH keys, certificates, RADIUS pre-shared keys and API keys. This can provide access to additional resources in the network and potentially turn a VPN compromise into a full network compromise. The author says it is likely that some of these techniques are already used in the wild: Mandiant's Cutting Edge report on Ivanti exploitation campaigns described attackers compromising the LDAP service account configured on the Ivanti device, and although it does not detail how, the author believes it is fairly likely they used one of these methods, extracting the credentials from the configuration file or sniffing network traffic. The techniques are trivial to implement, so attackers of all sophistication levels can use them.
Fix
Ivanti assigned CVE-2024-13842 and CVE-2024-13843 to the hard-coded key issue and the MDM cleartext passwords, but had not released a patch at the time of publication. Fortinet concluded that none of the described issues required a fix, then said it intended to fix the custom encryption key bypass, and finally decided not to fix it because it "does not cross a security boundary." The author's recommendations are to employ Zero Trust Network Access instead of all-or-nothing VPN access, limit service account permissions preferably to read only and avoid integrations that need strong permissions, use dedicated identities such as purpose-issued certificates for VPN authentication rather than existing AD accounts, and monitor configuration changes by comparing against a golden image and analysing device logs.
Variants to test
- Add a rogue RADIUS or LDAP server to a user group or realm on another VPN product and authenticate as a test user. A positive result is the rogue server receiving that user's credentials.
- Capture LDAP traffic with the appliance's packet capture while a user authenticates over plain LDAP. A positive result is the service account and user password in cleartext.
- Switch an LDAP configuration from LDAPS to plain LDAP and authenticate. A positive result is the password arriving in cleartext, with the change expected to be transparent to the user.
- Export a configuration file from a default-configured appliance and attempt decryption with the vendor's known default key. A positive result is readable secrets.
- Disable the custom encryption key setting and re-export the configuration. A positive result is secrets decryptable with the default key.
- Feed an encrypted secret from one instance into a lab instance configured for simple LDAP authentication and capture the outbound bind. A positive result is the decrypted secret in the packet capture.
- Inspect MDM or similar integration fields named as encrypted and compare them with the cleartext field. A positive result is identical cleartext values in both.
What happened, in plain words
A VPN is a service that lets people outside an office connect securely to the office network, as if they were sitting inside it. Many companies run a VPN server at the edge of their network so staff can work from home. Because that server is reachable from the internet, it is a popular target for attackers.
Most security research about VPNs looks at how an attacker gets in: a bug in the VPN software, a stolen password, a trick that skips the login. This research asks a different question. Suppose the attacker is already inside the VPN server. What else can they do, using only the normal management screens of the device, without installing any custom malicious program on it?
The author, Ori David, calls this idea "living off the VPN." The name is a play on "living off the land," a phrase for attackers who use tools already present on a victim's computer instead of bringing their own. Here the "tools" are the VPN's own features: its packet capture, its user group settings, and its configuration export.
The two products tested were Ivanti Connect Secure and FortiGate, both widely used VPN appliances. An appliance here means a dedicated box (or virtual machine) that does one job, in this case running the VPN.
The research found two kinds of problems. First, several actual vulnerabilities, which got official CVE numbers (a CVE is a public catalogue entry for a known security flaw). Second, a set of techniques that the vendors did not fix, with Fortinet concluding that none of the described issues required a fix. The author argues those techniques are still dangerous.
The core message: a compromised VPN server is not just a doorway into the network. It can also be a place where the attacker harvests passwords and secrets, and those can unlock many other systems.

The question the post is built around: what can an attacker accomplish while using only the VPN management interface?
Introduction: why VPNs get attacked
The post opens with a familiar story. A serious bug is found in a VPN server. Attackers start using it in the wild (meaning real attacks, not just theory). Administrators rush to install the patch (the vendor's fix). Social media fills with alarm.
The author notes that the previous year was rough for VPN security, with a critical vulnerability patched or found being exploited roughly every other month. This is not new, though. Attackers have long liked VPN servers because:
- they are reachable from the internet, so anyone can try;
- they expose a lot of functionality, which means a lot of places for bugs to hide;
- they are often poorly monitored and poorly secured compared with the rest of the network.
Historically, a VPN server was abused for one goal: initial access. The attacker breaks into the internet-facing box and uses it as a beachhead (a foothold) to reach the internal network.
That works well, but the researchers asked: should control of a VPN server be seen only as a gateway? They wanted to see what else is possible once the attacker is already on the box, having got there by some other means such as a vulnerability or stolen credentials.
Living off the VPN
The usual way attackers do things after getting in is to target the operating system (OS) of the device. Once they have remote code execution (RCE, the ability to make the device run their own commands), they drop a custom implant: a small malicious program written specifically for that device. With an implant they can do anything: hook functions to leak sensitive data, tamper with logs to avoid detection, change settings to stay resident.
This approach has one big drawback: it is expensive. Appliances usually run a custom, hardened OS (stripped down and locked down), so writing and maintaining an implant for one is a lot of work. That is why these deep post-exploitation techniques were mostly the domain of top-tier nation-state actors, meaning well-funded government-linked groups.
Exploring a different approach
The researchers tried an easier route. Instead of a custom implant, abuse the features the device already has. The question again: what can an attacker do using only the VPN management interface, the web-based admin screens where an administrator configures the device?
This "living off the VPN" approach has at least two advantages:
- Access to the management interface can be easier to get than full RCE. It might come from an authentication bypass (a bug that skips the login check), weak credentials (a guessable password), or phishing (tricking a person into handing over their login).
- It is cheaper, because there is no custom payload to write and maintain.
The test subjects were Ivanti Connect Secure and FortiGate. The research uncovered 2 CVEs, and a set of no-fix techniques. The author's warning is that these can potentially turn a VPN compromise into a full network compromise.
Although the findings focus on those two products, the author believes variations are likely to be relevant for other VPN servers and edge devices (devices that sit at the boundary of a network).
Abusing remote authentication servers
Some of the most valuable things a VPN server handles are external credentials, meaning usernames and passwords for other systems.
A VPN can keep its own list of local users, but in many setups it does not. Instead it uses an external authentication server: a separate system that already knows who the users are. Rather than maintaining a second set of passwords, the admin points the VPN at an existing identity provider (a system that manages identities). The user types their normal password into the VPN, and the VPN asks the external server whether it is correct.
Two common types of external authentication server are:
- LDAP: a protocol for looking up and checking users in a directory. The most common directory in companies is Active Directory (AD), Microsoft's domain controller service. A domain controller is the server that runs the domain and holds the user accounts.
- RADIUS: a protocol commonly used to check credentials for network access, such as Wi-Fi or VPN logins.
The researchers found ways to steal these external credentials, which can give an attacker access to more resources in the network.
Intercepting LDAP credentials
LDAP, usually an Active Directory domain controller, is a very popular choice for VPN authentication, because users can log in with their normal domain password.
When you set up an LDAP authentication server, you give the VPN the credentials of an AD service account. A service account is a non-human account used by software to talk to another system. The VPN needs it to query user information. The post shows an example of this configuration in FortiGate.
When a user logs in to FortiGate or Ivanti with LDAP credentials, the VPN checks them by contacting the LDAP server. The two products do this slightly differently.
FortiGate LDAP authentication
To check the credentials, FortiGate tries to use them to log in to the remote server. This uses simple authentication, which means FortiGate sends the password to the server in cleartext, unencrypted, readable by anyone who can see the traffic.
Two sets of credentials travel during this process: the LDAP service account configured on FortiGate, and the credentials the user typed. Both go out in cleartext.
The default configuration is plain LDAP, but FortiGate also supports LDAPS and TLS, which are the encrypted versions and should prevent cleartext communication.
Ivanti LDAP authentication
Ivanti's implementation is a bit different and supports two types of LDAP authentication server: normal LDAP and Active Directory.
LDAP authentication server
With a normal LDAP server the process is much like FortiGate's. When plain LDAP is used, a simple bind is performed (a bind is the LDAP term for logging in), and both the AD service account and the user's credentials are transmitted in cleartext.
However, when you configure an LDAP authentication server on Ivanti, the default setting is TLS, and LDAPS is also supported. So Ivanti instances are less likely to use plain LDAP.
AD authentication server
The second type is an AD server. With this option, authentication uses Kerberos, a protocol that proves identity without sending passwords over the network. So no passwords are transmitted.
Capturing cleartext LDAP credentials
For both products, when plain LDAP is used, any credential sent to the VPN can potentially be stolen. That can be done by an attacker sitting between the VPN and the LDAP server, or by an attacker who controls the VPN server itself.
How do you capture credentials without installing an implant? Conveniently, FortiGate and Ivanti both include a built-in packet capture feature. Packet capture records the network traffic passing through the device into a file (a PCAP, the standard capture file format). By capturing LDAP packets, an attacker intercepts every credential that goes through the VPN.
If a secure protocol is in use, no cleartext credentials leave the server. Even so, an attacker who controls the VPN can still capture them trivially. If you control the VPN, nothing stops you from changing the configuration and downgrading it back to plain LDAP.
For normal LDAP servers, just change the configuration to plain LDAP. To downgrade Ivanti's AD server, use the AD connection details to configure a new, normal LDAP server instead of the existing one. In both cases the change should be invisible to users, and it makes the VPN send passwords in cleartext.
The bottom line: if LDAP authentication is used, whatever the configuration, an attacker who compromises the VPN can easily obtain credentials and pivot into the domain. To pivot means to move from one compromised system to another.
Registering a rogue authentication server
When the VPN authenticates a remote user, it contacts the appropriate authentication server to check the credentials. The researchers found a way to abuse this flow to capture any credential a user provides to the VPN.
The trick is to register a rogue authentication server, meaning a server the attacker controls, that the VPN will consult when checking users. To explain how, the post first describes some details of how authentication works on both products.
FortiGate user groups
FortiGate users can have different permissions and different policies applied. Instead of managing each user one by one, users can be put into user groups: sets of users that share policies and permissions.
When configuring such a group, you can include users from remote groups, groups that live on a remote authentication server. For example, you can include the members of a specific AD group.
The researchers noticed something interesting with remote groups. Suppose you configure a user group with two members: a local FortiGate user and a remote group on an LDAP server. You would expect this behaviour:
- When the local member logs in, their credentials are checked against FortiGate's local user database.
- When a member of the remote group logs in, their credentials are checked against the remote LDAP server.
But that is not what happens. Once a remote group is added to a user group, whenever any member of the user group logs in, FortiGate tries to validate their credentials against both the local user database and the remote authentication server. And if you add more than one remote server to a user group, FortiGate tries all the configured authentication servers.
In essence, FortiGate does not match a specific user to the right authentication method. It simply tries all of them, and if any one succeeds, the user is logged in.
Ivanti authentication realms
Ivanti has a similar feature called authentication realms. Unlike FortiGate's user groups, each realm is limited to a single authentication server. To manage users from different servers you need separate realms.
Despite that restriction, and conveniently for an attacker, Ivanti lets you configure an "additional authentication server". This option exists to support certain SSO configurations. SSO, single sign-on, is a setup where one login gives access to several systems.
When an additional authentication server is configured, Ivanti checks the credentials against both servers. Authentication succeeds only if both servers approve.
Creating a rogue authentication server to leak credentials
An attacker can abuse these behaviours to leak the credentials of any user who logs in to FortiGate or Ivanti, whatever type of remote authentication server is used. By adding a rogue authentication server to a user group or realm, the VPN can be made to send credentials to a server the attacker controls.
These credentials could belong to clients connecting to the VPN, or to administrators connecting to the management interface. Any authentication managed through a user group or realm can be hijacked this way.
On FortiGate, the researchers created a remote group that uses the rogue server and added it to the target user group. On Ivanti, they added the rogue server as an additional authentication server for the target realm.
Now, whenever a member of the target group or realm logs in, the VPN tries to validate their credentials against the rogue server.
To capture the credentials they used a RADIUS authentication server. RADIUS is convenient here for two reasons:
- Credentials are sent in the initial request, without first checking whether the user exists on the server.
- Credentials are sent encrypted with a key the attacker chooses, so the attacker can recover the cleartext.
The following script, based on RFC 2865 (the RADIUS specification), decrypts RADIUS passwords:
import hashlib
# Authenticator value can be obtained from the PCAP
authenticator = bytearray.fromhex("[redacted]")
enc = bytearray.fromhex("[redacted]")
# Pre-shared key configured by the attacker when setting up the rogue server
secret = bytes("verygoodpsk", "utf-8")
chunk_len = 16
enc_chunks = []
dec = ""
for i in range(0, len(enc), chunk_len):
enc_chunks.append(enc[i:i+chunk_len])
for chunk in enc_chunks:
dec_chunk = b""
chunk_key = hashlib.md5(secret + authenticator ).digest()
i = 0
for enc_byte in chunk:
dec_chunk += (enc_byte ^ chunk_key[i]).to_bytes(1,"big")
dec += chr(enc_byte ^ chunk_key[i])
i+=1
authenticator = chunk
print(dec)
Line by line:
import hashlibloads Python's built-in library of hashing functions. A hash takes data and produces a fixed-length fingerprint; here MD5 is used, which is fast but not secure for storing passwords.- The comment says the authenticator value can be obtained from the PCAP. The authenticator is a random value RADIUS puts in each packet; it is not secret, it just needs to be known to undo the encryption.
authenticator = bytearray.fromhex(...)turns a hex string (hex is a way of writing bytes as pairs of characters) into the raw bytes of that authenticator.enc = bytearray.fromhex(...)does the same for the encrypted password blob, which is the RADIUS password attribute taken from the capture.- The comment explains that
secretis the pre-shared key the attacker set when setting up the rogue server. A pre-shared key is a password both sides of a connection agree on in advance. secret = bytes("verygoodpsk", "utf-8")turns that key into bytes.chunk_len = 16sets the block size. RADIUS encrypts the password in 16-byte chunks.enc_chunks = []anddec = ""create an empty list for the chunks and an empty string for the result.- The first
forloop walks through the encrypted data 16 bytes at a time and stores each slice inenc_chunks. - The second
forloop handles one chunk at a time.chunk_key = hashlib.md5(secret + authenticator).digest()computes the MD5 fingerprint of the secret joined with the current authenticator; that fingerprint is the key used to scramble this chunk. - The inner loop goes byte by byte.
enc_byte ^ chunk_key[i]is an XOR, a simple reversible operation: applying it twice with the same key returns the original. That recovers each plaintext byte, which is appended todec. authenticator = chunksets the current encrypted chunk as the authenticator for the next chunk, because RADIUS chains them this way.print(dec)prints the recovered password.
One caveat for Ivanti: because both servers must approve the user, a rogue server that rejects credentials would lock users out. So the rogue RADIUS server must be configured to approve any credentials it receives.
Extracting configuration file secrets
What may be the most concerning finding involves VPN configuration files.
Among the many settings in a configuration file, one stands out: secrets. VPNs store many secrets there: local user passwords, SSH keys (cryptographic keys used to log in to servers), certificates (digital identity documents), and most interestingly, credentials for third-party service accounts.
An attacker can get these sensitive files in two main ways:
- After taking control of a VPN, export the device configuration through the management interface.
- Find a previously exported configuration file saved somewhere public, such as a shared folder.
To protect them, secrets are stored in the configuration file in encrypted form. The post shows an example of an encrypted secret in a FortiGate configuration file.
Now, let's decrypt some secrets.
Decrypting secrets from a FortiGate configuration file
You might think the secrets are hashed and therefore cannot be recovered. But that cannot be the case. Take integration passwords: the cleartext password is needed to connect to the third party, so it has to be stored with reversible encryption. Reversible means the original can be recovered with the right key; a hash, by contrast, is one-way.
This was shown in a blog post by Bart Dopheide that dug into the FortiGate password encryption process. FortiGate uses AES, a standard strong encryption algorithm, to encrypt all secrets in the configuration. Which key does it use? Dopheide found that a single hard-coded key is used across all FortiGate appliances, and it could not be changed. The original blog post does not share the key, but a quick Google search will find it.
Fortinet assigned CVE 2019-6693 to this issue and implemented a fix by letting users change the hard-coded key to a custom one.
Even after the fix, the problem is still very relevant. The key was not changed, so by default, FortiGate appliances still use the same key. That means if an attacker obtains a configuration file from a FortiGate appliance with the default configuration, they can decrypt all the secrets stored on the device. The author points to a public implementation of the decryption process.
But what if the admin followed best practice and used a custom key? The researchers found that if you control the VPN, you can still easily get the secrets.
The private-data-encryption setting controls the custom encryption key. Surprisingly, admins can simply disable this feature. This requires no knowledge of the currently configured key, and reverts the encryption of all secrets back to the original hard-coded key.
Reverting the encryption
To revert the encryption, use these FortiGate command-line interface commands. The command-line interface (CLI) is the text-based way of configuring the device, as opposed to clicking in a web page.
FGT # config system global
FGT (global) # set private-data-encryption disable
FGT (global) # end
Line by line:
FGT # config system globalenters the global system settings section.FGT #is the prompt, the text the device shows before your command.FGT (global) # set private-data-encryption disableturns off the custom encryption key feature. The prompt now shows(global)because you are inside that section.FGT (global) # endleaves the section and applies the change.
At this point you can download the configuration file and decrypt the secrets with the known default key, exactly as before.
Many interesting secrets can be compromised this way. FortiGate supports integrations with various applications through the "external connector" feature. These connectors serve different purposes, but most share one important aspect: they need credentials for the application.
So a FortiGate may contain credentials for critical services such as cloud providers, SAP, Kubernetes, ESXi and more. Some of those credentials need high privileges. For example, the "Poll Active Directory Server" integration requires the credentials of an account with administrative access to a domain controller, which can turn a FortiGate breach into a full domain compromise immediately.
Decrypting secrets from an Ivanti configuration file
The situation is similar with Ivanti. In fact, it may be worse.
Ivanti also stores secrets with reversible encryption. If you extract the code from the device and dig into it, you quickly find the secret value used as the encryption key, which is again a static string (a fixed value that does not change).
The author redacted the full key, but by looking at its beginning they assume it has likely not changed since at least 2015, when Juniper last owned Connect Secure.
Ivanti seems to have put more effort into protecting stored secrets, using a more complex encryption algorithm than FortiGate. Even so, the process is still reversible. That means secrets across all Ivanti instances are encrypted with one static key that cannot be changed. Attackers could use this knowledge to decrypt any Ivanti configuration file.
Letting Ivanti decrypt passwords for us
The first idea was to reverse engineer the encryption process and write a decryptor. That is certainly possible, but after a few long hours looking at decompiled code (code turned back from machine form into something readable), the researchers took a different approach as a proof of concept. They let Ivanti do the work.
The idea: use a dedicated Ivanti instance owned by the attacker, feed it the encrypted password, and get it to decrypt it.
The steps are:
- Obtain an encrypted password from an Ivanti configuration file.
- In a lab, set up an Ivanti instance and an LDAP server (for example a Windows server running Active Directory).
- On the lab Ivanti instance, configure the LDAP server as an authentication server that uses simple authentication.
- Export the lab Ivanti configuration to a file.
- Replace the existing encrypted LDAP password in the configuration file with the encrypted password you want to decrypt.
- Import the modified configuration file back into the Ivanti instance.
Now, when you trigger an authentication attempt to the LDAP server, Ivanti decrypts the password from the configuration and sends it in cleartext to the LDAP server. Capturing the packets gives you the decrypted password.
LDAP server authentication is used here as an "interface" to the decryption process, but the technique is not limited to LDAP passwords. Testing showed it works for all secrets stored in the configuration file, including (but not limited to) AD passwords, RADIUS pre-shared keys and API keys. An API key is a secret string that lets software call another service.
Cleartext MDM server passwords
Ivanti supports several popular mobile device management (MDM) servers as authentication methods. MDM is software that manages phones and tablets in a company.
Like other authentication servers, this integration needs credentials for the MDM server. If you inspect the configuration for the MDM server, you find two interesting fields: "password-encrypted" and "password-cleartext". Despite what the names suggest, both fields are stored in cleartext.
VPN post-exploitation techniques in the wild
It is likely that some of these techniques are already used in the wild. In their Cutting Edge report, which covered a series of exploitation campaigns against Ivanti appliances, Mandiant researchers shared that attackers were able to compromise the LDAP service account configured on the Ivanti device.
The Mandiant report does not detail how the attackers did this, but the author believes it is fairly likely they used one of the methods described here, either extracting the credentials from the configuration file or sniffing network traffic. Sniffing means passively recording traffic on a network.
These techniques are trivial to implement, so attackers of all sophistication levels can use them.
Recommendations when using a VPN server
Four principles reduce the risk from these techniques:
- Employ Zero Trust Network Access
- Limit service account permissions
- Use dedicated identities for VPN authentication
- Monitor configuration changes
1. Employ Zero Trust Network Access
One main problem with traditional VPNs is their "all or nothing" approach. Users are either "in", with complete access to the network, or "out", with no access at all.
Both options are problematic. Users need remote access to internal applications, but you do not want an attacker who compromises the VPN to get full network access.
Zero Trust Network Access (ZTNA) offers a solution. By defining access policies per entity (per user or per device), you let users do the approved remote operations while reducing the impact of a breach. "Zero Trust" means nothing is trusted by default, even inside the network.
Akamai Enterprise Application Access is a ZTNA solution that gives precise access to private applications based on identity and context. It uses identity-based policies and real-time data such as user location, time and device security, so users only reach the applications they need, and it removes network-level access. It works with Akamai MFA to provide strong user authentication. MFA is multi-factor authentication: proving identity with more than one thing, such as a password plus a code.
2. Limit service account permissions
As shown, recovering the cleartext passwords of service accounts stored on VPN servers is trivial. There is no real way to avoid it, because VPNs sometimes need the cleartext passwords.
To reduce the impact of a VPN compromise, use service accounts with a limited set of permissions, preferably read only. Defenders should think about how an attacker could use the credentials stored on the VPN, and make sure a VPN compromise does not lead to a compromise of other critical assets.
Some integrations need a service account with strong permissions to work. If possible, avoid them.
3. Use dedicated identities for VPN authentication
An attacker who controls the VPN can trivially compromise the credentials of users logging in. Although it is tempting to reuse existing authentication services such as AD, the recommendation is to avoid that. An attacker with control of the VPN can obtain those credentials and use them to pivot into internal assets, making the VPN a single point of failure.
Instead, use a separate, dedicated way to authenticate users to the VPN. For example, certificate-based authentication with certificates issued specifically for that purpose.
4. Monitor configuration changes
All the techniques described show up in the device configuration in one way or another. Network device configuration does not tend to change often, so these changes are a significant detection opportunity.
To spot configuration changes, periodically pull the device configuration and compare it with a "golden image", a known-good copy. Most devices also have internal logging for system and security events. Collect and analyse the available logs to identify suspicious changes.
These four principles boil down to this: don't blindly trust your VPN.
Summary
Attackers are after your VPN. That is a fact. Defenders should assume it is only a matter of time before a threat actor gains access, and act accordingly now. A compromised VPN must not lead to a fully compromised network.
Disclosure timeline
Ivanti
03.26.2024: Initial report to vendor
04.05.2024: Ivanti acknowledges the report and confirms they are working on a fix
06.03.2024: Initial notice to Ivanti that the research is planned for publication on August 7
06.27.2024: Ivanti states they are working on a fix but cannot confirm the issues will be fixed before the publication date
07.08.2024: Ivanti assigns CVE-2024-13842 and CVE-2024-13843 to the hard-coded key issue and the MDM cleartext passwords, but has not yet released a patch
07.15.2024: Additional notice to Ivanti about the planned release schedule
08.07.2024: Research is published
Fortinet
03.22.2024: Initial report to vendor
04.17.2024: Fortinet initial response, concluding that none of the described issues require a fix
04.21.2024: Initial notice to Fortinet that the research is planned for publication on August 7
04.30.2024: Fortinet informs us they intend to fix the custom encryption key bypass we described
07.15.2024: Additional notice to Fortinet about the planned release schedule
07.23.2024: Fortinet states they will likely not be able to release the patch before the publication date
08.02.2024: Fortinet informed us that after additional consideration, they decided not to fix the custom encryption key bypass as it "does not cross a security boundary"
08.07.2024: Research is published

Glossary
- VPN (Virtual Private Network): a service that lets a remote user connect securely to a private network as if they were inside it.
- VPN server / appliance: the device or virtual machine at the network edge that runs the VPN.
- Management interface: the web-based admin screens used to configure the device.
- Post-exploitation: what an attacker does after they already have access to a system.
- Living off the VPN: the author's term for post-exploitation using only the VPN's own built-in features.
- Living off the land: an attacker technique of using tools already present on a victim's computer instead of bringing their own.
- Implant: a small malicious program placed on a device to give an attacker control.
- OS (Operating System): the core software that runs a device, such as Windows or Linux.
- Hardened OS: an operating system stripped down and locked down to reduce attack surface.
- RCE (Remote Code Execution): the ability to make a remote device run commands of your choosing.
- Nation-state actor: a well-funded attacker group linked to a government.
- Authentication: the process of proving who you are, usually with a username and password.
- Authentication bypass: a bug that lets someone skip the login check.
- Phishing: tricking a person into handing over credentials or other sensitive information.
- Credentials: a username and password (or similar) used to log in.
- Identity provider: a system that manages user identities and checks logins.
- LDAP (Lightweight Directory Access Protocol): a protocol for looking up and checking users in a directory.
- Active Directory (AD): Microsoft's directory service, run by a domain controller, that holds company user accounts.
- Domain controller: the server that runs an Active Directory domain.
- RADIUS: a protocol commonly used to check credentials for network access such as VPN or Wi-Fi logins.
- Service account: a non-human account used by software to talk to another system.
- Simple authentication / simple bind: an LDAP login that sends the password in cleartext.
- Cleartext: data sent unencrypted, readable by anyone who can see the traffic.
- TLS / LDAPS: encrypted versions of a connection; LDAPS is LDAP over TLS.
- Kerberos: an authentication protocol that proves identity without sending passwords over the network.
- Packet capture / PCAP: recording network traffic into a file; PCAP is the standard capture file format.
- Downgrade: changing a secure configuration to a weaker one.
- Pivot: moving from one compromised system to another.
- User group: a set of users that share policies and permissions.
- Remote group: a group of users that lives on a remote authentication server.
- Authentication realm: Ivanti's equivalent of a user group, limited to a single authentication server.
- Additional authentication server: an Ivanti option, meant for certain SSO setups, that adds a second server which must also approve a login.
- SSO (Single Sign-On): a setup where one login gives access to several systems.
- Rogue server: a server controlled by the attacker.
- Pre-shared key: a password both sides of a connection agree on in advance.
- RFC 2865: the specification document for RADIUS.
- Hash: a one-way function that turns data into a fixed-length fingerprint.
- MD5: a fast hashing algorithm, not secure for storing passwords.
- XOR: a simple reversible operation on bytes; applying it twice with the same key returns the original.
- Hex: a way of writing bytes as pairs of characters.
- Configuration file: the file holding all of a device's settings, which can be exported and imported.
- SSH keys: cryptographic keys used to log in to servers.
- Certificate: a digital identity document used to prove who you are.
- AES: a standard strong encryption algorithm.
- Reversible encryption: encryption where the original can be recovered with the right key, unlike a hash.
- Hard-coded key: a key built into the software that is the same everywhere and cannot easily be changed.
- CVE: a public catalogue entry for a known security vulnerability.
- CLI (Command-Line Interface): the text-based way of configuring a device.
- External connector: a FortiGate feature for integrating with other applications, which needs credentials for them.
- API key: a secret string that lets software call another service.
- MDM (Mobile Device Management): software that manages phones and tablets in a company.
- Sniffing: passively recording traffic on a network.
- ZTNA (Zero Trust Network Access): an access model that grants per-application access based on identity and context instead of full network access.
- Zero Trust: a principle that nothing is trusted by default, even inside the network.
- MFA (Multi-Factor Authentication): proving identity with more than one thing, such as a password plus a code.
- Golden image: a known-good copy of a configuration used for comparison.
- Proof of concept: a demonstration that a technique works.
- Decompiled code: code turned back from machine form into something readable.