Skip to content

Commit 6041514

Browse files
committed
fix(macos): lock down rejected config snapshots
1 parent af6b642 commit 6041514

3 files changed

Lines changed: 15 additions & 4 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ Docs: https://docs.openclaw.ai
196196
- Discord/threads: return the created thread as partial success when the follow-up initial message fails, so agents do not retry thread creation and create empty duplicate threads. Fixes #48450. Thanks @dahifi.
197197
- Discord/components: consume every button or select in a non-reusable component message after the first authorized click, so single-use panels cannot fire sibling callbacks. Fixes #54227. Thanks @fujiwarakasei.
198198
- macOS/config: preserve existing `gateway.auth` and unrelated config keys during app fallback writes, so dashboard or Talk settings changes cannot strand Control UI clients by dropping persisted auth. Fixes #75631. Thanks @Fuma2013.
199+
- macOS/config: reject stale or destructive app fallback config writes before direct replacement and store rejected payloads as private audit artifacts, so `gateway.mode`, metadata, and secrets are not silently clobbered. Fixes #64973 and #74890. Thanks @Fuma2013.
199200
- Control UI/TUI: keep reconnecting chat sends bound to the same backing session id and let TUI relaunches resume the last selected session, avoiding silent fresh sessions after refresh, reconnect, or terminal restart. Fixes #63195, #68162, and #73546. Thanks @bond260312-cmyk, @zhong18804784882, and @mtuwei.
200201
- Plugins/tools: let plugin manifests declare static tool availability so reply startup skips unavailable plugin tool runtimes instead of importing factories that only return `null`. Thanks @shakkernerd.
201202
- Discord/reactions: skip reaction listener registration when DMs and group DMs are disabled and every configured guild has `reactionNotifications: "off"`, avoiding needless reaction-event queue work. Fixes #47516. Thanks @x4v13r1120.

‎apps/macos/Sources/OpenClaw/OpenClawConfigFile.swift‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,13 +642,20 @@ enum OpenClawConfigFile {
642642
let timestamp = ISO8601DateFormatter().string(from: Date())
643643
let url = configURL.deletingLastPathComponent()
644644
.appendingPathComponent("\(configURL.lastPathComponent).rejected.\(self.configTimestampToken(timestamp))")
645-
guard !FileManager().fileExists(atPath: url.path) else { return url.path }
646-
do {
647-
try data.write(to: url, options: [])
645+
let fileManager = FileManager()
646+
let privatePermissions: NSNumber = 0o600
647+
if fileManager.fileExists(atPath: url.path) {
648+
try? fileManager.setAttributes([.posixPermissions: privatePermissions], ofItemAtPath: url.path)
648649
return url.path
649-
} catch {
650+
}
651+
guard fileManager.createFile(
652+
atPath: url.path,
653+
contents: data,
654+
attributes: [.posixPermissions: privatePermissions])
655+
else {
650656
return nil
651657
}
658+
return url.path
652659
}
653660

654661
private static func observeConfigRead(data: Data, root: [String: Any]?, configURL: URL, valid: Bool) {

‎apps/macos/Tests/OpenClawIPCTests/OpenClawConfigFileTests.swift‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,9 @@ struct OpenClawConfigFileTests {
424424
#expect(blocking.contains("gateway-mode-removed"))
425425
if let rejectedPath = auditRoot?["rejectedPath"] as? String {
426426
#expect(FileManager().fileExists(atPath: rejectedPath))
427+
let attributes = try FileManager().attributesOfItem(atPath: rejectedPath)
428+
let mode = attributes[.posixPermissions] as? NSNumber
429+
#expect(mode?.intValue == 0o600)
427430
} else {
428431
Issue.record("Missing rejected payload path")
429432
}

0 commit comments

Comments
 (0)