Language: TypeScript
Label: vulnerable
CWE: CWE-1321 \u2014 Improperly Controlled Modification of Object Prototype Attributes ('Prototype Pollution')
The product receives input from an upstream component that specifies attributes that are to be initialized or updated in an object, but it does not properly control modifications of attributes of the object prototype.

Code:
function resolveMetadataRecord(owner: object, context: Context, useMetaFromContext: boolean): MetadataRecord
{
    // If registry is not to be used, it means that context.metadata is available 
    if (useMetaFromContext) {
        return context.metadata as MetadataRecord;
    }

    // Obtain record from registry, or create new empty object.
    let metadata: MetadataRecord = registry.get(owner) ?? {};

    // In case that the owner has Symbol.metadata defined (e.g. from base class),
    // then merge it current metadata. This ensures that inheritance works as
    // intended, whilst a base class still keeping its original metadata.
    if (Reflect.has(owner, METADATA)) {
        // @ts-expect-error: Owner has Symbol.metadata!
        metadata = Object.assign(metadata, owner[METADATA]);
    }

    return metadata;
}