已关闭
[Bug]: OGAI 密钥文件读取模式未被识别 #8481
Wwwing301创建于  9 天前关闭于  1 天前
Wwwing301
9 天前 创建

测试类型

安全

测试版本

7.0.0LTS

问题描述

OGAI 功能读取 ogai.key.cipherogai.key.rand 时会传入 OGAI_MODE。该模式已经定义在枚举中,但公共密钥文件读取函数没有把它列入支持范围,因此直接报invalid key mode

调用方事先把密钥缓冲区清零,而读取函数没有返回状态。读取失败后,上层无法判断错误,空密钥缓冲区可能继续传给后续加密函数。

操作系统和硬件信息

Ubuntu 22.04.5 LTS,x86_64。

测试环境

企业版单机

被测功能

OGAI API key 加密流程读取本地密钥文件时的模式分派。

预置条件

安装支持 C++17 的 g++,并将附件 poc.cc 保存到当前目录。

操作步骤

g++ -std=gnu++17 -O0 -g poc.cc -o poc
./poc subscription-control
./poc ogai-trigger

预期输出

已定义的 OGAI_MODE 应被密钥文件读取函数识别。读取失败时应把错误返回给调用方,并停止后续加密。

实际输出

SUBSCRIPTION_MODE 对照正常通过;OGAI_MODE 被拒绝并输出:

AK/SK encrypt/decrypt encounters invalid key mode.

日志信息

相关代码:

  • src/include/cipher.h:80-95
  • src/common/port/cipher.cpp:470-483,799-820,891-900
  • src/gausskernel/cbb/utils/aes/cipherfn.cpp:808-885,897-943
  • src/gausskernel/storage/access/datavec/ogai.cpp:484-520

提单组织

社区用户

测试代码

#include <cstdio>
#include <cstring>

typedef enum {
    UNKNOWN_KEY_MODE, SERVER_MODE, CLIENT_MODE,
    HADR_MODE, OBS_MODE, SOURCE_MODE, GDS_MODE,
    USER_MAPPING_MODE, SUBSCRIPTION_MODE, OGAI_MODE
} KeyMode;

static bool isModeExists(KeyMode mode)
{
    if (mode != SERVER_MODE && mode != CLIENT_MODE && mode != HADR_MODE &&
        mode != OBS_MODE && mode != SOURCE_MODE && mode != GDS_MODE &&
        mode != USER_MAPPING_MODE && mode != SUBSCRIPTION_MODE) {
        std::fprintf(stderr, "AK/SK encrypt/decrypt encounters invalid key mode.\n");
        return false;
    }
    return true;
}

int main(int argc, char **argv)
{
    if (argc != 2) return 2;
    if (std::strcmp(argv[1], "subscription-control") == 0)
        return isModeExists(SUBSCRIPTION_MODE) ? 0 : 3;
    if (std::strcmp(argv[1], "ogai-trigger") == 0)
        return !isModeExists(OGAI_MODE) ? 0 : 4;
    return 2;
}

likedislike
opengauss_bot
opengauss_bot成员
9 天前 评论:

This issue requires an assignee. Since you haven't specified one, we've assigned TestManager as the default assignee for this issue.

likedislike
opengauss_botopengauss_bot成员
9 天前 将 TestManager 设为负责人
opengauss_bot
opengauss_bot成员
9 天前 评论:

Welcome To openGauss Community

Hey @Wwwing301 , thanks for your contribution to the community.

Bot Usage Manual

I'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. You can self-configure the PR merge rules for this repository. For more details, please refer to Here.

Contact Guide

If you have any questions, please contact the SIG: StorageEngine, AI, CM, CloudNative, SecurityTechnology, SQLEngine ,
and any of the maintainers: @CarrotGo, @chendong76, @chenxiaobin19, @congzhou2603, @dodders, @hwworkholic, @jemappellehc, @libiao2024, @muyulinzhong, @quemingjian, @shenzheng4, @shirley_zhengx, @superlchf, @totaj, @wlff234, @wofanzheng, @ywzq1161327784 ,
and any of the committers: @Igali, @bihua111, @cailei19, @h_ray, @levy53071, @libiao2024, @lihaixiao, @mrzack, @wangfeihuo, @wuyuechuan, @xiong_xjun, @zhangfengzhi123, @zhangxubo, @zhangzq131, @zjh_hw .

likedislike
opengauss_botopengauss_bot成员
9 天前 添加了label:sig/SecurityTechnology
liuzhen001liuzhen001成员
9 天前 关联了看板:openGauss 7.0.0-LTS
IIgali成员
8 天前 将 zcj112 设为负责人
IIgali成员
7 天前 移除了负责人 TestManager
chendong76chendong76成员
6 天前 将 Eurekaxun 设为负责人
chendong76chendong76成员
6 天前 移除了负责人 zcj112
徐文贵徐文贵成员
6 天前 关联了pull request:[7.0.0] 修复口令清零、SHOW 清理及加解密问题
徐文贵徐文贵成员
6 天前 关联了pull request:[master] 修复口令清零、SHOW 清理及加解密问题
徐文贵
徐文贵成员
4 天前 评论:

B023
image.png

likedislike
徐文贵徐文贵成员
4 天前 issue状态由 待办的 改变为 待回归
l1azzzy
l1azzzy成员
1 天前 评论:

验收日期:2026-9-15
验收结论:验收通过
验收版本:7.0.0.B023

image.png

image.png
image.png

likedislike
l1azzzyl1azzzy成员
1 天前 issue状态由 待回归 改变为 已验收
l1azzzyl1azzzy成员
1 天前 关闭了 issue