Repository navigation
fix: backport security auth fixes to develop/2500u3 - #1334
Conversation
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)
Reviewer's GuideAPISecure the password-hint and login-reminder D-Bus methods by receiving the caller identity and authorizing access before changing or returning account data.
ImplementationValidate password hints and serialize the config write with the exported-property update to prevent invalid input and concurrent stale writes.
Authorize greeter theme updates, clean up rejected file descriptors, serialize replacements, and safely render theme values into xsettings configuration.
ConfigurationConfigure the greeter polkit action and its authorization policy for theme updates.
TestsCover password-hint validation limits and rejected control characters.
Verify xsettings values cannot inject configuration keys and that missing required DPI data is reported while optional keys remain supported.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
6548ee4
into
linuxdeepin:develop/2500u3
|
This pr force merged! (status: blocked, merge_method: rebase) |
安全问题修复回合到 develop/2500u3
将 master 上已合入的三个安全修复回合到
develop/2500u3:f394c55b6fix: authorize password hint writes(fix: authorize password hint writes #1306)e9f819992fix: authorize GetReminderInfo(fix: authorize GetReminderInfo #1307)def84cf4ffix: authorize greeter theme updates with polkit(fix: authorize greeter theme updates via active local session #1305)对应 USRC 预警:UT-2026-0145(Accounts1 密码提示未授权读写)、UT-2026-0133(Greeter1 登录界面配置未鉴权)。
内容
SetPasswordHint接收 sender 并鉴权(本人免认证、他人需 user-administration),补充入参校验与 PropsMu 保护。GetReminderInfo接收 sender 并鉴权,被拒时不读取 shadow 与 wtmp/btmp。UpdateGreeterQtTheme使用org.deepin.dde.greeter.doAction做 polkit 鉴权;xsettingsd 值拒绝引号/反斜杠/控制字符;FD 拒绝时关闭,更新串行化。验证
go test ./accounts1 ./bin/dde-greeter-setter通过。Summary by Sourcery
Backport authorization protections for account-sensitive operations and greeter theme updates.
Bug Fixes:
Enhancements:
Tests:
Chores: