fix(ios): force tls for non-loopback manual gateway hosts#21969
Merged
fix(ios): force tls for non-loopback manual gateway hosts#21969
Conversation
Comment on lines
7
to
10
| import Foundation | ||
| import Darwin | ||
| import OpenClawKit | ||
| import Network |
Contributor
There was a problem hiding this comment.
Import ordering nit
Darwin and the surrounding imports are not in alphabetical order — Darwin should come before EventKit/Foundation, and Network should come before OpenClawKit. The list was already slightly out of order before this PR, but adding Darwin between Foundation and OpenClawKit extends the inconsistency.
Suggested change
| import Foundation | |
| import Darwin | |
| import OpenClawKit | |
| import Network | |
| import Foundation | |
| import Darwin | |
| import Network | |
| import OpenClawKit |
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/ios/Sources/Gateway/GatewayConnectionController.swift
Line: 7-10
Comment:
**Import ordering nit**
`Darwin` and the surrounding imports are not in alphabetical order — `Darwin` should come before `EventKit`/`Foundation`, and `Network` should come before `OpenClawKit`. The list was already slightly out of order before this PR, but adding `Darwin` between `Foundation` and `OpenClawKit` extends the inconsistency.
```suggestion
import Foundation
import Darwin
import Network
import OpenClawKit
```
<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>
How can I resolve this? If you propose a fix, please make it concise.7a8ccbe to
9fb39f5
Compare
|
Thanks for keeping scope tight and adding the regression tests |
Contributor
Author
6 tasks
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 1, 2026
…1969) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 9fb39f5 Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com> Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com> Reviewed-by: @mbelinky (cherry picked from commit 8fa46d7) # Conflicts: # apps/ios/Sources/Gateway/GatewayConnectionController.swift # apps/ios/Tests/GatewayConnectionSecurityTests.swift
hughdidit
pushed a commit
to hughdidit/DAISy-Agency
that referenced
this pull request
Mar 3, 2026
…1969) Merged via /review-pr -> /prepare-pr -> /merge-pr. Prepared head SHA: 9fb39f5 Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com> Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com> Reviewed-by: @mbelinky (cherry picked from commit 8fa46d7) # Conflicts: # apps/ios/Sources/Gateway/GatewayConnectionController.swift # apps/ios/Tests/GatewayConnectionSecurityTests.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary\n- force TLS for manual gateway hosts that are not true loopback\n- keep .ts.net default-port behavior unchanged\n- harden loopback detection to avoid prefix-bypass hosts like 127.attacker.example\n- add gateway security tests for manual TLS behavior and default port behavior\n\n## Why\nThis supersedes the iOS part of #21441 with a tighter loopback matcher and focused scope.
Greptile Summary
This PR hardens iOS manual gateway connections by forcing TLS for all non-loopback hosts. It introduces a robust
isLoopbackHostcheck usinginet_pton(preventing hostname prefix-bypass attacks like127.attacker.example), addsresolveManualUseTLSto centralize the TLS decision, and consistently applies it across all three manual-connection code paths (connectManual,maybeAutoConnectmanual branch, andmaybeAutoConnectlast-known branch). The existing.ts.netdefault-port logic (shouldForceTLS) is preserved unchanged for port resolution only.127.0.0.0/8), IPv6 (::1), IPv4-mapped IPv6 (::ffff:127.x.x.x),localhost,0.0.0.0,::, bracket-wrapped addresses, and zone IDsshouldForceTLS(.ts.netdetection) is retained solely for theresolveManualPortdefault-port logicConfidence Score: 5/5
inet_ptonfor robust IP parsing, preventing hostname prefix-bypass attacks. All three manual-connection code paths are consistently updated. The existing.ts.netdefault-port behavior is preserved. New tests cover the key security invariants including edge cases. No logic errors or regressions detected.Last reviewed commit: 7a8ccbe