@@ -144,13 +144,11 @@ impl ToolInvocationService {
144144 . route_tool ( session. execution_id , & tool_name)
145145 . await
146146 . map_err ( |e| {
147- SmcpSessionError :: SignatureVerificationFailed ( format ! ( "Routing error: {}" , e) )
147+ SmcpSessionError :: MalformedPayload ( format ! ( "Routing error: {}" , e) )
148148 } ) ?;
149149
150150 let server = self . tool_router . get_server ( server_id) . await . ok_or (
151- SmcpSessionError :: SignatureVerificationFailed (
152- "Server vanished after routing" . to_string ( ) ,
153- ) ,
151+ SmcpSessionError :: MalformedPayload ( "Server vanished after routing" . to_string ( ) ) ,
154152 ) ?;
155153
156154 // 4. Execute based on ExecutionMode (Gateway Retrofit)
@@ -337,7 +335,7 @@ impl ToolInvocationService {
337335
338336 loop {
339337 if attempts >= max_attempts {
340- return Err ( SmcpSessionError :: SignatureVerificationFailed (
338+ return Err ( SmcpSessionError :: JudgeTimeout (
341339 format ! (
342340 "Inner-loop semantic judge '{}' timed out after {} seconds." ,
343341 judge_agent,
@@ -993,7 +991,7 @@ fn sanitize_segment(input: &str) -> String {
993991 return "unversioned" . to_string ( ) ;
994992 }
995993
996- trimmed
994+ let sanitized : String = trimmed
997995 . chars ( )
998996 . map ( |c| {
999997 if c. is_ascii_alphanumeric ( ) || c == '.' || c == '-' || c == '_' {
@@ -1002,7 +1000,19 @@ fn sanitize_segment(input: &str) -> String {
10021000 '_'
10031001 }
10041002 } )
1005- . collect ( )
1003+ . collect ( ) ;
1004+
1005+ // Prevent path traversal patterns after character substitution.
1006+ // Treat empty or traversal-like segments as a safe default.
1007+ if sanitized. is_empty ( )
1008+ || sanitized == "."
1009+ || sanitized == ".."
1010+ || sanitized. contains ( ".." )
1011+ {
1012+ "unversioned" . to_string ( )
1013+ } else {
1014+ sanitized
1015+ }
10061016}
10071017
10081018fn path_to_string ( path : & Path ) -> String {
0 commit comments