Commit Graph

86 Commits

Author SHA1 Message Date
Sukchan Lee 3cfa8ba301 [AMF/MME] NAS message in an invaild state (#3131)
In InitialUEMessage, send a NAS message with a message type
other than Registration Request, Deregistration Request, or Service Request,
the following messages from UE will not be accepted.

We found this issue in not only the initial state but multiple states.
We believe if an attacker has the ability to inject a NAS message to the core,
it can perform a DoS attack on the victim UE.

So, I've fixed that The MME/AMF deletes MME_UE_S1AP_ID/AMF_UE_NGAP_ID,
and will not accept any following messages from the UE.
2024-04-13 13:25:09 +09:00
Sukchan Lee cd76dc641d [SEC] Crash and Protocol Violations
The AMF will crash on the following locations when it receives a sequence
of NAS messages from a UE.

- ogs_nas_encrypt: Assertion `pkbuf->len' failed. (../lib/nas/common/security.c:86)
- gmm_state_authentication: Assertion `r != OGS_ERROR' failed. (../src/amf/gmm-sm.c:1561)

Besides the crashes found above, an incorrect protocol transition
is identified in Open5GS. Without any Registration/Attach Request message,
when the Identity Response message sent, the Core Network responds
with an Authentication Request message. According to the standard,
only the Registration/Attach Request message can start a state transition
from the 5GMM/EMM-DEREGISTERED state to the 5GMM/EMM-COMMON-PROCEDURE-INITIATED.

So I've modified the relevant code to address these issues.
2024-04-09 16:23:49 +09:00
Sukchan Lee 09410eba08 Revert "udpate it"
This reverts commit 6814de5c57.
2024-04-09 11:20:16 +09:00
Sukchan Lee 6814de5c57 udpate it 2024-04-09 11:18:57 +09:00
Sukchan Lee 322719f3e7 [SEC] Vulnerabilities have been resolved (#2945)
Reachable assertion in amf_ue_set_suci

Location: src/amf/context.c:1968

```
void amf_ue_set_suci(amf_ue_t *amf_ue,
        ogs_nas_5gs_mobile_identity_t *mobile_identity)
{
    amf_ue_t *old_amf_ue = NULL;
    amf_sess_t *old_sess = NULL;
    char *suci = NULL;

    ogs_assert(amf_ue);
    ogs_assert(mobile_identity);

    suci = ogs_nas_5gs_suci_from_mobile_identity(mobile_identity);
    ogs_assert(suci);
```

Exploitable by: Base Station
Severity: denial of service
2024-03-06 07:20:50 +09:00
Sukchan Lee 199f4c7add [AMF] Fixed crash in no context setup (#2999)
Remove ogs_assert((__sESS)->gsm_message.n1buf) from AMF_SESS_STORE_5GSM_MESSAGE
because N1 buffer can become NULL during PDU session release.
2024-03-04 21:03:07 +09:00
Sukchan Lee 2ceca49161 [MME/AMF] Fixed crash following Handover Request (#3014)
1. HandoverRequired
2. HandoverRequest
3. HandoverFailure
4. UEContextReleaseCommand
5. HandoverPreparationFailure

If UEContextReleaseComplete is not received,
the Source-UE will have the Target-UE.

6. HandoverRequired

There may be cases where the Source UE has a Target UE
from a previous HandoverRequired process. In this case,
it is recommended to force the deletion of the Target UE information
when receiving a new HandoverRequired.

7. HandoverRequest
8. HandoverFailure
9. UEContextReleaseCommand
10. UEContextReleaseComplete
11. HandoverPreparationFailure

... Crashed ...
2024-02-29 23:02:38 +09:00
Sukchan Lee be12610fb6 [AMF/MME] No STATE Change for the EMM/GMM-STATUS 2024-02-03 10:16:16 +09:00
Sukchan Lee 47419be650 [AMF/SMF] Resolved the Issue of Session Release Based on the Order of N1/N2 Messages (#2917)
There is an issue with SESSION RELEASE not working properly
depending on the PDU session release complete order
in the PDUSessionResourceReleaseResponse.

If the AMF receives PDUSessionResourceReleaseResponse
followed by PDU session release complete, it works correctly.

However, if it receives PDU session release complete
followed by PDUSessionResourceReleaseResponse, it does not work correctly
and sends an Error Indication to the UE/gNB.

To fix this issue, we added pdu_session_release_complete_received and
pdu_session_resource_release_response_received to the content
so that CLEAR_SM_CONTEXT_REF() is executed when both are received.
2024-02-03 09:42:09 +09:00
Sukchan Lee b0cf9fcbe7 [AMF] Issue during Concurrent UE Registration (#2839)
While they were continuing their fuzzy testing and developing PacketRusher, an unusual issue with the AMF was observed. The problem arises when a single Ethernet frame containing three bundled SCTP chunks is sent. This behavior is reproduced with PacketRusher when attempting to concurrently register two UEs with the same MSIN.

The expected behavior is that the PDU Session Establishment Accept is sent inside a DownlinkNASTransport to RAN UE NGAP ID 1. However, it is actually sent inside an InitialContextSetupRequest to RAN UE NGAP ID 2. The MAC of this NAS message is invalid for the Security Context of RAN UE NGAP ID 2 (probably valid for RAN UE NGAP ID 1)
2024-01-13 23:16:50 +09:00
Sukchan Lee b1515a16ff [SMF] Fixes crash when PDU session release
I've resolved an issue where sending continuous
'PDU Session Release Request' message to the same session,
when more than two sessions were created, was causing an SMF crash.

For your reference, this problem did not occur
when only one session was created.
2024-01-05 21:15:34 +09:00
Sukchan Lee 1ba3fd3cf8
[AMF/MME] UEContextReleaseCommand after Interity Protected (#2786) (#2794)
* [AMF/MME] UEContextReleaseCommand in Integrity (#2786)

Modified not to send UEContextReleaseCommand in Integrity Unprotected
NAS message such like Registration or Service request.

* [AMF/MME] UEContextReleaseCommand after Interity Protected (#2786)

Modified not to send UEContextReleaseCommand in Integrity Unprotected
NAS message such like Registration or Service request.
2023-12-13 17:54:37 +09:00
Sukchan Lee 7da45cde66 [AMF] mac_failed should be initialized (#2679)
amf_ue->mac_failed flag to be cleared during security mode procedure but it was not.
At this point, the only way to cleare the amf_ue->mac_failed flag is by UE Context Release.
But I'd like to connect UEs as fast as possible without UE Context Release.
2023-10-17 22:28:23 +09:00
Sukchan Lee 7ce1137a10 [SMF] Disable Network Service request while ACTIVATING
Disable Network triggered service request
while UE triggered service request

(#2294)
2023-05-08 22:33:50 +09:00
Sukchan Lee 0df402bd49 [SBI] Move HNET PKI conf inside UDM 2023-02-18 12:41:08 +09:00
Sukchan Lee b88dcecc29 [TEST] Reduce paging wait time 2023-02-05 12:17:43 +09:00
Sukchan Lee b7386284a7 [NRF] Fixed a crash during NRF discovery (#2034)
Other NF instances are obtained through NRF
or created directly through configuration files.

Other NFs created by the config file should not be passed
through NRF discovery or anything like that.

Since self-created NF Instances do not have an ID,
they are implemented to exclude them from NRF Discovery.
2023-01-29 11:22:45 +09:00
Sukchan Lee 3715b9ece3 [CORE] OGS_MAX_SDU_LEN->OGS_HUGE_LEN Stack (#2008)
Changed all OGS_MAX_SDU_LEN in the stack to OGS_HUGE_LEN.
2023-01-25 22:24:51 +09:00
Sukchan Lee df4c83372d [AMF] Fixed MEMORY LEAK (#1925) 2023-01-21 09:02:44 +09:00
Sukchan Lee 79d46be086 Introduced Subscription identifier de-concealing
o Generate the private key as below.
   $ openssl genpkey -algorithm X25519 -out /etc/open5gs/hnet/curve25519-1.key
   $ openssl ecparam -name prime256v1 -genkey -conv_form compressed -out /etc/open5gs/hnet/secp256r1-2.key

 o The private and public keys can be viewed with the command.
   The public key is used when creating the SIM.
   $ openssl pkey -in /etc/open5gs/hnet/curve25519-1.key -text
   $ openssl ec -in /etc/open5gs/hnet/secp256r1-2.key -conv_form compressed -text

In ausf/udm.yaml

 hnet:
    o Home network public key identifier(PKI) value : 1
      Protection scheme identifier : ECIES scheme profile A
    - id: 1
      scheme: 1
      key: /etc/open5gs/hnet/curve25519-1.key

    o Home network public key identifier(PKI) value : 2
      Protection scheme identifier : ECIES scheme profile B
    - id: 2
      scheme: 2
      key: /etc/open5gs/hnet/secp256r1-2.key

    o Home network public key identifier(PKI) value : 3
      Protection scheme identifier : ECIES scheme profile A
    - id: 3
      scheme: 1
      key: /etc/open5gs/hnet/curve25519-1.key

    o Home network public key identifier(PKI) value : 4
      Protection scheme identifier : ECIES scheme profile B
    - id: 4
      scheme: 2
      key: /etc/open5gs/hnet/secp256r1-2.key

Related to #1779
2022-12-24 20:22:45 +09:00
Sukchan Lee 817007d0ae [AMF] Wrongly sending PDU Session Release (#1925) 2022-12-04 14:32:19 +09:00
Sukchan Lee 773c7df3e6 [5GC] Fixed session deletion in a BSF (#1725) 2022-10-01 13:11:13 +09:00
Sukchan Lee c28faf00ea Added simple test program
./tests/registration/registration simple-test
./tests/vonr/vonr simple-test
./tests/attach/attach simple-test
./tests/volte/volte simple-test
2022-09-03 07:28:48 +09:00
Sukchan Lee da1905b36c fixed the memory leak in test program 2022-07-20 12:08:17 +09:00
Sukchan Lee 9c3b7dfe4b Added RRCEstablishmentCause to Test-Msg Param 2022-06-12 14:32:53 +09:00
Sukchan Lee bb4a8f34d4 [AMF] Fix the bug NGResetAck (#1525) 2022-05-14 02:43:01 +09:00
Sukchan Lee da8c934326 [Test] Fix the SBI running[1] 2022-03-28 23:09:24 +09:00
Sukchan Lee 2ed35f245d Fix the ciphered test program 2022-01-08 12:26:23 +09:00
Sukchan Lee 07a61018b2 [AMF] fix the crash (#1280)
During PDU Session Establishment,
if gNB sends PDUSessionResourceReleaseResponse,
AMF was crashed.

In this case, AMF/SMF remove Session Context and sends ErrorIndication.
2021-12-11 20:35:16 +09:00
Sukchan Lee acd67c7aa6 [5GC] Service Request Race Condition(#1226)
When UE-triggered and Network-triggered Service Request was occurred at
the same time, we need UPF deactivation and UEContextRelease
2021-11-28 20:54:51 +09:00
Sukchan Lee 0fb8279e36 VoNR added but not tested! 2021-11-14 21:07:56 +09:00
Sukchan Lee e730530f7b [SMF] Exception handling in session release(#1155)
- UE changes the airplain-mode. However, it does not send PDU
    session complete message
    - Added exception handling for PDU session release
2021-09-04 16:14:18 +09:00
Sukchan Lee 3d11b87127 [AMF] Buffix for NON-initial NAS message (#1106)
Confirmation for non-cleartext IE should only be applied
to the initial NAS message. Registration requests and Service requests
with UplinkNASTransport do not have to.
2021-05-19 13:27:31 +09:00
Sukchan Lee 5ea9b22209 [AMF] security protection (UERANSIM-issues316)
1. Allocate ngKSI other than the value already used.
2. Add the protection of Service request
3. fix SBI convert error ng_ap_cause
2021-05-08 13:24:17 +09:00
Sukchan Lee 1dc692753a [AMF] Distinguish Cleartext/Non-cleartext (#958)
1. If UE does not use a NAS container for Non-cleartext IEs,
   Open5GS AMF will send Registration reject message.
2. If UE sends Non-cleartext IEs without Integrity-protected,
   Open5GS AMF will send Registration reject message.
3. If UE does not send NAS container in Security mode complete message,
   Open5GS AMF will send Registration reject message.
2021-05-07 15:07:51 +09:00
Sukchan Lee ea89d8dc8e [AMF] Added RANConfigurationUpdate (#943) 2021-04-16 16:26:13 +09:00
Sukchan Lee cc03c91bdd [AMF] 5G-GUTI generation changed (#910)
The AMF shall assign a new 5G-GUTI for a particular UE:
a) during  a successful initial registration procedure;
b) during a successful registration procedure
   for mobility registration update; and
c) after a successful service request procedure invoked as a response
   to a paging request from the network and before the release
   of the N1 NAS signalling connection as specified in subclause 5.4.4.1.

The AMF should assign a new 5G-GUTI for a particular UE
during a successful registration procedure
for periodic registration update. The AMF may assign a new 5G-GUTI
at any time for a particular UE by performing
the generic UE configuration update procedure.
2021-04-13 17:34:25 +09:00
Sukchan Lee cc30aa2a9a fix: No S-TMSI in InitialUEMessage (#890) 2021-03-31 15:35:59 +09:00
Sukchan Lee d0eec31f5c upf/sgwu: fix the PDR creation bug (#860)
When PDR is created without deleting session, there is a bug to create
new PDR.
2021-03-19 10:08:37 +09:00
Sukchan Lee 37e0a714f9 Fixes UE IPv6 BUG (#808) 2021-03-15 10:01:55 +09:00
Sukchan Lee a6e42a4932 fix: No S-NSSAI error during NAS signalling #845 2021-03-12 22:45:21 +09:00
Sukchan Lee fc5c9b2af0 Try to fix the UE infinite attach (#568)
If both Delete-Session-Request/Response and
UEContextReleaseCommand/UEContextReleaseComplete are failed at the same time,
UE cannot attach to the EPC infinitely.

So, I've add the protection code
if timer expires when MME does not receive Delete-Session-Response.
2021-03-09 14:28:07 +09:00
Sukchan Lee 9af4268bab arch: DB schema Changes (#796)
- New function : NSSF
- New feature : SMF selection
2021-03-08 21:25:09 +09:00
Sukchan Lee 852756f902 test: Porting FreeBSD 2021-02-08 14:25:40 -05:00
Sukchan Lee 7901a1164f mac: Support Apple M1 chips
See https://open5gs.org/open5gs/docs/platform/05-macosx-apple-silicon/
2021-02-06 00:13:48 -05:00
Sukchan Lee f47f65a51c fix: asn1c decode problem for NGReset (#773) 2021-02-02 13:33:09 -05:00
Sukchan Lee d9417be9a6 feat: Handling Duplicated PDU Session ID
TS29.502 5.2.2.3.11 AMF requested PDU Session Release due to duplciated
PDU Session Id
2021-02-01 10:14:27 -05:00
Sukchan Lee ada01fca8f spec: S1AP/NGAP update to v16.4.0(2021-01-04) 2021-01-24 23:43:42 -05:00
Sukchan Lee 61778f9142 fix: UE Context Request IE handling (#771) 2021-01-23 13:42:59 -05:00
Sukchan Lee 776d323a16 fix: Change UE Context Request IE handling (#771)
Previously, AMF would sends PDUSessionResourceSetupRequest
when the following conditions were met:
- gNB didn't send UE Context Request IE of InitialUEMessage
- AMF should send SMF generated TRANSFER message(PDU_RES_SETUP_REQ)
to the gNB

However, in issues #771, the gNB did not accept
PDUSessionResourceSetupRequest. Perhaps the gNB engineer thought
that if gNB needs to send data traffic to the UE, AMF should send
an InitialContextSetupRequest regardless of UE Context Request IE.
This is because gNB requires the kgNB security context
for data connection.

So, in this case, Open5GS-AMF decided to send
an InitialContexSetupRequest regardless of
whether it received UE Context Request IE of InitialUEMessage.
2021-01-23 11:56:04 -05:00