open5gs/lib/nas/eps
Sukchan Lee d1d3ec6fcb [SEC] Several vulnerabilities have been resolved.
1. Reachable assertion in ogs_nas_5gmm_decode

Location: lib/nas/5gs/decoder.c:4445

```c
int ogs_nas_5gmm_decode(ogs_nas_5gs_message_t *message, ogs_pkbuf_t *pkbuf)
{
    int size = 0;
    int decoded = 0;

    ogs_assert(pkbuf);
    ogs_assert(pkbuf->data);
    ogs_assert(pkbuf->len);
```

When a NAS payload is received over `src/amf/context.c:1675`NGAP that has no data, the ogs_assert(pkbuf->len) assertion will be triggered.

2.Reachable assertion in ogs_nas_emm_decode

```
int ogs_nas_emm_decode(ogs_nas_eps_message_t *message, ogs_pkbuf_t *pkbuf)
{
    int size = 0;
    int decoded = 0;

    ogs_assert(pkbuf);
    ogs_assert(pkbuf->data);
    ogs_assert(pkbuf->len);
```

Nearly identical to (1), but for LTE.

3. Reachable assertion in nas_eps_send_emm_to_esm

```
int nas_eps_send_emm_to_esm(mme_ue_t *mme_ue,
        ogs_nas_esm_message_container_t *esm_message_container)
{
    int rv;
    ogs_pkbuf_t *esmbuf = NULL;

    if (!mme_ue_cycle(mme_ue)) {
        ogs_error("UE(mme-ue) context has already been removed");
        return OGS_NOTFOUND;
    }

    ogs_assert(esm_message_container);
    ogs_assert(esm_message_container->length);
```

The ESM message payload may be 0-length, as the length is determined by a field in the NAS payload (which can be chosen arbitrarily by an attacker). This leads to the length assertion above being triggered.

5. Reachable assertion and incorrect hash calculation in ogs_kdf_hash_mme

```
void ogs_kdf_hash_mme(const uint8_t *message, uint8_t message_len, uint8_t *hash_mme)
{
    uint8_t key[32];
    uint8_t output[OGS_SHA256_DIGEST_SIZE];

    ogs_assert(message);
    ogs_assert(message_len);
    ogs_assert(hash_mme);

    memset(key, 0, 32);
    ogs_hmac_sha256(key, 32, message, message_len,
            output, OGS_SHA256_DIGEST_SIZE);

    memcpy(hash_mme, output+24, OGS_HASH_MME_LEN);
}
```

When handling NAS attach requests or TAU requests, the ogs_kdf_hash_mme function is passed the NAS payload. However, the length field is represented as an unsigned 8-bit integer, which the passed length of the packet may overflow. This leads to the passed value being truncated.

When the passed value is a multiple of 256, the above assertion (ogs_assert(message_len)) is triggered. Otherwise, the hash is computed on only the first n bits of the message (where n = actual_message_len % 256).
2024-02-03 10:41:12 +09:00
..
support [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
conv.c [MME] Constify params in mme-context and depending APIs 2024-01-06 07:42:32 +09:00
conv.h [MME] Constify params in mme-context and depending APIs 2024-01-06 07:42:32 +09:00
decoder.c [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
encoder.c [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
ies.c [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
ies.h [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
meson.build simple 5GC registration is done 2020-06-21 23:10:54 -04:00
message.h [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
ogs-nas-eps.h simple 5GC registration is done 2020-06-21 23:10:54 -04:00
types.c [AMF/MME] Support TAI Range 2023-03-19 18:31:45 +09:00
types.h [SEPP] Initial Update for 5G Roaming (#2739) 2023-11-19 19:34:51 +09:00