Skip to content

Commit 8473ecb

Browse files
Require HTTPS for CDN requests (#15660)
## Summary This should arguably enforce same-realm (as the API), but this is a good guardrail for now.
1 parent ad35d12 commit 8473ecb

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

crates/uv-auth/src/pyx.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ fn is_known_url(url: &Url, api: &DisplaySafeUrl, cdn: &str) -> bool {
539539
//
540540
// For example, if URL is on `files.astralhosted.com` and the CDN domain is
541541
// `astralhosted.com`, consider it known.
542-
if matches_domain(url, cdn) {
542+
if matches!(url.scheme(), "https") && matches_domain(url, cdn) {
543543
return true;
544544
}
545545

@@ -603,6 +603,13 @@ mod tests {
603603
cdn_domain
604604
));
605605

606+
// CDN on HTTP.
607+
assert!(!is_known_url(
608+
&Url::parse("http://astralhosted.com/packages/").unwrap(),
609+
&api_url,
610+
cdn_domain
611+
));
612+
606613
// Unknown domain.
607614
assert!(!is_known_url(
608615
&Url::parse("https://pypi.org/simple/").unwrap(),

0 commit comments

Comments
 (0)