Skip to content

Comments

fix: validate rechargingInfo format to prevent panic#61

Merged
Alonza0314 merged 2 commits intofree5gc:mainfrom
solar224:fix/issue-760-rechargeput-panic
Jan 14, 2026
Merged

fix: validate rechargingInfo format to prevent panic#61
Alonza0314 merged 2 commits intofree5gc:mainfrom
solar224:fix/issue-760-rechargeput-panic

Conversation

@solar224
Copy link
Contributor

@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

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
- Change route from /recharging/:rechargingInfo to /recharging/:ueId
- Use query parameter ?ratingGroup=N instead of underscore delimiter
- This follows REST best practices and avoids parsing issues
- Fixes potential issues when ueId contains underscores

Breaking change: API clients must update to new format
Old: PUT /recharging/{ueId}_{ratingGroup}
New: PUT /recharging/{ueId}?ratingGroup={ratingGroup}
@solar224
Copy link
Contributor Author

@roundspring2003 PTAL
Thanks.

@roundspring2003
Copy link
Contributor

@Alonza0314 LGTM

@roundspring2003
Copy link
Contributor

@Alonza0314
testAll pass
ci-test & basic-charging pass
attatchment: webconsole#175

@Alonza0314 Alonza0314 merged commit 55af766 into free5gc:main Jan 14, 2026
3 checks passed
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

3 participants