fix: require auth and tenant scoping on GetUEPDUSessionInfo#210
Open
DBGR18 wants to merge 3 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the GetUEPDUSessionInfo WebUI handler by enforcing caller authentication before minting an internal NF token, and by tenant-scoping the proxied SMF OAM response for non-admin users to prevent cross-tenant reads.
Changes:
- Require a valid WebConsole JWT (via
GetTenantId()) at the start ofGetUEPDUSessionInfo, rejecting unauthorized callers before any SMF OAM proxying occurs. - Add
sendResponseToClientFilterTenantSingleto tenant-filter single-object SMF responses for non-admin callers. - Route admin vs non-admin responses through unfiltered vs tenant-filtered forwarding.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1892
to
+1907
| var jsonData map[string]interface{} | ||
| if err = json.NewDecoder(response.Body).Decode(&jsonData); err != nil { | ||
| logger.ProcLog.Errorf("sendResponseToClientFilterTenantSingle err: %+v", err) | ||
| c.JSON(http.StatusInternalServerError, gin.H{}) | ||
| return | ||
| } | ||
|
|
||
| if supi, ok := jsonData["Supi"].(string); ok && tenantCheck(supi) { | ||
| c.JSON(response.StatusCode, jsonData) | ||
| return | ||
| } | ||
|
|
||
| c.JSON(http.StatusForbidden, gin.H{ | ||
| "cause": "Subscriber does not belong to this tenant", | ||
| }) | ||
| } |
Comment on lines
+1875
to
+1879
| filterTenantIdOnly := bson.M{"tenantId": tenantId} | ||
| amDataList, err := mongoapi.RestfulAPIGetMany(amDataColl, filterTenantIdOnly) | ||
| if err != nil { | ||
| logger.ProcLog.Errorf("sendResponseToClientFilterTenantSingle err: %+v", err) | ||
| c.JSON(http.StatusInternalServerError, gin.H{}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixing free5gc/free5gc#1074
Problem
GetUEPDUSessionInfo(GET /api/ue-pdu-session-info/:smContextRef) performed no authentication or authorization. It minted the WebConsole's own NF OAuth2 token and proxied the request to the internal SMF OAM interface, returning the response verbatim to the caller. It's a confused-deputy that lets a request without a valid token read a UE's PDU session info.It also applied no tenant filtering, unlike the sibling
GetRegisteredUEContext.Fix
GetTenantId()at the top of the handler,before the NF token is minted, so unauthorized requests are rejected with
401 and never reach the SMF OAM proxy.
sendResponseToClientFilterTenantSinglehelper. The existingsendResponseToClientFilterTenantonly filters slices and would pass theSMF's single-object response through unfiltered, leaving cross-tenant reads
possible.