open5gs/lib/crypt
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
..
openssl Fixed MacOSX compile error (Follow-up on #2581) 2023-09-14 07:04:27 +09:00
curve25519-donna.c Introduced Subscription identifier de-concealing 2022-12-24 20:22:45 +09:00
ecc.c Introduced Subscription identifier de-concealing 2022-12-24 20:22:45 +09:00
ecc.h Introduced Subscription identifier de-concealing 2022-12-24 20:22:45 +09:00
kasumi.c Rename Project to Open5GS 2019-10-27 17:41:14 +09:00
kasumi.h Rename Project to Open5GS 2019-10-27 17:41:14 +09:00
meson.build [AMF/MME] Fix crash during snow-3g encrypt (#2581) 2023-09-13 23:22:46 +09:00
milenage.c Improve Milenage library for [R1-R5] (#1153) 2021-09-01 19:38:36 +09:00
milenage.h Rename Project to Open5GS 2019-10-27 17:41:14 +09:00
ogs-aes-cmac.c License update 2020-11-12 20:58:08 -05:00
ogs-aes-cmac.h License update 2020-11-12 20:58:08 -05:00
ogs-aes.c License update 2020-11-12 20:58:08 -05:00
ogs-aes.h License update 2020-11-12 20:58:08 -05:00
ogs-base64.c Introduced Subscription identifier de-concealing 2022-12-24 20:22:45 +09:00
ogs-base64.h Introduced Subscription identifier de-concealing 2022-12-24 20:22:45 +09:00
ogs-crypt.h [AMF/MME] Fix crash during snow-3g encrypt (#2581) 2023-09-13 23:22:46 +09:00
ogs-kdf.c [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
ogs-kdf.h [SEC] Several vulnerabilities have been resolved. 2024-02-03 10:41:12 +09:00
ogs-sha1-hmac.c License update 2020-11-12 20:58:08 -05:00
ogs-sha1-hmac.h License update 2020-11-12 20:58:08 -05:00
ogs-sha1.c License update 2020-11-12 20:58:08 -05:00
ogs-sha1.h License update 2020-11-12 20:58:08 -05:00
ogs-sha2-hmac.c License update 2020-11-12 20:58:08 -05:00
ogs-sha2-hmac.h License update 2020-11-12 20:58:08 -05:00
ogs-sha2.c License update 2020-11-12 20:58:08 -05:00
ogs-sha2.h License update 2020-11-12 20:58:08 -05:00
snow-3g.c Use talloc for all memory pool (#1263) 2022-01-04 08:29:18 +09:00
snow-3g.h Rename Project to Open5GS 2019-10-27 17:41:14 +09:00
zuc.c Remove not valid UTF-8 characters 2023-01-31 00:22:16 +09:00
zuc.h Rename Project to Open5GS 2019-10-27 17:41:14 +09:00