Packages / elysia / Security

HighVulnerabilityGHSA-f45g-68q3-5w8xCVE-2026-30837Published 10 Mar 2026

Elysia has a string URL format ReDoS

Your version

Affected releases · elysia

  • 1.x1.0.0 – 1.4.25Fixed in 1.4.26
  • 0.8.x and older0.1.0 – 0.8.17No fix, no longer updated

On 1.x, the newest line:

npm install elysia@1.4.26
Every release on a timeline
1.x
  1. Affected

    1.0.0 – 1.4.25

    129 releases

  2. Fixed

    1.4.26 – 1.4.30

    5 releases, latest

0.x
  1. Affected

    0.1.0 – 0.8.17

    132 releases

266 stable releases of elysia, oldest to newest, one row per major.

What happens

Impact

t.String({ format: 'url' }) is vulnerable to redos

Repeating a partial url format (protocol and hostname) multiple times cause regex to slow down significantly

'http://a'.repeat(n)

Here's a table demonstrating how long it takes to process repeated partial url format

n repeatelapsed_ms
102433.993
2048134.357
4096537.608
81922155.842
163848618.457
3276834604.139

Patches

Patched by 1.4.26, please kindly update elysia to >= 1.4.26

Here's how long it takes after the patch

n repeatelapsed_ms
10240.194
20480.274
40960.455
81920.831
163841.632
327683.052

Workarounds

  1. It's recommended to always limit URL format to a reasonable length

t.String({
	format: 'url',
	maxLength: 288
})
  1. If a long URL format is necessary, to patch this without updating to 1.4.26, add the following code to any part of your codebase

import { FormatRegistry } from '@sinclair/typebox'

FormatRegistry.Delete('url')
FormatRegistry.Set('url', (value) =>
	/^(?:https?|ftp):\/\/(?:[^\s:@]+(?::[^\s@]*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)(?:\.(?:[a-z0-9\u{00a1}-\u{ffff}]+-)*[a-z0-9\u{00a1}-\u{ffff}]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu.test(
		value
	)
)