diff --git a/src/index.ts b/src/index.ts index 625ca80..737d100 100644 --- a/src/index.ts +++ b/src/index.ts @@ -19,6 +19,11 @@ export const EOL_DATES: Record = { "24": "2028-04-30", }; +/** + * Maximum length for a version string to prevent DoS. + */ +const MAX_VERSION_LENGTH = 256; + /** * Check if a major version is EOL. */ @@ -52,6 +57,11 @@ export const getVersion = (): NodeVersion => { * Compare the current node version with a target version string. */ const compareTo = (target: string): number => { + // DoS Prevention: Limit version string length + if (target.length > MAX_VERSION_LENGTH) { + return NaN; + } + if (target !== target.trim() || target.length === 0) { return NaN; }