{"record":{"id":"d236f6cda16810bc","repo":"facebook/react","slug":"cannot-taint-a-kind-because-the-value-is-too-ge","errorCode":null,"errorMessage":"Cannot taint a ${kind} because the value is too general and not unique enough to block globally.","messagePattern":"Cannot taint a (.+?) because the value is too general and not unique enough to block globally\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/react/src/ReactTaint.js","lineNumber":97,"sourceCode":"  } else if (\n    value instanceof TypedArrayConstructor ||\n    value instanceof DataView\n  ) {\n    // For now, we just convert binary data to a string so that we can just use the native\n    // hashing in the Map implementation. It doesn't really matter what form the string\n    // take as long as it's the same when we look it up.\n    // We're not too worried about collisions since this should be a high entropy value.\n    TaintRegistryByteLengths.add(value.byteLength);\n    entryValue = binaryToComparableString(value);\n  } else {\n    // $FlowFixMe[invalid-compare]\n    const kind = value === null ? 'null' : typeof value;\n    if (kind === 'object' || kind === 'function') {\n      throw new Error(\n        'taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.',\n      );\n    }\n    throw new Error(\n      'Cannot taint a ' +\n        kind +\n        ' because the value is too general and not unique enough to block globally.',\n    );\n  }\n  const existingEntry = TaintRegistryValues.get(entryValue);\n  if (existingEntry === undefined) {\n    TaintRegistryValues.set(entryValue, {\n      message,\n      count: 1,\n    });\n  } else {\n    existingEntry.count++;\n  }\n  if (finalizationRegistry !== null) {\n    finalizationRegistry.register(lifetime, entryValue);\n  }\n}","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/facebook/react/blob/eafeac097ba51e1eab809c07102126bd5f8e5425/packages/react/src/ReactTaint.js#L79-L115","documentation":"Beyond objects/functions (redirected to taintObjectReference) and strings/bigints/binary views (supported), taintUniqueValue refuses remaining types: booleans, numbers, symbols, undefined and null (reported as 'null'). These values are too general — a taint on e.g. the number 1 or true would block a huge share of legitimate traffic globally, so React refuses to register them.","triggerScenarios":"Calling taintUniqueValue(message, lifetime, true), taintUniqueValue(message, lifetime, 42), or passing a symbol/undefined as the value.","commonSituations":"Attempting to taint a numeric ID or a boolean flag from a database row; defensive-security code that loops over every property of a secret object and taints each value indiscriminately.","solutions":["Taint a higher-entropy representation instead: convert the number to a sufficiently unique string (e.g. a long random token, not the integer ID)","Taint the container object with taintObjectReference(message, holder)","Skip tainting low-entropy fields; only unique values (tokens, hashes) belong in taintUniqueValue"],"exampleFix":"// before\ntaintUniqueValue(msg, lifetime, user.pinCode); // number -> throws\n\n// after\ntaintObjectReference(msg, user);\n// or taint the unguessable token only:\ntaintUniqueValue(msg, lifetime, user.sessionToken); // string","handlingStrategy":"validation","validationCode":"// Only taint value types the registry supports\nconst SUPPORTED = ['string', 'bigint'];\nfunction taintChecked(message: string, lifetime: object, value: unknown) {\n  if (value instanceof DataView || ArrayBuffer.isView(value)) {\n    taintUniqueValue(message, lifetime, value);\n  } else if (typeof value === 'string' || typeof value === 'bigint') {\n    taintUniqueValue(message, lifetime, value);\n  } else if (value != null && typeof value === 'object') {\n    taintObjectReference(message, value);\n  } else {\n    console.warn('Skipping untaintable low-entropy value:', typeof value);\n  }\n}","typeGuard":"const isUniqueTaintable = (v: unknown): v is string | bigint | $ArrayBufferView =>\n  typeof v === 'string' || typeof v === 'bigint' || v instanceof DataView || ArrayBuffer.isView(v);","tryCatchPattern":null,"preventionTips":["Only taint high-entropy secrets (tokens, hashes, keys); never numbers or booleans","For low-entropy fields, taint the enclosing object with taintObjectReference instead"],"tags":["security","taint-apis","taintuniquevalue","invalid-type"],"backgroundTag":"taint-api-misuse","analyzedSha":"eafeac097ba51e1eab809c07102126bd5f8e5425","analyzedAt":"2026-08-21T22:01:08.818Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}