wso2 / wso2/api-platform

[API Policies] Azure Content Safety Content Moderation Policy Issue

Open
#690 0 comments 0 reactions 1 assignee View on GitHub

@Thenujan-Nagaratnam is already working on this.

Since Jan 15, 2026.

Dominant language
Go
Stars
71
Forks
111
Avg merge
1d 14h
Merged PRs (30d)
110

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.