facebook/react · error · Error
Cannot taint a ${kind} because the value is too general and
Error message
Cannot taint a ${kind} because the value is too general and not unique enough to block globally. What it means
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.
Source
Thrown at packages/react/src/ReactTaint.js:97
} else if (
value instanceof TypedArrayConstructor ||
value instanceof DataView
) {
// For now, we just convert binary data to a string so that we can just use the native
// hashing in the Map implementation. It doesn't really matter what form the string
// take as long as it's the same when we look it up.
// We're not too worried about collisions since this should be a high entropy value.
TaintRegistryByteLengths.add(value.byteLength);
entryValue = binaryToComparableString(value);
} else {
// $FlowFixMe[invalid-compare]
const kind = value === null ? 'null' : typeof value;
if (kind === 'object' || kind === 'function') {
throw new Error(
'taintUniqueValue cannot taint objects or functions. Try taintObjectReference instead.',
);
}
throw new Error(
'Cannot taint a ' +
kind +
' because the value is too general and not unique enough to block globally.',
);
}
const existingEntry = TaintRegistryValues.get(entryValue);
if (existingEntry === undefined) {
TaintRegistryValues.set(entryValue, {
message,
count: 1,
});
} else {
existingEntry.count++;
}
if (finalizationRegistry !== null) {
finalizationRegistry.register(lifetime, entryValue);
}
}View on GitHub (pinned to eafeac097b)
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
Example fix
// before taintUniqueValue(msg, lifetime, user.pinCode); // number -> throws // after taintObjectReference(msg, user); // or taint the unguessable token only: taintUniqueValue(msg, lifetime, user.sessionToken); // string
Defensive patterns
Strategy: validation
Validate before calling
// Only taint value types the registry supports
const SUPPORTED = ['string', 'bigint'];
function taintChecked(message: string, lifetime: object, value: unknown) {
if (value instanceof DataView || ArrayBuffer.isView(value)) {
taintUniqueValue(message, lifetime, value);
} else if (typeof value === 'string' || typeof value === 'bigint') {
taintUniqueValue(message, lifetime, value);
} else if (value != null && typeof value === 'object') {
taintObjectReference(message, value);
} else {
console.warn('Skipping untaintable low-entropy value:', typeof value);
}
} Type guard
const isUniqueTaintable = (v: unknown): v is string | bigint | $ArrayBufferView => typeof v === 'string' || typeof v === 'bigint' || v instanceof DataView || ArrayBuffer.isView(v);
Prevention
- Only taint high-entropy secrets (tokens, hashes, keys); never numbers or booleans
- For low-entropy fields, taint the enclosing object with taintObjectReference instead
When it happens
Trigger: Calling taintUniqueValue(message, lifetime, true), taintUniqueValue(message, lifetime, 42), or passing a symbol/undefined as the value.
Common situations: 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.
Related errors
- To taint a value, a lifetime must be defined by passing an o
- taintUniqueValue cannot taint objects or functions. Try tain
- Only objects or functions can be passed to taintObjectRefere
- Only objects or functions can be passed to taintObjectRefere
- Invalid tag: ${tag}
AI-assisted analysis of facebook/react@eafeac097b (2026-08-21).
Data as JSON: /api/errors/d236f6cda16810bc.
Report an issue: GitHub.