Skip to content

fix: remove unsafe Bluetooth D-Bus exposure - #1244

Open
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/remove-bluetooth-sensitive-dbus
Open

fix: remove unsafe Bluetooth D-Bus exposure#1244
yixinshark wants to merge 1 commit into
linuxdeepin:masterfrom
yixinshark:fix/remove-bluetooth-sensitive-dbus

Conversation

@yixinshark

@yixinshark yixinshark commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Pms: BUG-370875, BUG-370897

  • Remove BluetoothGetDeviceTechnologies and its path-based file access from the system daemon.
  • Keep DebugInfo compatible while returning no adapter or device data.
  • Preserve the D-Bus method signature for existing callers.

Summary by Sourcery

Remove unsafe Bluetooth data exposure while maintaining compatibility for existing D-Bus clients.

Bug Fixes:

  • Remove the unsafe Bluetooth device-technology D-Bus exposure and path-based file access from the system daemon.
  • Prevent Bluetooth debug output from exposing adapter and device details while preserving D-Bus compatibility.

Enhancements:

  • Retain the DebugInfo method with its existing signature for callers while returning an empty snapshot.

Tests:

  • Add coverage confirming Bluetooth DebugInfo returns no details.

Remove the path-based BluetoothGetDeviceTechnologies method from the system daemon and keep DebugInfo compatible while returning no adapter or device data.

Pms: BUG-370875, BUG-370897

删除系统守护进程中存在路径拼接风险的 BluetoothGetDeviceTechnologies 接口,并保留 DebugInfo 的 D-Bus 兼容签名但不再返回适配器和设备敏感信息。

Change-Id: I4b9e1a61c3c1cfd5245ca7f7ed97a6ff8097e4cb
@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

Removes the unsafe BluetoothGetDeviceTechnologies D-Bus API and its path-based access from the system daemon, while preserving DebugInfo method compatibility by returning an empty snapshot and testing that behavior.

File-Level Changes

Change Details Files
Remove the system daemon’s Bluetooth technology lookup and its path-based file access.
  • Delete the Bluetooth implementation, tests, and fixture data.
  • Unregister BluetoothGetDeviceTechnologies from the daemon’s exported D-Bus methods.
  • Eliminate the daemon-side exposure of device technology information.
bin/dde-system-daemon/bluetooth.go
bin/dde-system-daemon/bluetooth_test.go
bin/dde-system-daemon/exported_methods_auto.go
bin/dde-system-daemon/testdata/doBluetoothGetDeviceTechnologies/info1
Retain DebugInfo as a D-Bus-compatible method while returning an empty result.
  • Keep the existing method signature on both Bluetooth interfaces.
  • Stop serializing or returning adapter and device state.
  • Add coverage confirming the system implementation returns an empty string without an error.
bluetooth1/bluetooth_ifc.go
system/bluetooth1/bluetooth_ifc.go
system/bluetooth1/bluetooth_ifc_test.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

@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 1 issue

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

## Individual Comments

### Comment 1
<location path="bin/dde-system-daemon/exported_methods_auto.go" line_range="12-16" />
<code_context>
 func (v *Daemon) GetExportedMethods() dbusutil.ExportedMethods {
 	return dbusutil.ExportedMethods{
-		{
-			Name:    "BluetoothGetDeviceTechnologies",
-			Fn:      v.BluetoothGetDeviceTechnologies,
-			InArgs:  []string{"adapter", "device"},
-			OutArgs: []string{"technologies"},
-		},
 		{
 			Name:   "ClearTty",
</code_context>
<issue_to_address>
**🚨 issue (security):** Removing the D-Bus registration does not remove the underlying path-based Bluetooth technology reader: `device.getTechnologies` and `doGetDeviceTechnologies` remain in the system daemon and still read caller-derived filenames through `KeyFile.LoadFromFile`. The unsafe code is therefore still present and can be re-exposed by any remaining or future internal call.

**Triggers:** When code in the system daemon invokes the retained `getTechnologies` helper.

**Suggested fix:** Delete the unused `device.getTechnologies` and `doGetDeviceTechnologies` implementations, along with the now-unneeded path/file imports and constants.
</issue_to_address>

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

Comment on lines -12 to -16
Name: "BluetoothGetDeviceTechnologies",
Fn: v.BluetoothGetDeviceTechnologies,
InArgs: []string{"adapter", "device"},
OutArgs: []string{"technologies"},
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚨 issue (security): Removing the D-Bus registration does not remove the underlying path-based Bluetooth technology reader: device.getTechnologies and doGetDeviceTechnologies remain in the system daemon and still read caller-derived filenames through KeyFile.LoadFromFile. The unsafe code is therefore still present and can be re-exposed by any remaining or future internal call.

Triggers: When code in the system daemon invokes the retained getTechnologies helper.

Suggested fix: Delete the unused device.getTechnologies and doGetDeviceTechnologies implementations, along with the now-unneeded path/file imports and constants.

@deepin-bot

deepin-bot Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

TAG Bot

New tag: 6.1.106
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #1246

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.

1 participant