Skip to content

Revert "feat: 添加D-Bus调用者白名单鉴权机制,org.deepin.dde.LocaleHelper1设置语言" - #201

Closed
fly602 wants to merge 1 commit into
linuxdeepin:masterfrom
fly602:master
Closed

Revert "feat: 添加D-Bus调用者白名单鉴权机制,org.deepin.dde.LocaleHelper1设置语言"#201
fly602 wants to merge 1 commit into
linuxdeepin:masterfrom
fly602:master

Conversation

@fly602

@fly602 fly602 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This reverts commit 062dd62.

回退 security-loader 安全启动方案及其相关提交,包括:
集成 security-loader 及 AllowCaller 权限控制、LocaleHelper接口的鉴权改造、polkit 提权回退机制

原因

该方案影响范围过广,涉及 dde-session-daemon、langselector、polkit 策略、systemd 服务等多处改动,且与 V25 项目当前架构存在不匹配之处,不适合在此阶段落地。如果上层应用适配会影响其项目架构。

后续计划

需重新评估安全方案的整体设计,制定更契合 V25 架构的分阶段实施方案。

Summary by Sourcery

Revert the D-Bus caller whitelist authorization mechanism for locale-helper and return to direct Polkit authorization.

Enhancements:

  • Restore locale-helper authorization to use Polkit directly instead of the allow-caller registry.
  • Remove the allow-caller registry and its SetAllowCaller D-Bus method from the locale helper.
  • Update D-Bus policy configuration to remove SetAllowCaller-specific permissions and restrictions.

Chores:

  • Remove obsolete allow-caller implementation and tests.

Summary by Sourcery

Improve process identity validation in allow-caller authorization by making process start-time checks injectable.

Enhancements:

  • Improve allow-caller authorization testability by injecting process start-time lookup into the registry.

Tests:

  • Update allow-caller authorization tests to provide deterministic process start-time lookups.

@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 @fly602, 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: fly602

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

@sourcery-ai

sourcery-ai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR reverts the previously added D-Bus caller whitelist mechanism for org.deepin.dde.LocaleHelper1, removing the allow-caller registry, its D-Bus method and related configuration, and restoring direct Polkit-based authorization for locale changes.

Sequence diagram for updated SetLocale authorization via Polkit

sequenceDiagram
  actor Caller
  participant LocaleHelperHelper as Helper
  participant PolkitAuthority as polkit.Authority

  Caller->>LocaleHelperHelper: SetLocale(locale)
  LocaleHelperHelper->>LocaleHelperHelper: service.DelayAutoQuit()
  LocaleHelperHelper->>PolkitAuthority: checkAuth(sender)
  PolkitAuthority-->>LocaleHelperHelper: ok, err
  LocaleHelperHelper->>LocaleHelperHelper: logger.Debug("---Auth ret", ok, err)
  alt [!ok or err != nil]
    LocaleHelperHelper-->>Caller: dbusutil.ToError(errAuthFailed)
  else [authorized]
    LocaleHelperHelper-->>Caller: success (locale set)
  end
Loading

File-Level Changes

Change Details Files
Restore direct Polkit-based auth flow for SetLocale/GenerateLocale and remove allow-caller fallback logic.
  • Replace authorizeOrPolkit calls with direct checkAuth usage in SetLocale and generateLocale.
  • Remove debug-logged authorization branching and rely solely on checkAuth result to accept or reject requests.
  • Delete the authorizeOrPolkit helper that combined allow-caller registry and Polkit auth.
locale-helper/ifc.go
Remove allow-caller registry support from the Helper service and its initialization.
  • Drop allowCallers field from Helper struct and related lifecycle management.
  • Remove initialization and teardown of allowCallerRegistry in main, simplifying Helper construction.
locale-helper/main.go
locale-helper/allow_caller.go
locale-helper/allow_caller_test.go
Remove the SetAllowCaller D-Bus API and corresponding bus policy rules.
  • Delete the SetAllowCaller method implementation and its export from GetExportedMethods.
  • Remove D-Bus busconfig policies that allowed SetAllowCaller from root/deepin-daemon and denied it elsewhere.
locale-helper/ifc.go
locale-helper/exported_methods_auto.go
misc/conf/org.deepin.dde.LocaleHelper1.conf
Minor metadata and packaging adjustments consistent with reverting the feature.
  • Adjust SPDX-FileCopyrightText year range headers to 2018-2022 in main and interface files.
  • Keep polkit action and systemd unit files but without allow-caller related changes from the reverted commit.
locale-helper/ifc.go
locale-helper/main.go
misc/polkit-action/org.deepin.dde.locale-helper.policy.in
misc/systemd/system/deepin-locale-helper.service

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

★ 总体评分:40分

■ 【总体评价】

代码移除了自定义鉴权机制并简化了架构,但严重削弱了系统安全性
逻辑正确但因将Polkit策略从需管理员认证降级为直接允许,引入了高危的未授权配置篡改漏洞扣60分

■ 【详细分析】

  • 1.语法逻辑 基本正确 ✓

代码移除了 allow_caller.go 及相关引用,修改了 ifc.go 中的鉴权调用,语法和逻辑闭合性正确,编译无误。
潜在问题:无
建议:无

  • 2.代码质量 良好 ✓

移除了复杂的 allowCallerRegistry 机制及相关测试,减少了代码维护成本,配置文件也同步进行了清理,结构清晰。
潜在问题:无
建议:无

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

移除了注册表的加载、持久化和 D-Bus 信号监听,减少了不必要的系统调用和内存开销,性能有所提升。
潜在问题:无
建议:无

  • 4.代码安全 存在1个安全漏洞 ✕

漏洞对比统计:新增漏洞 1 个,减少漏洞 0 个,持平 0 个
本次变更移除了原有的双重鉴权机制,并将 Polkit 策略降级,导致普通用户可绕过认证修改系统全局配置。

  • 安全漏洞1(高危):未授权系统配置篡改 在 misc/polkit-action/org.deepin.dde.locale-helper.policy.in 中,将 <allow_active>auth_admin_keep</allow_active> 修改为 <allow_active>yes</allow_active>。这使得任何处于 active 状态的本地登录用户都可以无需管理员密码认证,直接通过 D-Bus 调用 SetLocaleGenerateLocale 方法,进而修改 /etc/default/locale/etc/locale.gen 等系统级配置文件。攻击者可恶意篡改系统语言环境,影响系统可用性或其他用户的正常使用。——非常重要

  • 建议:将 misc/polkit-action/org.deepin.dde.locale-helper.policy.in 中的 <allow_active>yes</allow_active> 恢复为 <allow_active>auth_admin_keep</allow_active>,或者根据实际业务需求调整为 auth_admin,确保修改系统级配置需要管理员授权。

■ 【改进建议代码示例】

--- a/misc/polkit-action/org.deepin.dde.locale-helper.policy.in
+++ b/misc/polkit-action/org.deepin.dde.locale-helper.policy.in
@@ -12,7 +12,7 @@
     <defaults>
       <allow_any>no</allow_any>
       <allow_inactive>no</allow_inactive>
-      <allow_active>yes</allow_active>
+      <allow_active>auth_admin_keep</allow_active>
     </defaults>
   </action>
 </policyconfig>

@deepin-ci-robot

Copy link
Copy Markdown

@fly602: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
github-pr-review-ci a0597c0 link true /test github-pr-review-ci

Full PR test history. Your PR dashboard.

Details

Instructions 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.

1. Add processStartTime function field to allowCallerRegistry struct.
2. Default to getProcessStartTime in newAllowCallerRegistryWithConfig.
3. Replace direct getProcessStartTime calls with r.processStartTime.
4. Set mock processStartTime in tests that use non-existent PIDs.

Log: Test-only fix; no functional change

Influence:
1. Verify all authorizeRegistrar and addCaller tests pass without /proc access.

fix: 将 getProcessStartTime 改为可 mock 结构体字段,修复测试

1. 在 allowCallerRegistry 中添加 processStartTime 函数字段。
2. newAllowCallerRegistryWithConfig 默认赋值为 getProcessStartTime。
3. authorizeRegistrar 中两处调用改为 r.processStartTime。
4. 测试用例设置 mock 返回固定值,避免依赖 /proc。

Log: 仅测试修复,无功能变更

Influence:
1. 验证所有 authorizeRegistrar 和 addCaller 测试无需 /proc 即可通过。
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