Skip to content

Commit 9be8811

Browse files
re2zerodeepin-bot[bot]
authored andcommitted
chore: harden service security
- Fix CMake variable name from CVERSION to VERSION in debian/rules - Enhance deepin-devicecontrol service with comprehensive sandboxing: - Apply strict resource limits (2G memory, IO weight 200) - Enable filesystem protection (ProtectSystem, ProtectHome, PrivateTmp) - Restrict executable paths and set write permissions selectively - Add security restrictions (NoNewPrivileges, MemoryDenyWriteExecute) - Define specific accessible and inaccessible system paths - Set capability bounding set and ambient capabilities - Adjust scheduling priority and OOM score Log: harden service security.
1 parent 9ac43d4 commit 9be8811

3 files changed

Lines changed: 56 additions & 3 deletions

File tree

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ CMakeLists.txt.user*
4747
.cursor
4848
.specstory
4949
.cursorindexingignore
50+
.claude_settings.json
51+
# Auto Claude data directory
52+
.auto-claude/
53+
54+
# vs code
55+
.vscode/
5056

5157
# debian
5258
debian/.debhelper/

debian/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ override_dh_auto_configure:
3232
-DCMAKE_BUILD_TYPE=Release \
3333
-DCMAKE_INSTALL_PREFIX=/usr \
3434
-DAPP_VERSION=$(DEB_VERSION_UPSTREAM) \
35-
-DCVERSION=$(DEB_VERSION_UPSTREAM) \
35+
-DVERSION=$(DEB_VERSION_UPSTREAM) \
3636
-DQT_DIR=$(QT_DIR)
3737
%:
3838
dh $@ --parallel

deepin-devicemanager-server/deepin-devicecontrol/deepin-devicecontrol.service

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,55 @@ Type=dbus
66
BusName=org.deepin.DeviceControl
77
User=root
88
ExecStart=/usr/bin/deepin-devicecontrol
9-
CapabilityBoundingSet=~CAP_NET_RAW
10-
MemoryMax=8G
9+
StandardOutput=journal
10+
MemoryMax=2G
11+
IOWeight=200
12+
ProtectSystem=full
13+
ProtectHome=true
14+
ProtectProc=invisible
15+
PrivateTmp=true
16+
PrivateDevices=false
17+
PrivateIPC=true
18+
ProtectClock=true
19+
ProtectKernelTunables=true
20+
ProtectKernelModules=false
21+
NoNewPrivileges=true
22+
MemoryDenyWriteExecute=true
23+
RestrictSUIDSGID=true
24+
LimitMEMLOCK=infinity
25+
CapabilityBoundingSet=CAP_SYS_ADMIN CAP_SYS_MODULE CAP_SYS_PTRACE CAP_DAC_OVERRIDE CAP_FOWNER CAP_SYS_BOOT CAP_KILL CAP_NET_BIND_SERVICE
26+
AmbientCapabilities=CAP_SYS_ADMIN CAP_SYS_MODULE CAP_SYS_PTRACE CAP_DAC_OVERRIDE CAP_FOWNER CAP_SYS_BOOT CAP_KILL CAP_NET_BIND_SERVICE
27+
ExecPaths=/usr/bin /usr/sbin /bin /sbin /lib /lib64 /usr/lib /usr/lib64
28+
NoExecPaths=/tmp /var/tmp /home /root
29+
ReadWritePaths=/var/lib/deepin-devicemanager
30+
ReadWritePaths=/var/log
31+
ReadWritePaths=/var/cache
32+
ReadWritePaths=/tmp
33+
ReadWritePaths=/var/tmp
34+
ReadWritePaths=/etc/modprobe.d
35+
ReadWritePaths=/run
36+
ReadOnlyPaths=/sys
37+
ReadOnlyPaths=/proc
38+
ReadOnlyPaths=/etc
39+
ReadOnlyPaths=/usr
40+
ReadOnlyPaths=/lib
41+
ReadOnlyPaths=/boot
42+
InaccessiblePaths=-/etc/shadow
43+
InaccessiblePaths=-/etc/NetworkManager/system-connections/
44+
InaccessiblePaths=-/etc/pam.d/
45+
InaccessiblePaths=-/etc/security/
46+
InaccessiblePaths=-/etc/selinux/
47+
InaccessiblePaths=-/etc/deepin-elf-verify/
48+
InaccessiblePaths=-/etc/filearmor.d/
49+
InaccessiblePaths=-/etc/crypttab
50+
InaccessiblePaths=-/etc/fstab
51+
InaccessiblePaths=-/sysroot/ostree/repo/
52+
InaccessiblePaths=-/persistent/ostree/repo/
53+
InaccessiblePaths=-/usr/share/uadp
54+
InaccessiblePaths=-/etc/sudoers
55+
InaccessiblePaths=-/etc/sudoers.d
56+
OOMScoreAdjust=-500
57+
Nice=-5
1158

1259
[Install]
1360
WantedBy=multi-user.target

0 commit comments

Comments
 (0)