Safeguard
Vulnerability Analysis•

CVE-2026-40685: Heap Write in Exim JSON Lookups Before 4.99.2

CVE-2026-40685 is a heap out of bounds write in Exim JSON operators before 4.99.2. Update to 4.99.2 and check whether your config parses JSON from headers.

Safeguard Security Team
2 min read

CVE-2026-40685 is a heap out of bounds write in Exim, scored CVSS 6.5. When JSON lookup is enabled, malformed JSON in an untrusted header can trigger it. Exim 4.99.2 fixes it. Update, and check whether your configuration uses JSON operators on outside input.

What's affected

  • Affected: Exim before 4.99.2, when JSON lookup is enabled
  • Fixed: 4.99.2

The Exim project's assessment lists the condition as a configuration that uses json operators on externally provided input, and the impact as remote triggered heap corruption. The NVD text attributes the bug to an incorrect implementation of backslash skipping.

How to check if you're exposed

Check your Exim version:

exim -bV

Then check whether your configuration uses JSON operators, which appear as the extract, json style expansion operators on header values. Search the configuration:

exim -bP configure_file
grep -rn "json" /etc/exim4 /etc/exim 2>/dev/null

If nothing in the configuration applies JSON operators to header content, the stated condition is not met, though updating is still right.

What to do now

  1. Update Exim to 4.99.2 or your distribution backport.
  2. Check your configuration for JSON operators applied to header data.
  3. Check your distribution security tracker, since many ship patched packages without changing the upstream number.
  4. Restart Exim after upgrade and confirm the version.

Why it matters

The record lists CWE-787, out of bounds write, and CWE-684, incorrect provision of specified functionality. The parser mishandles an escape character while skipping through a string, so the length it computes does not match the data. That mismatch becomes a write past the end of a buffer.

Mail servers receive input from anyone, which makes parsing bugs matter even when the score is medium. The feature condition narrows exposure a lot. The record does not flag exploitation in the wild.

Try it yourself

Click through it at your own pace, or open it full screen.

Quick check

Am I affected if I never enabled JSON lookups?

The record says the issue applies when JSON lookup is enabled. Check your configuration to confirm.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.