Skip to content

fix(security): add caller verification for more Manager and Updater methods - #457

Open
qiuzhiqian wants to merge 1 commit into
masterfrom
fix-dbus-policy
Open

fix(security): add caller verification for more Manager and Updater methods#457
qiuzhiqian wants to merge 1 commit into
masterfrom
fix-dbus-policy

Conversation

@qiuzhiqian

@qiuzhiqian qiuzhiqian commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Add sender parameter and checkInvokePermission calls to the following D-Bus methods that were missing authorization checks:

Manager: GetArchivesInfo, PackageExists, PackageInstallable, GetUpdateLogs, GetHistoryLogs, PackagesSize, PackagesDownloadSize, RegisterAgent, SetAutoClean, UnRegisterAgent, QueryAllSizeWithSource, PowerOff, CanRollback

Updater: GetCheckIntervalAndTime, ListMirrorSources, SetDeliveryDownloadSpeedLimit, SetDeliveryUploadSpeedLimit

Bug: https://pms.uniontech.com/bug-view-371795.html

Summary by Sourcery

Enforce caller authorization for additional Manager and Updater D-Bus methods to close missing security checks.

Bug Fixes:

  • Add caller verification to Manager methods handling archive info, package queries, logs, size calculations, agent registration, auto-clean configuration, aggregate size queries, power operations, and rollback capability checks.
  • Require caller authorization for Updater methods related to update check scheduling, mirror source listing, and delivery speed limit configuration.

…ethods

Add sender parameter and checkInvokePermission calls to the following
D-Bus methods that were missing authorization checks:

Manager: GetArchivesInfo, PackageExists, PackageInstallable,
GetUpdateLogs, GetHistoryLogs, PackagesSize, PackagesDownloadSize,
RegisterAgent, SetAutoClean, UnRegisterAgent, QueryAllSizeWithSource,
PowerOff, CanRollback

Updater: GetCheckIntervalAndTime, ListMirrorSources,
SetDeliveryDownloadSpeedLimit, SetDeliveryUploadSpeedLimit

Bug: https://pms.uniontech.com/bug-view-371795.html

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @qiuzhiqian, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: qiuzhiqian

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

Copy link
Copy Markdown

CLA Assistant Lite bot:
提交邮箱中包含我们的合作伙伴,但您似乎并非合作伙伴的成员或对接人,请联系相关对接人将您添加至组织之中,或由其重新发起 Pull Request。
The commit email domain belongs to one of our partners, but it seems you are not yet a member of the current organization, please contact the contact person to add you to the organization or let them submit the Pull Request.

xml seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request

@sourcery-ai

sourcery-ai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds D-Bus caller verification to several Manager and Updater methods by threading a sender parameter through their signatures and invoking existing permission checks before performing privileged operations.

Sequence diagram for Manager methods with caller verification

sequenceDiagram
    actor Client
    participant DBus
    participant Manager

    Client->>DBus: GetArchivesInfo(sender)
    DBus->>Manager: GetArchivesInfo(sender)
    Manager->>Manager: checkInvokePermission(sender)
    alt [permission denied]
        Manager-->>DBus: dbusutil.ToError(err)
        DBus-->>Client: error
    else [permission granted]
        Manager->>Manager: getArchiveInfo()
        Manager-->>DBus: info, nil
        DBus-->>Client: info
    end
Loading

Sequence diagram for Updater methods with caller verification

sequenceDiagram
    actor Client
    participant DBus
    participant Updater
    participant Manager

    Client->>DBus: SetDeliveryDownloadSpeedLimit(sender, limitConfig)
    DBus->>Updater: SetDeliveryDownloadSpeedLimit(sender, limitConfig)
    Updater->>Manager: checkInvokePermission(sender)
    alt [permission denied]
        Updater-->>DBus: dbusutil.ToError(err)
        DBus-->>Client: error
    else [permission granted]
        Updater->>Updater: json.Unmarshal(limitConfig, speedLimitConfig)
        Updater-->>DBus: nil
        DBus-->>Client: ok
    end
Loading

File-Level Changes

Change Details Files
Add sender argument and permission checks to previously unguarded Manager D-Bus methods.
  • Updated multiple Manager interface methods to accept a dbus.Sender parameter instead of relying on implicit caller context.
  • Inserted checkInvokePermission(sender) calls at the start of methods, returning dbusutil.ToError on failure.
  • Ensured DelayAutoQuit and other existing logic remain intact while being executed only after permission validation where appropriate.
src/lastore-daemon/manager_ifc.go
Add sender-based permission checks to Updater D-Bus methods that read or modify update configuration and delivery limits.
  • Extended several Updater methods to accept a dbus.Sender parameter and wired them to use the Manager's checkInvokePermission for authorization.
  • Guarded configuration read methods (e.g., GetCheckIntervalAndTime, ListMirrorSources) with permission checks before accessing internal state.
  • Protected delivery speed limit mutators with permission checks to prevent unauthorized configuration changes.
src/lastore-daemon/updater_ifc.go

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

★ 总体评分:95分

■ 【总体评价】

代码通过为DBus接口方法统一添加调用者权限校验,有效修复了未授权访问的安全隐患
逻辑正确且修复方式规范,因无安全漏洞且各维度表现良好给予95分

■ 【详细分析】

  • 1.语法逻辑完全正确✓

代码在manager_ifc.goupdater_ifc.go中为多个方法添加了sender dbus.Sender参数,并在函数体首部正确调用了checkInvokePermission进行权限拦截,错误处理使用dbusutil.ToError(err)转换并返回,符合Go语言和DBus接口规范。
潜在问题:无
建议:无

  • 2.代码质量优秀✓

修改方式高度统一,所有暴露的接口方法均采用相同的权限校验模式,代码风格一致,可读性强,未引入冗余逻辑。
潜在问题:无
建议:无

  • 3.代码性能无性能问题✓

权限校验通常是基于本地策略或缓存的快速查询,开销极小,不会对接口响应时间产生明显影响。
潜在问题:无
建议:无

  • 4.代码安全存在0个安全漏洞✓

漏洞对比统计:新增漏洞 0 个,减少漏洞 0 个,持平 0 个
本次修改修复了原先未授权访问的风险,通过在执行核心业务逻辑前增加checkInvokePermission校验,确保只有授权的调用者才能访问GetArchivesInfoPackageExistsListMirrorSources等敏感接口,显著提升了系统安全性,当前代码片段不存在安全漏洞。

  • 建议:继续保持在所有新增DBus接口方法中强制执行权限校验的规范

■ 【改进建议代码示例】

diff --git a/src/lastore-daemon/manager_ifc.go b/src/lastore-daemon/manager_ifc.go
index 8fb2efce8..b248658ee 100644
--- a/src/lastore-daemon/manager_ifc.go
+++ b/src/lastore-daemon/manager_ifc.go
@@ -69,8 +69,11 @@ func (m *Manager) FixError(sender dbus.Sender, errType string) (job dbus.ObjectP
 	return jobObj.getPath(), nil
 }
 
-func (m *Manager) GetArchivesInfo() (info string, busErr *dbus.Error) {
+func (m *Manager) GetArchivesInfo(sender dbus.Sender) (info string, busErr *dbus.Error) {
 	m.service.DelayAutoQuit()
+	if err := m.checkInvokePermission(sender); err != nil {
+		return "", dbusutil.ToError(err)
+	}
 	info, err := getArchiveInfo()
 	if err != nil {
 		return "", dbusutil.ToError(err)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants