fix(security): add polkit auth check to getFileSize D-Bus method - #493
Conversation
The getFileSize method was missing polkit authorization check, allowing any local user to query arbitrary file sizes via D-Bus. getFileSize方法缺少polkit认证检查,任意本地用户均可通过D-Bus 获取任意root可读文件的大小信息,造成信息泄露。 Log: 修复getFileSize方法未鉴权的安全漏洞 PMS: BUG-372477 Influence: 未授权用户无法再通过D-Bus获取任意文件大小,消除信息泄露风险。
There was a problem hiding this comment.
Sorry @wangrong1069, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds a missing polkit authorization check to the LogViewerService::getFileSize D-Bus method to align it with other privileged file-inspection methods and prevent unauthenticated users from querying root-readable file sizes. Sequence diagram for polkit auth in LogViewerService_getFileSizesequenceDiagram
actor Client
participant DBus
participant LogViewerService
participant Polkit
Client->>DBus: getFileSize(filePath)
DBus->>LogViewerService: getFileSize(filePath)
LogViewerService->>LogViewerService: checkAuth(s_Action_View)
alt [checkAuth passes]
LogViewerService->>LogViewerService: QFileInfo(filePath)
LogViewerService->>DBus: return fileSize
DBus->>Client: fileSize
else [checkAuth fails]
LogViewerService->>DBus: return 0
DBus->>Client: 0
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
/retest |
|
@wangrong1069: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
/retest |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lzwind, wangrong1069 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 |
deepin pr auto review★ 总体评分:100分■ 【总体评价】
■ 【详细分析】
■ 【改进建议代码示例】 quint64 LogViewerService::getFileSize(const QString &filePath)
{
qCDebug(logService) << "Getting file size for:" << filePath;
// 增加权限校验,未授权时直接返回 0,防止信息泄露
if (!checkAuth(s_Action_View)) {
return 0;
}
QFileInfo fi(filePath);
if (fi.exists())
return static_cast<quint64>(fi.size());
return 0;
} |
根因分析
LogViewerService::getFileSizeD-Bus 方法以 root 权限运行,但缺少 polkit 认证检查,任意本地用户可通过系统总线获取任意 root 可读文件的精确大小信息,造成信息泄露。关键证据:
logViewerService/logviewerservice.cpp:802—getFileSize方法入口无checkAuth(s_Action_View)调用getFileSize缺少认证检查isFileExist(:790)和getLineCount(:607)均正确执行了checkAuth修复方案
在
getFileSize方法入口添加checkAuth(s_Action_View)认证检查,认证失败时返回0,与同类方法isFileExist、getLineCount的模式一致。改动安全评估
低风险。仅添加 early return 认证检查,不改变函数签名,不影响已授权调用者的行为。所有引用点为声明或 D-Bus 适配器转发层,无直接业务调用者会因修复而行为变化。
Summary by Sourcery
Bug Fixes: