From e0a21061edd194bbc631afc06c05b5a0df83bc3b Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 06:10:29 -0600 Subject: [PATCH] fix(id): reject dot segments in app manifest web route/socket (#5427) --- pkgs/id/src/app_manifest.rs | 45 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/pkgs/id/src/app_manifest.rs b/pkgs/id/src/app_manifest.rs index 4c5918c0f0..432b49db7b 100644 --- a/pkgs/id/src/app_manifest.rs +++ b/pkgs/id/src/app_manifest.rs @@ -59,8 +59,10 @@ //! `is_safe_web_path` now rejects empty segments, so route `/` //! (no non-empty segment), a trailing slash (`/app/`), and //! doubled separators (`/a//b`) all fail the manifest gate for -//! `route` and `socket` alike. `/` is additionally a -//! host-registered route (disposition 6). Ordinary spellings +//! `route` and `socket` alike. Dot segments are rejected on the +//! same rule (#5427): `/a/./b`, `/./a`, and `/a/.` normalize onto +//! other paths, so they are alternate spellings, not new routes. +//! `/` is additionally a host-registered route (disposition 6). Ordinary spellings //! (`/tic-tac-toe`, `/ws/world`) are unchanged. //! 4. **App-`id` uniqueness.** Structural, no extra check added: //! `app.id` must equal the folder (entry) name, and one @@ -261,12 +263,12 @@ pub fn parse_app_manifest(source: &str, folder_name: &str) -> Result bool { // segment, so `/` itself, a trailing slash, and doubled // separators are rejected, not just traversal segments. && !path.split('/').skip(1).any(|segment| segment.is_empty()) + // Dot segments (#5427): a `.` segment is the remaining RFC 3986 + // dot segment -- `/a/./b`, `/./a`, and `/a/.` pass the checks + // above but normalize onto `/a/b`, `/a`, and `/a/`, so one + // normalized path would pass as two distinct routes/sockets + // past the exact-string uniqueness checks downstream. + && !path.split('/').skip(1).any(|segment| segment == ".") } /// One consistent list-entry rule for manifest string lists @@ -581,6 +589,35 @@ route = "/tic-tac-toe" assert!(error.to_string().contains("interfaces.web.socket")); } + #[test] + fn test_web_route_dot_segments_are_rejected() { + // #5427: a `.` segment is an alternate spelling of the path + // without it (RFC 3986 remove_dot_segments), so it fails the + // shape rule for route and socket alike, while a dotted name + // that is not a whole segment stays legal. + for route in ["/./tic-tac-toe", "/tic-tac-toe/./x", "/tic-tac-toe/."] { + let source = + MANIFEST.replace("route = \"/tic-tac-toe\"", &format!("route = {route:?}")); + let error = parse_app_manifest(&source, "tic-tac-toe").unwrap_err(); + assert!( + error.to_string().contains("interfaces.web.route"), + "route {route:?} rejection names the field: {error:#}" + ); + } + let dot_socket = MANIFEST.replace( + "route = \"/tic-tac-toe\"", + "route = \"/tic-tac-toe\"\nsocket = \"/ws/./world\"", + ); + let error = parse_app_manifest(&dot_socket, "tic-tac-toe").unwrap_err(); + assert!(error.to_string().contains("interfaces.web.socket")); + + let dotted_names = MANIFEST.replace( + "route = \"/tic-tac-toe\"", + "route = \"/tic-tac-toe\"\nsocket = \"/ws/world.min\"", + ); + assert!(parse_app_manifest(&dotted_names, "tic-tac-toe").is_ok()); + } + #[test] fn checked_in_tic_tac_toe_manifest_remains_valid() { let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("apps/tic-tac-toe/app.toml");