Skip to content

@fastify/forwarded vulnerable to improper input validation via unstripped tab characters in X-Forwarded-For

Moderate
mcollina published GHSA-2849-m2w7-xm8f Jul 28, 2026

Package

npm @fastify/forwarded (npm)

Affected versions

< 3.0.2

Patched versions

3.0.2

Description

Impact

@fastify/forwarded resolves client addresses from the X-Forwarded-For header. When the header contains two or more comma-separated entries, the parser trims only space characters and does not strip horizontal tabs (\t), even though RFC 7230 defines optional whitespace as both space and tab. As a result, a tab-padded entry keeps the literal tab in the resolved address string.

For example, X-Forwarded-For: 9.9.9.9,\t1.2.3.4 resolves to "\t1.2.3.4" instead of "1.2.3.4".

This affects applications that make exact-string-match security decisions on the resolved client IP (an allowlist, a blocklist, a per-IP rate-limit key, or audit-log correlation), typically via @fastify/proxy-addr and Fastify's request.ip. By adding a tab before their own address, an attacker makes the resolved string no longer match the expected value, silently evading the check. The flaw does not cross the trust boundary, since a tab-corrupted string is not a valid IP and cannot be mistaken for a trusted proxy.

Patches

This vulnerability has been patched in @fastify/forwarded 3.0.2. All users should upgrade to this version or later.

Workarounds

If upgrading is not immediately possible, normalize the resolved address before any exact-match comparison (for example ip.replace(/[\t ]/g, '')), or reject requests whose X-Forwarded-For header contains a tab with an onRequest hook:

fastify.addHook('onRequest', async (request, reply) => {
  const xff = request.headers['x-forwarded-for']
  if (xff && xff.includes('\t')) {
    reply.code(400).send({ error: 'Invalid X-Forwarded-For header' })
  }
})

References

Severity

Moderate

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
None
Integrity
Low
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N

CVE ID

CVE-2026-18174

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

Incomplete List of Disallowed Inputs

The product implements a protection mechanism that relies on a list of inputs (or properties of inputs) that are not allowed by policy or otherwise require other action to neutralize before additional processing takes place, but the list is incomplete. Learn more on MITRE.

Credits