Skip to content

fix: backport security auth fixes to develop/2500u3 - #1334

Merged
deepin-bot[bot] merged 3 commits into
linuxdeepin:develop/2500u3from
fly602:fix/security-auth-2500u3
Dec 3, 2026
Merged

deepin-bot[bot] merged 3 commits into
linuxdeepin:develop/2500u3from
fly602:fix/security-auth-2500u3

Conversation

@fly602

@fly602 fly602 commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

安全问题修复回合到 develop/2500u3

将 master 上已合入的三个安全修复回合到 develop/2500u3:

对应 USRC 预警:UT-2026-0145(Accounts1 密码提示未授权读写)、UT-2026-0133(Greeter1 登录界面配置未鉴权)。

内容

  1. SetPasswordHint 接收 sender 并鉴权(本人免认证、他人需 user-administration),补充入参校验与 PropsMu 保护。
  2. GetReminderInfo 接收 sender 并鉴权,被拒时不读取 shadow 与 wtmp/btmp。
  3. UpdateGreeterQtTheme 使用 org.deepin.dde.greeter.doAction 做 polkit 鉴权;xsettingsd 值拒绝引号/反斜杠/控制字符;FD 拒绝时关闭,更新串行化。

验证

  • go test ./accounts1 ./bin/dde-greeter-setter 通过。
  • cherry-pick 三个提交无冲突。

Summary by Sourcery

Backport authorization protections for account-sensitive operations and greeter theme updates.

Bug Fixes:

  • Require authorization before password-hint writes and reminder-information reads, while validating password hints and protecting account configuration updates.
  • Require Polkit authorization for greeter theme updates and reject unsafe values that could inject xsettingsd configuration.

Enhancements:

  • Serialize greeter theme and xsettings updates, and report failures when the configuration cannot be updated.

Tests:

  • Add coverage for password-hint validation and xsettings value safety and configuration handling.

Chores:

  • Update the greeter Polkit policy to support the authorization change.

1. SetPasswordHint took no sender and performed no authorization, so any
   local user could rewrite another account's password hint. The hint is
   shown before authentication, so a cross-user write can mislead whoever
   is recovering that account.
2. The method now takes a sender and authorizes it: the account owner
   passes with the change-own-data action without a prompt, other callers
   need user-administration. The greeter, which saves the hint after a
   password change for the selected user, runs as lightdm and is already
   granted user-administration in an active session by the existing polkit
   rule, so that path keeps working.
3. Validate the hint as well: at most 512 characters and no control
   characters, so a caller cannot write an oversized or multi-line value
   into the user config file. An empty hint still clears the old one.
4. Hold PropsMu across the config write and property update. The config
   writer snapshots in-memory fields such as Layout, so releasing the
   config-file lock before updating PasswordHint could allow a concurrent
   SetLayout to persist a stale layout or leave the file and property
   describing different values.

fix: 密码提示写入补鉴权、入参校验与并发保护

1. SetPasswordHint 既不接收 sender 也不鉴权,任意本地用户可改写他人的
   密码提示;提示会在认证前展示,被篡改后会误导正在找回账号的用户。
2. 方法现在接收 sender 并鉴权:账号本人在自己对象上免认证
   (change-own-user-data),其他人需要 user-administration。登录界面
   在改密后保存提示、以 lightdm 运行,既有 polkit 规则已对活跃会话放行
   user-administration,该路径不受影响。
3. 同时校验入参:最长 512 字符且不允许控制字符,避免把超长或多行内容
   写进用户配置文件;空字符串仍按原语义清空提示。
4. 配置写入和属性更新统一持有 PropsMu。配置写入会快照 Layout 等内存
   字段,若在更新 PasswordHint 前释放锁,并发的 SetLayout 可能把旧
   layout 写回,或导致配置文件与 D-Bus 属性不一致。

Log: 用户只能修改自己的密码提示;他人修改需要管理员认证;并发修改不再把旧设置写回。
Influence: 1) 用户 A 对用户 B 的 User 对象调用 SetPasswordHint 应返回授权错误,B 的提示不变;2) 用户 A 修改自己的提示应免弹窗成功,空字符串应清空提示;3) 在登录界面修改密码后保存提示仍应成功,不弹认证框;4) 超过 512 字符或含换行/制表符等控制字符的提示应被拒绝,配置文件不变;5) 并发修改提示或同时修改 Layout 时,配置文件与属性保持一致。
PMS: BUG-379743
(cherry picked from commit f394c55)
1. GetReminderInfo returned the account's login statistics to any caller:
   last and current login time, terminal, source address, the number of
   failed logins since the last successful one, and the shadow ageing
   fields. Nothing in the method checked who asked.
2. It now takes the caller's sender and authorizes it: the account owner
   passes with the change-own-data action without a prompt, other callers
   need user-administration. The legitimate consumer, dde-login-reminder,
   queries its own uid's User object at login, so it keeps working
   without a prompt.

fix: 登录提醒信息补鉴权

1. GetReminderInfo 把登录统计返回给任何调用者:上次与本次登录时间、
   终端、来源地址、上次成功登录以来的失败次数,以及 shadow 老化字段,
   方法内没有任何调用者检查。
2. 现在接收 sender 并鉴权:账号本人在自己对象上免认证
   (change-own-user-data),其他人需要 user-administration。合法调用方
   dde-login-reminder 在登录后查询的是自己 uid 对应的 User 对象,仍可
   免弹窗获取。

Log: 登录记录与失败次数只对账号本人或管理员可见。
Influence: 1) 用户 A 对用户 B 的 User 对象调用 GetReminderInfo 应返回授权错误,不返回任何登录记录;2) 用户 A 查询自己的提醒信息应免弹窗成功,登录后 dde-login-reminder 仍能弹出提醒;3) 管理员通过 polkit 认证后可查询他人信息;4) 被拒时不应读取 shadow 与 wtmp/btmp。
PMS: BUG-379743
(cherry picked from commit e9f8199)
1. Reuse greeter.doAction and make lightdm its action owner so the
   unprivileged service can check callers of other identities.
2. Allow active local sessions without authentication; remote, inactive
   and sessionless callers fall back to allow_any=no.
3. Keep FD cleanup on rejection, serialize theme and xsettings updates,
   and reject theme values that could inject extra xsettingsd keys.

fix: 使用 polkit 鉴权登录界面主题更新

1. 复用 greeter.doAction,并将 lightdm 设为 action owner,使非 root
   服务可以代查其他身份的调用者。
2. 本地活跃会话免认证;远程、非活跃与无会话调用落到 allow_any=no。
3. 拒绝时关闭调用方 FD,主题与 xsettings 更新串行化,并拒绝可能注入
   额外 xsettingsd 键的主题值。

Log: 本地活跃会话可免认证更新共享登录界面主题,远程与无会话调用被拒绝
Influence:
  1. 桌面会话内更新主题无需认证弹窗,qt-theme.ini 与 xsettingsd.conf 正确刷新
  2. SSH 或远程调用返回 access denied,两份配置保持不变
  3. 鉴权失败与 polkit 不可用时调用返回错误且不泄漏 FD
PMS: BUG-379743
(cherry picked from commit def84cf)
@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

API

Secure the password-hint and login-reminder D-Bus methods by receiving the caller identity and authorizing access before changing or returning account data.

  • accounts1/user_ifc.go L1074-1100, L1107-1117

Implementation

Validate password hints and serialize the config write with the exported-property update to prevent invalid input and concurrent stale writes.

  • accounts1/password_hint.go L1-28

Authorize greeter theme updates, clean up rejected file descriptors, serialize replacements, and safely render theme values into xsettings configuration.

  • bin/dde-greeter-setter/manager.go L65-122, L173-187, L194-225 (+5 small edits)

Configuration

Configure the greeter polkit action and its authorization policy for theme updates.

  • misc/polkit-action/org.deepin.dde.greeter.policy L13-15

Tests

Cover password-hint validation limits and rejected control characters.

  • accounts1/password_hint_test.go L1-43

Verify xsettings values cannot inject configuration keys and that missing required DPI data is reported while optional keys remain supported.

  • bin/dde-greeter-setter/manager_test.go L1, L8-9, L51-128

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

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

Hey - I've found 2 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="bin/dde-greeter-setter/manager.go" line_range="162" />
<code_context>

 	// 目录创建由 postinst 脚本处理,这里只负责文件写入
-	xf, err := os.OpenFile(xsettingsFile, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+	xf, err := os.OpenFile(xsettingsPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
 	if err != nil {
-		logger.Warning(err)
</code_context>
<issue_to_address>
**Theme and xsettings become inconsistent**

When an authorized theme lacks valid DPI data or xsettings writing fails, `UpdateGreeterQtTheme` replaces the theme before `updateXSettingsConfigFiles` validates DPI data and finishes writing; `OpenFile` truncates the existing xsettings file, so the error leaves the files describing different states and xsettings partial or empty.

Validate and generate xsettings before replacing either file, then commit the updated files without leaving a mixed pair.

Also at `bin/dde-greeter-setter/manager.go:109`.
</issue_to_address>

### Comment 2
<location path="accounts1/password_hint.go" line_range="23" />
<code_context>
+		return fmt.Errorf("password hint exceeds %d characters", maxPasswordHintLength)
+	}
+	for _, r := range hint {
+		if r < 0x20 || r == 0x7f {
+			return errors.New("password hint contains control characters")
+		}
</code_context>
<issue_to_address>
**Unicode control characters pass validation**

When a hint contains a Unicode C1 control character such as U+0085, `validatePasswordHint` rejects only ASCII C0 characters and DEL, so Unicode control characters pass and a display can render a line-breaking hint across lines, undermining the multiline-input protection.

Reject Unicode control characters using Unicode-aware validation.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread bin/dde-greeter-setter/manager.go Resolved
Comment thread accounts1/password_hint.go Resolved
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, robertkill

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

@fly602

fly602 commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot
deepin-bot Bot merged commit 6548ee4 into linuxdeepin:develop/2500u3 Dec 3, 2026
3 of 5 checks passed
@deepin-bot

deepin-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

This pr force merged! (status: blocked, merge_method: rebase)

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.

3 participants