Advisory

GHSA-455w-c45v-86rg

Also known as: CVE-2022-39288

Summary

fastify vulnerable to denial of service via malicious Content-Type

Details

Impact
An attacker can send an invalid Content-Type header that can cause the application to crash, leading to a possible Denial of Service attack. Only the v4.x line is affected.

(This was updated: upon a close inspection, v3.x is not affected after all).

Patches
Yes, update to > v4.8.0.

Workarounds
You can reject the malicious content types before the body parser enters in action.

  const badNames = Object.getOwnPropertyNames({}.__proto__)
  fastify.addHook('onRequest', async (req, reply) => {
    for (const badName of badNames) {
      if (req.headers['content-type'].indexOf(badName) > -1) {
        reply.code(415)
        throw new Error('Content type not supported')
      }
    }
  })

References

See the HackerOne report #1715536

For more information
Fastify security policy

Severity

High Basis: The source's own band: HIGH

Dates

Published
2022-10-11 13:45 UTC
Modified
2023-11-08 04:10 UTC

Affected packages and fixes

fastify

npm · All systems

Affected

  • introduced 4.0.0, fixed 4.8.1 (semver)

Fixed versions

4.8.1

Fix

Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.

Check your own computer: guard packages check

View this record on OSV.dev

Source

Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0

Sources & licences