Commit Graph

163 Commits

Author SHA1 Message Date
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 da5d424ed9 [MME] Incorrect behavior of SGsAP+Dedicated-Bearer (#3072)
First of all, it crashes when creating a Dedicated Bearer
on the default Session that is created for the first time.
This behavior should be possible, so the related ASSERT is removed.

Next, the InitialContextRequest is modified
during the Attach Request to include the first Bearer.

Finally, there was an issue where trying to create a Dedicated Bearer
with SGsAP enabled resulted in an InitialContextSetupRequest message
with a PTI of zero. This is because MME initializes the PTI to 0
upon receiving the Create Bearer Request while processing SGsAP.

All of these issues has been fixed.
2024-04-01 22:13:36 +09:00
Sukchan Lee a1a0a8c0a6 [MME] Race condition between S1AP and S6A
Assume the UE has Attached, the session has been created,
and is in the IDLE state with the UEContextRelease process.

This could result in the following call flow.

1. TAU request without Integrity Protected
2. Authentication request/response
3. Security-mode command/complete

MME can be performed simultaneously by the HSS(S6A) and UE(S1AP).

Update-Location-Request
Service request
Service reject
Delete Session Request
Delete Session Response
Update-Location-Answer
UEContextReleaseCommand for Service reject
TAU reject
UEContextReleaseCommand for TAU reject
UEContextReleaseComplete
UEContextReleaseComplete

MME crashes when UE sends a service request(S1AP) during ULR/ULA(S6A) with HSS,
which has been fixed.
2024-03-16 23:08:07 +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 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 41d8934677 [SMF] Added Bi-Directional Flow (#2909)
For bi-directions, the rules are created in the same form as for downlink
as shown below, so to apply them for uplink, we need to swap the rules
according to the interface.

RX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
GX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
PFCP : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
RULE : Source <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> Destination <UE_IP> <UE_PORT>
TFT : Local <UE_IP> <UE_PORT> REMOTE <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>

RX : permit in from <UE_IP> <UE_PORT> to <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
GX : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
PFCP : permit out from <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT> to <UE_IP> <UE_PORT>
RULE : Source <UE_IP> <UE_PORT> Destination <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
TFT : Local <UE_IP> <UE_PORT> REMOTE <P-CSCF_RTP_IP> <P-CSCF_RTP_PORT>
2024-02-17 20:43:15 +01:00
Sukchan Lee 843c4950ac [ASN1C] Fixed asn1c library on 32bit (#2934)
APER encoding fails when using the asn_uint642INTEGER function on a 32-bit machine as shown below.

```C
   asn_uint642INTEGER(AMF_UE_NGAP_ID, 0xffffffff);
   ...
   aper_encode_to_buffer(...)
```

INTEGER APER encode/decode functions seem to be operating internally with long variables instead of intmax_t.
That is probably the reason of the failure.

@v0-e fixed this issues in the mouse07410/asn1c pull request.
https://github.com/mouse07410/asn1c/pull/176
https://github.com/mouse07410/asn1c/pull/177
2024-02-12 14:00:06 +09:00
Bostjan Meglic ad216c0b77 [core] Fix a couple of warnings when using C++ compiler or more strict settings
../lib/core/ogs-list.h:62:24: warning: invalid conversion from 'void*' to 'ogs_list_t*' {aka 'ogs_list_s*'} [-fpermissive]
../lib/core/ogs-rbtree.h:79:32: warning: invalid conversion from 'const void*' to 'const ogs_rbnode_t*' {aka 'const ogs_rbnode_s*'} [-fpermissive]

[SBI] Fix compiler error - possible uninitialized variable

[SCP] Fix compiler error - Error: this condition has identical branches

In case of additional compiler warnings turned on, the compiler warns
about potentially unused variables. Fix those issues.
2024-01-09 17:50:22 +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 e42048e8a5
Reset the number of TA, SLICE, and PLMN supported by AMF/MME(#2761) (#2765)
* update it

* update it

* update it

* update it

* update it

* udpate it

* uupdate it
2023-12-03 23:52:29 +09:00
Sukchan Lee e92293e0af
[SEPP] Initial Update for 5G Roaming (#2739)
[SEPP] Initial Update for 5G Roaming
2023-11-19 19:34:51 +09:00
Pau Espin e108d6297c HSS: Add support for Operator-Determined-Barring field
* Add "subscriber_status" cmd to open5gs-dbctl to set values for
  "subscriber_status" and "operator_determined_barring" DB fields.
* Add webui View+Edit for those same fields.
* open5gs-hssd now takes those values into account and submits
  Operator-Determined-Barring AVP with DB-retrieved value if
subscriber_status is set to OPERATOR_DETERMINED_BARRING.

For more information, see TS 29.272 section 5.2.2.1.3  and 7.3.30.
2023-10-12 07:17:54 +09:00
Sukchan Lee a3a683e5a6 [MME] Implement ENBConfigurationUpdate (#2589) 2023-09-16 20:58:58 +09:00
Sukchan Lee 05ed95d623 [GTPU] Fixed PDCP SN handling (#2584, #2477)
Scenario is handover on S1AP, data forwarding is enabled, and
the Source ENB is forwarding DL PDCP packets to EPC(SGWU)
with PDCP SN included. SGWU is also forwarding these packets
to the Target ENB.

However the PDCP SN is not present in the forwarded packets
from SGWU to Target ENB.

I modified this part, and there was the same problem in 5GC, fixed it as well.

A lot of code in GTP-U has been modified,
so if you have any problems, please let us know right away.
2023-09-10 22:37:42 +09:00
Sukchan Lee 2f8ae91b0b Fixed dynamic-stack-buffer-overflow (#2578, #2577) 2023-09-05 21:58:05 +09:00
Sukchan Lee e01f46eb6c
Use x1000 multiplier for Kbps, Mbps, ... etc. (#2515)
NAS, GTP, PFCP, SBI, all except S1AP/NGAP use x1000 multiplier for Kbps, Mbps, Gbps ... etc.

From now on in WebUI all units also use a multiplier of x1000.
2023-08-13 18:19:45 +09:00
Sukchan Lee 9f19210f22 Add trace log for debugging #2287 2023-08-07 22:13:35 +09:00
Sukchan Lee 5764f7267d Fixed security vulnerability for malformed packet 2023-07-26 16:32:46 +09:00
Sukchan Lee 691d8ea13a [AMF] Fixed crashes with assertion (#2312)
AMF crashes with amf_nnssf_nsselection_handle_get assertion failure.
2023-05-21 07:51:43 +09:00
Sukchan Lee 01d3db4b6e [MME/SMF] Added Extended-PCO in 4G/LTE (#2261) 2023-04-22 00:06:50 +09:00
Sukchan Lee aed52a9ad8 [GTP-U] Send Error Indication for unknown PDR 2023-04-16 12:30:36 +09:00
Sukchan Lee 424f382265 [AMF/MME] Support TAI Range 2023-03-19 18:31:45 +09:00
Sukchan Lee 69c080c8f2 [NAS/GTP/PFCP] Upgrade IE to Release-17
As raised in #2147, AMF fails to decode S1 UE Network Capability.

So I reviewed all IE in NAS, GTP and PFCP and fixed it for Release-17.
2023-03-11 18:42:30 +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 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 982ac61894 Prometheus metrics set to default 2022-11-21 22:06:29 +09:00
Sukchan Lee 1acb7f72b4 [UPF] test code for unspecified address (#1776) 2022-10-01 13:23:15 +09:00
Sukchan Lee 2b8db5d488 Follow-up on #1757 2022-09-23 20:42:04 +09:00
Sukchan Lee 1d17e68c56 [ALL] Removing trailing whitespace and tab 2022-09-02 23:38:39 +09:00
Sukchan Lee 668cc59f94 [AMF] Fixed 5GMM cause in Reject message (#1660)
When a UE that requests slices tries to connect and there are no slices configured, the reject message is:

5GMM cause = 0x7 (5GS Services not allowed)

however it should be:

5GMM cause = 0x3e (No network slices available)

All 5GMM cause value in reject message is reviewed in this commit
2022-07-19 12:42:02 +09:00
Bostjan Meglic d1a2971990 [NAS] modify library to include both directions of deregistration requests
Definitions in NAS library now include both directions of deregistration
requests/accepts - from UE and from network.
2022-07-11 22:53:21 +09:00
Sukchan Lee b58ebda556 Change Default MCC/MNC 901/70 -> 999/70 (#1331) 2022-06-23 21:37:47 +09:00
Sukchan Lee 9c3b7dfe4b Added RRCEstablishmentCause to Test-Msg Param 2022-06-12 14:32:53 +09:00
Sukchan Lee 933f0b04c7 [TEST] Added IPv6 in GTPU (#1515) 2022-05-23 23:51:02 +09:00
Sukchan Lee e0a487f479 [SMF] Optimiza Session Modification Message
For video in VoNR, multiple QosFlow is required in one session.

In the past, since only one Session Modification Message was supported,
QoS-Flow was put into several Session Messages one by one and processed.

Now that multiple QoS-Flows can be supported,
it is optimized to process one session modification message.
2022-05-15 23:35:41 +09:00
Sukchan Lee 4d2f7726b9 X2 handover with SGW change (#1367, #1459) 2022-05-12 22:52:36 +09:00
Pau Espin 76fecdb54e
[SMF] Store MSISDN from GTPC and pass it in Gy CCR (#1519) 2022-05-04 05:37:44 +09:00
Sukchan Lee 3508e09a41 [GTPU] IPv6 RS/RA with QFI Extended Header (#1506) 2022-04-30 11:50:30 +09:00
Pau Espin e3da7c9934
Rename GTPv2C specifics to gtp2 prefix (#1485)
In the past only GTPv2C was supported, and had the "gtp" generic prefix.
Later on, GTPv1C support was added, and "gtp1" prefix was used.
Let's move GTPv2C specific bits to have "gtp2" prefix too, and leave
"gtp" prefix for generic stuff among different GTP versions.
2022-04-13 07:07:39 +09:00
Sukchan Lee 82241f5b84 Added Meson Continuous Integration (#1454) 2022-04-01 02:31:57 +09:00
Sukchan Lee 12c656efd0 Improve Slice/DNN selection (#1438), (#1440) 2022-03-27 17:50:31 +09:00
Sukchan Lee ced37a6201 fix the slice issues (#1438), (#1440) 2022-03-26 23:53:53 +09:00
Sukchan Lee 37af21a88d [MEM] fix the pkbuf problem (#1431) 2022-03-22 22:47:45 +09:00
Sukchan Lee bcf53124d5 Improve the socket option configuration (#1404)
o GTP-C Option (Default)
  - so_bindtodevice : NULL

  gtpc:
    addr: 127.0.0.7
    option:
      so_bindtodevice: vrf-blue

o GTP-U Option (Default)
  - so_bindtodevice : NULL

  gtpu:
    addr: 127.0.0.7
    option:
      so_bindtodevice: vrf-blue

o PFCP Option (Default)
  - so_bindtodevice : NULL

  pfcp:
    addr: 127.0.0.7
    option:
      so_bindtodevice: vrf-blue

o SBI Option (Default)
  - tcp_nodelay : true
  - so_linger.l_onoff : false

  sbi:
    addr: 127.0.0.10
    option:
      tcp_nodelay: false
      so_linger:
        l_onoff: true
        l_linger: 10

o NGAP Option (Default)
  - sctp_nodelay : true
  - so_linger.l_onoff : false
ngap:
  addr: 127.0.0.5
  option:
    stcp_nodelay: false
    so_linger:
      l_onoff: true
      l_linger: 10

o NGAP SCTP Option (Default)
  - spp_hbinterval : 5000 (5secs)
  - spp_sackdelay : 200 (200ms)
  - srto_initial : 3000 (3secs)
  - srto_min : 1000 (1sec)
  - srto_max : 5000 (5secs)
  - sinit_num_ostreams : 30
  - sinit_max_instreams : 65535
  - sinit_max_attempts : 4
  - sinit_max_init_timeo : 8000(8secs)
ngap:
  addr: 127.0.0.5
  option:
    sctp:
      spp_hbinterval : 5000
      spp_sackdelay : 200
      srto_initial : 3000
      srto_min : 1000
      srto_max : 5000
      sinit_num_ostreams : 30
      sinit_max_instreams : 65535
      sinit_max_attempts : 4
      sinit_max_init_timeo : 8000
2022-03-15 22:03:50 +09:00
Sukchan Lee 253e2ad98a [GTP/PFCP] Support VRF (#1404) 2022-03-07 22:43:18 +09:00
Pau Espin 7bddc92322 [GTP] Support binding socket to device
This is useful, among other possible applications, to make use of VRFs [1],
in this case for GTP-C and GTP-U traffic in the PGW.

The bind_dev field is added to the ogs_socknode_t so that it's easy to
extend its use into lots of other sockets being set up based on config
file information.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/vrf.rst
2022-03-02 20:07:51 +01:00
Pau Espin d06acc7f37
Fix trailing whitespace (#1402) 2022-03-01 17:13:40 +09:00