Sploitus

Exploit for details-for

kitploit · 2026-09-06

Exploit Code

MARKDOWN74 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-SMALLTOWN123-DETAILS-FOR-CVE-2022-46505
# CVE-2022-46505 详情

MatrixSSL 会话恢复漏洞

## 1\. 漏洞描述

MatrixSSL 4.5.1-open 及更早版本中存在一个问题,导致无法安全检查 SessionID 字段,从而导致滥用**全零 MasterSecret** ,进而可以解密机密数据。

## 2\. 受影响版本

MatrixSSL 4.5.1-open 及更早版本

## 3\. 漏洞类型

TLS 恢复会话解密

## 4\. 漏洞详情

MatrixSSL 服务器通过一个列表来存储协商的会话信息。

root@kitploit:~
    
    
    static sslSessionEntry_t g_sessionTable[SSL_SESSION_TABLE_SIZE]; 
    // SSL_SESSION_TABLE_SIZE is 32
    

root@kitploit:~
    
    
    typedef struct
    {
        unsigned char id[SSL_MAX_SESSION_ID_SIZE]; // 32
        unsigned char masterSecret[SSL_HS_MASTER_SIZE]; // 48
        const sslCipherSpec_t *cipher;
        unsigned char majVer;
        unsigned char minVer;
        short extendedMasterSecret;           /* was the extension used? */
        psTime_t startTime;
        int32 inUse;
        DLListEntry chronList;
    } sslSessionEntry_t;
    

SessionID 字段的前四个字节是一个**小端序** 序列号,范围**从 0 到 31** 。

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/084186eacb8cc73cc3a3b611b6c724d5a30a2281f4f626016fa1314625b0d086.png)

MatrixSSL 通过将接收到的会话 ID 的长度与四字节快速索引进行匹配,来判断会话是否为恢复会话。

然而,当存储列表初始化时,MasterSecret 全为零。

因此,恶意客户端可以发送**一个字节的 SessionID** 来尝试使用全零 MasterSecret 进行会话恢复。当服务器接收到一个字节的 sessionid 时,后续字节默认为 0。因此,它可以被验证并索引到列表中,而列表中对应序列号的 MasterSecret 可能仍为 0。如果发生这种情况,我们就能**计算出密钥并解密 TLS 通信数据** 。

`./matrixssl/matrixssl.c —> int32 matrixResumeSession(ssl_t *ssl)`

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/132067be7f50ed6be64eec0c281e0b65d86fc7b82ff3f7b639a470b5138c6443.png)

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/cb75ff9f149809b5ce71bb8f58abc4994a27a1714bac0796e97549282ded1ef9.png)

**添加用于调试的控制台输出:**

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/b2a72e33d0172da6d4aa6a7c7e6c31c260b35a3a7d61625d068047d4014279a6.png)

**测试结果:**

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/ca4552979d09a63d0f6c8c93f6f502ab8ab7be14de8efdff3be6c9cc9c6fbe15.png)

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/a9eb0a800fbe98e2af413ac6a03b841d172574c933dbfd0501360011042c87f0.png)

**使用全零 MasterSecret 进行解密!**

![Untitled](https://assets.kitploit.com/production/public/readmes/20708/75ce539766d26f82c5cfbd0ffefe8eeb9f7660c90edffb80dcdf90bebc126b7a.png)