Apps: harden network whitelist and SSRF-guard app downloads (M: wildcard hosts, SSRF) - #800
Closed
Rigidity wants to merge 1 commit into
Closed
Apps: harden network whitelist and SSRF-guard app downloads (M: wildcard hosts, SSRF)#800Rigidity wants to merge 1 commit into
Rigidity wants to merge 1 commit into
Conversation
Reject match-all wildcard hosts (bare "*", "*:443", embedded wildcards) in the network whitelist so an app manifest cannot turn connect-src into an effectively open policy. Guard app install/update/icon downloads against SSRF: resolve and validate the target address before connecting (rejecting loopback, private, link-local, CGNAT, and other non-public ranges), pin the connection to the vetted addresses to prevent DNS rebinding, and follow redirects manually so every hop is re-validated. Loopback stays allowed only for explicit localhost URLs used by the local dev flow.
Contributor
|
Fixed: 8c4cfa4 |
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.
Part of the security review follow-ups for #785 (Medium severity, network theme). Targets the
appsmirror branch.Findings addressed
M: Bare
*host allowed in network whitelist (types/network.rs)A manifest could request
https://*, which CSP treats as match-all — effectively an openconnect-srchiding behind an innocuous-looking whitelist entry. Wildcards are now only accepted as a single leading label (*.example.com); bare*,*:443,*., embedded (a*.example.com) and nested (*.*.example.com) wildcards are rejected, with tests.M: SSRF on URL install/update (
lifecycle/snapshot.rs,types/app/view/common.rs)reqwest::getwas used directly on user-supplied app URLs with no address blocklist and default redirect following, so an install URL (or a redirect from it) could reach internal services such as cloud metadata endpoints or LAN hosts. All app-related downloads (manifest, snapshot files, remote icons) now go through a guarded fetch insecurity/net.rsthat:169.254.169.254), CGNAT, unique-local, unspecified, broadcast, documentation, multicast, and IPv4-mapped-IPv6 equivalentsresolve_to_addrs) so DNS rebinding between validation and connect is not possiblehttp://localhost/127.0.0.1/::1), preserving the supported local dev install flowNotes
cargo check,cargo clippy --all-targets, and the new unit tests pass locally; relying on CI for the full build.Note
Medium Risk
Security-sensitive networking on install/update and icon fetch paths; behavior changes could block legitimate URLs or mis-resolve DNS, though loopback dev flow is preserved.
Overview
Hardens user-supplied app URL fetches so installs, snapshot downloads, and remote icons no longer use unguarded
reqwest::get. Newget_with_ssrf_guardinsecurity/net.rsresolves each hop, blocks private/link-local/metadata-style addresses, pins DNS withresolve_to_addrs, follows redirects manually (max 5) with re-validation, and allowshttponly for explicit loopback hosts for local dev.Tightens manifest network whitelist hosts so CSP cannot be widened to match-all: only
*.example.com-style leading wildcards are allowed; bare*,*:443,*., and embedded/nested*forms are rejected, with new tests.tokiogains thenetfeature for async host lookup.Reviewed by Cursor Bugbot for commit d46113a. Bugbot is set up for automated code reviews on this repo. Configure here.