Reference material — not professional advice. Test in staging, back up first, verify against your specific version. Use your own judgment for your environment.
● High · CVSS 8.8

How to Fix CVE-2026-40897: CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes

By Sai Kiran Pandrala

Other vulnerabilities in the same area that are worth patching alongside this one:

Last verified: 2026-05-25

CVE-2026-40897 is a cwe-915: improperly controlled modification of dynamically-determined object attributes in josdejong mathjs. Fix it by upgrading to the patched build from the vendor advisory.

⚡ At a glance
SeverityCVSS 8.8 - High
Actively exploited?Not currently in the CISA KEV catalog
Affectedmathjs >= 13.1.1, < 15.2.0
Fixed inSee vendor advisory
Type (CWE)CWE-915: CWE-915: Improperly Controlled Modification of Dynamically-Determined Object Attributes

What is CVE-2026-40897?

CVE-2026-40897 is a cwe-915: improperly controlled modification of dynamically-determined object attributes flaw in josdejong mathjs. It carries a CVSS base score of 8.8 (high). It is not currently listed in the CISA Known Exploited Vulnerabilities catalog.

From the source record: Math.js is an extensive math library for JavaScript and Node.js. From 13.1.1 to before 15.2.0, a vulnerability allowed executing arbitrary JavaScript via the expression parser of mathjs. You can be affected when you have an application where users can evaluate arbitrary expressions using the mathjs expression parser. This vulnerability is fixed in 15.2.0.

Why it matters in practice: The blast radius depends on how the affected service is exposed. An internet-facing instance with no compensating controls is the highest-risk configuration.

Am I affected?

You are affected if your installation of mathjs matches a version listed in the Affected row above.

Check the running version against the Affected row above using the product's admin console or --version flag.

How to fix CVE-2026-40897

Apply the vendor patch. Target the build named in the Fixed in row above (See vendor advisory). The runnable command set below covers the most common deployment patterns for mathjs.

Generic upgrade pattern

If the affected product is a Linux package, upgrade via the system package manager:


# Debian / Ubuntu
sudo apt-get update && sudo apt-get upgrade -y

# RHEL / Rocky / Alma
sudo dnf upgrade --security -y

If it ships as a Windows installer, download the patched build from the vendor advisory and:


# Vendor advisory: https://github.com/josdejong/mathjs/security/advisories/GHSA-29qv-4j9f-fjw5
Start-Process msiexec.exe -ArgumentList '/i <patched-installer>.msi /qn /norestart' -Wait
Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | \
    Where-Object DisplayName -match '<product-name>' | Select-Object DisplayName, DisplayVersion

After applying the patch

  1. Restart the service or device so the patched binary loads.
  2. Confirm the running version matches the Fixed in row using the verification command below.
  3. Rotate credentials and API keys that the affected service could access if the asset was exposed during the disclosure window.

If you can't patch immediately

Until the patch lands, narrow the attack surface with these runnable controls.

Restrict network exposure

Block public access to the affected service at the perimeter. Allow only trusted source IPs.


# Linux iptables: only allow trusted admin subnet
sudo iptables -A INPUT -p tcp --dport 443 -s 10.10.10.0/24 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j DROP
sudo iptables-save | sudo tee /etc/iptables/rules.v4

# Windows firewall: only allow trusted admin subnet on management port
New-NetFirewallRule -DisplayName "Restrict-Mgmt-Allow" -Direction Inbound -Action Allow `
  -RemoteAddress 10.10.10.0/24 -Protocol TCP -LocalPort 443
New-NetFirewallRule -DisplayName "Restrict-Mgmt-Deny"  -Direction Inbound -Action Block `
  -Protocol TCP -LocalPort 443

Mitigations are temporary. Apply the vendor patch as soon as a maintenance window opens.

How to verify the fix worked

Confirm the patched build is the one actually running.

Check the running version against the Affected row above using the product's admin console or --version flag.

Expected: a version at or above the patched build named in the vendor advisory.

Also worth doing: pull recent log windows for indicators of compromise listed in the vendor advisory, and re-run an authenticated vulnerability scan with up-to-date signatures.

Frequently asked questions

Is CVE-2026-40897 being exploited in the wild?

As of 2026-05-25, CVE-2026-40897 is not listed in the CISA Known Exploited Vulnerabilities catalog. Watch the catalog and patch on a normal cadence; KEV status can change as exploitation evidence emerges.

What is the CVSS score for CVE-2026-40897?

The CVSS base score is 8.8 (High).

What version fixes this?

The vendor advisory names the patched build. See the References section.

Will a WAF or IDS rule alone close this?

No. Network filters cut down opportunistic scans but they do not remove the flaw. The vendor patch is the only durable fix.

References


*Assembled from the official vendor advisory, the NVD record, and the CISA KEV listing on 2026-05-25. Always confirm against the vendor advisory before applying changes in production.*