@@ -52,6 +52,10 @@ func RegisterServersEndpoints(api huma.API, pathPrefix string, registry service.
5252 Description : "Get a paginated list of MCP servers from the registry" ,
5353 Tags : []string {"servers" },
5454 }, func (ctx context.Context , input * ListServersInput ) (* Response [apiv0.ServerListResponse ], error ) {
55+ if containsNULByte (input .Cursor ) {
56+ return nil , huma .Error400BadRequest ("Invalid cursor: NUL byte not allowed" )
57+ }
58+
5559 // Build filter from input parameters
5660 filter := & database.ServerFilter {}
5761
@@ -119,12 +123,18 @@ func RegisterServersEndpoints(api huma.API, pathPrefix string, registry service.
119123 if err != nil {
120124 return nil , huma .Error400BadRequest ("Invalid server name encoding" , err )
121125 }
126+ if containsNULByte (serverName ) {
127+ return nil , huma .Error400BadRequest ("Invalid server name: NUL byte not allowed" )
128+ }
122129
123130 // URL-decode the version
124131 version , err := url .PathUnescape (input .Version )
125132 if err != nil {
126133 return nil , huma .Error400BadRequest ("Invalid version encoding" , err )
127134 }
135+ if containsNULByte (version ) {
136+ return nil , huma .Error400BadRequest ("Invalid version: NUL byte not allowed" )
137+ }
128138
129139 var serverResponse * apiv0.ServerResponse
130140 // Handle "latest" as a special version
@@ -160,6 +170,9 @@ func RegisterServersEndpoints(api huma.API, pathPrefix string, registry service.
160170 if err != nil {
161171 return nil , huma .Error400BadRequest ("Invalid server name encoding" , err )
162172 }
173+ if containsNULByte (serverName ) {
174+ return nil , huma .Error400BadRequest ("Invalid server name: NUL byte not allowed" )
175+ }
163176
164177 // Get all versions for this server
165178 servers , err := registry .GetAllVersionsByServerName (ctx , serverName )
@@ -186,3 +199,7 @@ func RegisterServersEndpoints(api huma.API, pathPrefix string, registry service.
186199 }, nil
187200 })
188201}
202+
203+ func containsNULByte (s string ) bool {
204+ return strings .IndexByte (s , 0 ) >= 0
205+ }
0 commit comments