Skip to content

Conversation

@solar224
Copy link

@solar224 solar224 commented Jan 7, 2026

@roundspring2003 PTAL

  • Add length check before accessing split result index
  • Return HTTP 400 Bad Request with ProblemDetails for invalid format
  • Improve strconv.Atoi error handling to return 400 instead of continuing
  • Add proper error logging for security monitoring

This fixes a Denial of Service vulnerability where malicious input without underscore delimiter would cause index out of range panic.

Fixes: free5gc/free5gc#760

Detail: "ratingGroup must be a valid integer",
}
logger.RechargingLog.Errorf("UE[%s] invalid ratingGroup: %s", ueId, rgStr)
c.JSON(http.StatusBadRequest, problemDetail)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add c.set()

rechargingInfo := c.Param("rechargingInfo")
ueIdRatingGroup := strings.Split(rechargingInfo, "_")

if len(ueIdRatingGroup) < 2 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it can't block all the attack.

- Add length check before accessing split result index
- Return HTTP 400 Bad Request with ProblemDetails for invalid format
- Improve strconv.Atoi error handling to return 400 instead of continuing
- Add proper error logging for security monitoring

This fixes a Denial of Service vulnerability where malicious input
without underscore delimiter would cause index out of range panic.

Fixes: free5gc/free5gc#760
Signed-off-by: solar224 <cyc.cs14@nycu.edu.tw>
@solar224 solar224 force-pushed the fix/issue-760-rechargeput-panic branch from 47f86be to 2c0938e Compare January 7, 2026 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bugs] CHF RechargePut panics on missing underscore in rechargingInfo

2 participants