Summary
Free5GC NRF 1.4.0 contains an authorization flaw where the AccessTokenScopeCheck() function skips scope validation when a specially crafted targetNF value is supplied.
Under these conditions, an attacker can obtain access tokens with arbitrary scopes, potentially impersonating other 5G network functions or gaining unauthorized access to protected services.
Affected context
This vulnerability affects deployments of free5GC where the NRF (Network Repository Function) acts as an authorization server issuing access tokens to other network functions.
It specifically manifests in the access-token generation path in internal/sbi/processor/access_token.go when the AccessTokenScopeCheck() logic is invoked.
If upstream components or external callers can influence the targetNF parameter without strict validation or isolation, the NRF may issue tokens whose scopes are not properly constrained to the caller's actual privileges.
Exploit preconditions
- Attack surface: The NRF's access-token issuance API (typically over SBI/HTTP2 in a 5G core deployment).
- Required access: Ability to send or influence access token requests to the NRF, including control over the
targetNFvalue in those requests. - Trigger point: Invocation of
AccessTokenScopeCheck()during token generation with a craftedtargetNFthat causes the function to bypass normal scope checks. - Why exploitation is possible: The authorization logic implicitly trusts certain structures or values of
targetNFand fails open, skipping scope validation instead of failing closed when encountering unexpected or malformed input.
Why this happens
The core issue lies in improper authorization logic (CWE-863), where the enforcement of access scopes does not correctly match the caller's identity and intended permissions.
Within the AccessTokenScopeCheck() function, certain control-flow paths tied to the targetNF parameter lead to a bypass of scope validation.
Instead of strictly verifying that requested scopes are allowed for the requesting network function and the given target, the code allows token issuance without validating or constraining scopes under specific crafted conditions.
Conceptually, this represents a "missing or inconsistent check" in the authorization layer, where trust is placed in an input field (targetNF) that should never be relied upon without independent validation.
Potential impact
- Attackers may obtain access tokens containing arbitrary scopes beyond their legitimate permissions.
- Malicious or compromised network functions could impersonate other NFs by requesting tokens scoped to those roles.
- Unauthorized access to protected 5G core services and APIs exposed via the NRF's service discovery and authorization flows.
- Escalation of privileges across the control plane, potentially affecting session management, policy control, or subscriber data access.
- Lateral movement between network functions that rely on scoped tokens from the NRF for trust decisions.
General mitigation guidance
Mitigations typically focus on tightening authorization boundaries and making scope validation fail-safe:
- Ensure that scope checks are always enforced regardless of
targetNFcontent, and that exceptional or unexpected values result in denial rather than bypass. - Derive authorized scopes from verified NF identity and role (e.g., from certificates or registration state) rather than from client-supplied parameters.
- Introduce centralized, declarative authorization policies that map NF identities to allowed scopes, reducing ad-hoc logic in token-generation code paths.
- Apply strict validation and normalization to fields like
targetNF, rejecting malformed or unregistered values early in the request lifecycle. - Design the token issuance path to fail closed: in any ambiguous or error condition during scope calculation, do not issue a token.
- Use least-privilege principles when defining scopes so that even if tokens are mis-issued, their impact is constrained by conservative defaults.
How teams detect issues like this
Detection efforts can leverage a mix of code-level and behavioral signals:
- Static analysis rules targeting authorization functions to ensure all code paths perform scope checks and do not silently bypass them based on input-controlled branches.
- Code review practices that flag any conditional logic around
targetNFor similar routing fields where checks may be skipped or weakened. - Policy-as-code enforcement (e.g., OPA or custom policy layers) to verify that all token issuance operations consult a centralized authorization policy.
- Logging and monitoring of token issuance events, including requested vs. granted scopes, to detect unusual patterns such as low-privilege clients consistently receiving high-privilege scopes.
- Periodic security testing and fuzzing of the access-token API, focusing on manipulating
targetNFand related parameters to identify bypass conditions.

