Language: TypeScript
Label: vulnerable
CWE: CWE-287 \u2014 Improper Authentication
When an actor claims to have a given identity, the product does not prove or insufficiently proves that the claim is correct.

Code:
export async function sendWorkloadMetadata(
  payload: IWorkloadMetadataPayload,
): Promise<void> {
  try {
    logger.info(
      { workloadLocator: payload.workloadLocator },
      'attempting to send workload metadata upstream',
    );

    const request: KubernetesUpstreamRequest = {
      method: 'post',
      url: `${upstreamUrl}/api/v1/workload`,
      payload,
    };

    const { response, attempt } = await reqQueue.push(request);
    if (!isSuccessStatusCode(response.statusCode)) {
      throw new Error(`${response.statusCode} ${response.statusMessage}`);
    } else {
      logger.info(
        { workloadLocator: payload.workloadLocator, attempt },
        'workload metadata sent upstream successfully',
      );
    }
  } catch (error) {
    logger.error(
      { error, workloadLocator: payload.workloadLocator },
      'could not send workload metadata upstream',
    );
  }
}