fix(editor): replace MD5 with SHA-256 and fix D-Bus caller verification - #498
Conversation
There was a problem hiding this comment.
Sorry @tianming-1996, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's GuideThis PR replaces MD5-based backup filename hashing with a SHA-256 helper, realigns all backup creation/cleanup code around the new helper, and fixes D-Bus/Polkit integration to authorize based on the caller’s system bus name with tightened D-Bus policy configuration. Sequence diagram for updated D-Bus saveFile authorization flowsequenceDiagram
actor DbusClient
participant DbusAdaptor
participant DBus
participant PolicyKitHelper
participant Authority
DbusClient->>DbusAdaptor: saveFile(filepath, text, encoding)
DbusAdaptor->>DbusAdaptor: message()
DbusAdaptor->>DBus: saveFile(path, text, encoding, callerBusName)
DBus->>PolicyKitHelper: checkAuthorization(com.deepin.editor.saveFile, callerBusName)
PolicyKitHelper->>Authority: checkAuthorizationSync(actionId, SystemBusNameSubject(appBusName), AllowUserInteraction)
Authority-->>PolicyKitHelper: Result Yes/No
PolicyKitHelper-->>DBus: bool
DBus-->>DbusAdaptor: bool
DbusAdaptor-->>DbusClient: bool
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Replace weak MD5 hash with SHA-256 in backup file naming and fix polkit authorization to use SystemBusNameSubject with D-Bus caller's system bus name instead of UnixProcessSubject with daemon's own PID. Also tighten D-Bus policy config and fix backup cleanup naming. 将备份文件名生成中的弱密码 MD5 算法替换为 SHA-256,并修复 polkit 授权使用 SystemBusNameSubject 配合 D-Bus 调用者 system bus name, 替代原先错误使用守护进程自身 PID 的 UnixProcessSubject。同时收紧 D-Bus 策略配置,修复备份清理文件名不匹配的问题。 Log: 修复弱密码算法和D-Bus调用者验证缺陷 PMS: TASK-393519 Influence: 提升密码算法合规性,消除潜在权限提升风险,符合UOS V20安全基线。
4d8dc9e to
d8fd49c
Compare
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 // daemon/src/dbus.cpp
// 建议在文件保存前增加路径规范化与遍历检查,防止越权写入
bool DBus::saveFile(const QByteArray &path, const QByteArray &text, const QByteArray &encoding, const QString &callerBusName)
{
const QString filepath = QString::fromUtf8(path);
// 规范化路径并检查是否包含 ".." 防止路径遍历
QString canonicalPath = QFileInfo(filepath).canonicalFilePath();
if (canonicalPath.isEmpty() || filepath.contains("..")) {
qWarning() << "Invalid file path detected:" << filepath;
return false;
}
// 使用 D-Bus 调用者的 system bus name 进行 polkit 授权校验
if (PolicyKitHelper::instance()->checkAuthorization("com.deepin.editor.saveFile", callerBusName)) {
// Create file if filepath is not exists.
if (!Utils::fileExists(canonicalPath)) {
QString directory = QFileInfo(canonicalPath).dir().absolutePath();
// ... 原有创建目录和文件逻辑 ...
}
// ... 原有保存文件逻辑 ...
}
return false;
} |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: max-lvs, tianming-1996 The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/merge |
Replace weak MD5 hash with SHA-256 in backup file naming and fix polkit authorization to use SystemBusNameSubject with D-Bus caller's system bus name instead of UnixProcessSubject with daemon's own PID. Also tighten D-Bus policy config and fix backup cleanup naming.
将备份文件名生成中的弱密码 MD5 算法替换为 SHA-256,并修复 polkit
授权使用 SystemBusNameSubject 配合 D-Bus 调用者 system bus name, 替代原先错误使用守护进程自身 PID 的 UnixProcessSubject。同时收紧
D-Bus 策略配置,修复备份清理文件名不匹配的问题。
Log: 修复弱密码算法和D-Bus调用者验证缺陷
PMS: TASK-393519
Influence: 提升密码算法合规性,消除潜在权限提升风险,符合UOS V20安全基线。
Summary by Sourcery
Strengthen backup file hashing and D-Bus/Polkit authorization to improve security and fix backup cleanup naming.
New Features:
Bug Fixes:
Enhancements: