{"record":{"id":"a7f87c87b712b846","repo":"denoland/deno","slug":"err-out-of-range-a7f87c","errorCode":"ERR_OUT_OF_RANGE","errorMessage":"The value of \"info\" is out of range. It must be must not contain more than 1024 bytes. Received ${received}","messagePattern":"The value of \"info\" is out of range\\. It must be must not contain more than 1024 bytes\\. Received (.+?)","errorType":"exception","errorClass":"ERR_OUT_OF_RANGE","httpStatus":null,"severity":"error","filePath":"ext/node/polyfills/internal/crypto/hkdf.ts","lineNumber":86,"sourceCode":"  }\n  // For strings / other BinaryLike, keep existing semantics (UTF-8 etc.)\n  return Buffer.from(toBuf(x as unknown as string));\n}\n\nconst validateParameters = hideStackFrames(\n  (hash, key, salt, info, length) => {\n    validateString(hash, \"digest\");\n    key = prepareKey(key);\n    validateByteSource(salt, \"salt\");\n    validateByteSource(info, \"info\");\n\n    salt = toRawBytes(toBuf(salt));\n    info = toRawBytes(toBuf(info));\n\n    validateInteger(length, \"length\", 0, kMaxLength);\n\n    if (TypedArrayPrototypeGetByteLength(info) > 1024) {\n      throw new ERR_OUT_OF_RANGE(\n        \"info\",\n        \"must not contain more than 1024 bytes\",\n        TypedArrayPrototypeGetByteLength(info),\n      );\n    }\n\n    validateAlgorithm(hash);\n\n    const size = op_node_get_hash_size(hash);\n    if (typeof size === \"number\" && size * 255 < length) {\n      throw new ERR_CRYPTO_INVALID_KEYLEN();\n    }\n\n    return {\n      hash,\n      key,\n      salt,\n      info,","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/ext/node/polyfills/internal/crypto/hkdf.ts#L68-L104","documentation":"crypto.hkdf/hkdfSync validate the 'info' (context) parameter before derivation and reject it when it exceeds 1024 bytes (ext/node/polyfills/internal/crypto/hkdf.ts:85-91). This mirrors Node's HKDF guard, which exists because the OpenSSL-backed HKDF implementation feeds info into the HMAC in fixed-size chunks and Node fixes that chunk at 1024. salt is unbounded; only info carries this limit.","triggerScenarios":"crypto.hkdfSync('sha256', ikm, salt, Buffer.alloc(1025), 32); passing a large context/label blob (e.g. a serialized object or certificate) as info; the same call via the async crypto.hkdf(...) with an oversized info buffer.","commonSituations":"Stuffing application metadata, nonces, or JWT-like claims into info; deriving keys from templates that concatenate domain-separation strings until they exceed 1 KiB; porting HKDF code from Go (golang.org/x/crypto/hkdf has no info limit) or from WebCrypto deriveBits (also no such limit).","solutions":["Trim or shrink info to 1024 bytes or fewer - domain separation usually needs only a few bytes.","Hash long context data first and pass its digest as info (e.g. info = createHash('sha256').update(bigContext).digest()).","Move the overflow bytes into salt, which has no size limit, if they do not need to be authenticated as info.","If you truly need unbounded context, pre-hash the context and bind it via the key material instead."],"exampleFix":"// before\nconst info = Buffer.alloc(2048, 1);\ncrypto.hkdfSync('sha256', ikm, salt, info, 32); // ERR_OUT_OF_RANGE: info > 1024 bytes\n\n// after\nconst info = Buffer.alloc(1024, 1);             // <= 1024 bytes\ncrypto.hkdfSync('sha256', ikm, salt, info, 32);\n// or compress long context:\nconst info2 = crypto.createHash('sha256').update(longContext).digest();","handlingStrategy":"validation","validationCode":"function assertHkdfInfo(info) {\n  const bytes = Buffer.byteLength(\n    typeof info === 'string' ? info : Buffer.from(info.buffer ?? info),\n  );\n  if (bytes > 1024) {\n    throw new RangeError(`hkdf info must be <= 1024 bytes, got ${bytes}`);\n  }\n}\nassertHkdfInfo(info);\ncrypto.hkdfSync('sha256', ikm, salt, info, 32);","typeGuard":null,"tryCatchPattern":"try {\n  okm = crypto.hkdfSync('sha256', ikm, salt, info, 32);\n} catch (e) {\n  if (e.code === 'ERR_OUT_OF_RANGE' && /info/.test(e.message)) {\n    info = crypto.createHash('sha256').update(info).digest(); // compress context\n    okm = crypto.hkdfSync('sha256', ikm, salt, info, 32);\n  } else throw e;\n}","preventionTips":["Keep info to short domain-separation labels (usually < 100 bytes).","Pre-hash long context data and pass the digest as info.","Bound the info size at your API boundary, not deep in derivation code."],"tags":["crypto","hkdf","key-derivation","argument-validation","node-compat"],"backgroundTag":"argument-out-of-range","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-21T10:36:37.832Z"}