Skip to content

[API Policies] Azure Content Safety Content Moderation Policy Issue #690

@DakshithaS

Description

@DakshithaS

Overview

Nil pointer dereference vulnerability in retry logic can cause application panic when Azure API is unavailable.


Issue Details

Potential Nil Pointer Dereference After Retry Exhaustion

File: azurecontentsafetycontentmoderation.go (lines 411-454)

Description:
If all 5 retries fail with 5xx errors, the retry loop exits without setting lastErr, and resp remains nil (closed on line 434). The subsequent defer resp.Body.Close() on line 454 will panic when trying to access resp.Body on a nil pointer.

Failure Scenario:

  1. Azure API returns 5xx errors for all retry attempts
  2. Loop exits with resp = nil
  3. defer resp.Body.Close() attempts to access nil pointer
  4. Application panics

Proposed Fix:
Check if resp is not nil before accessing resp.Body.Close(). Alternatively, restructure the retry logic to ensure resp is properly handled.

Impact:
Application panic when Azure API is unavailable and all retries are exhausted.

Reference

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions