react-admin icon indicating copy to clipboard operation
react-admin copied to clipboard

Upgrade to react-router(-dom) 7.5.2 due to CVE-2025-43865 breaks custom routes

Open sanderino666 opened this issue 1 year ago • 5 comments

Our current react admin app (version 5.7.4) uses react-router and react-router-dom version 7.1.3.

Last week https://nvd.nist.gov/vuln/detail/CVE-2025-43865 has been reported and as a result, we are trying to upgrade to version 7.5.2.

This is our <Admin> structure:

<Admin
	layout={MainLayout}
	authProvider={authProvider}
	i18nProvider={i18nProvider}
	loginPage={false}
	dataProvider={dataProvider}
	darkTheme={defaultDarkTheme}
	dashboard={Dashboard}
>
	<Resource name="customers" {...customers} recordRepresentation="name"/>
	<Resource name="resources" {...resources} recordRepresentation="name"/>
	<Resource name="orders" {...orders} />
	<Resource name="stock" {...stock} />
	<Resource name="persons" {...persons} />
	<Resource name="vehicles" {...vehicles} />
	<Resource name="management/users" {...users} />
	<Resource name="management/teams" {...teams} />
	<Resource name="settings" {...settings}></Resource>
	<CustomRoutes>
		<Route path="/planner" element={<Planner/>}/>,
		<Route path="/weekplanning" element={<WeekPlanner/>}/>,
	</CustomRoutes>
</Admin>

After bumping the version of react-router and dom, the following error appears:

[Route] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>


    at Routes (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4734:3)
    at Suspense (<anonymous>)
    at ErrorBoundary (http://localhost:3000/node_modules/.vite/deps/chunk-W2MBOQYV.js?v=5f94f09d:5455:5)
    at div (<anonymous>)
    at main (<anonymous>)
    at div (<anonymous>)
    at div (<anonymous>)
    at RaLayout-root (http://localhost:3000/node_modules/.vite/deps/chunk-BLQV34CV.js?v=5f94f09d:1349:45)
    at Layout (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:71739:20)
    at MainLayout (http://localhost:3000/src/components/layout/MainLayout.tsx:26:40)
    at RenderedRoute (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4097:26)
    at Routes (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4734:3)
    at CoreAdminRoutes (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:18458:3)
    at RenderedRoute (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4097:26)
    at Routes (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4734:3)
    at ErrorBoundary (http://localhost:3000/node_modules/.vite/deps/chunk-W2MBOQYV.js?v=5f94f09d:5455:5)
    at CoreAdminUI (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:18553:43)
    at CssBaseline (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:41212:17)
    at AdminUI (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:84601:18)
    at DefaultPropsProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:24539:3)
    at RtlProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:24515:3)
    at ThemeProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:24471:5)
    at ThemeProvider2 (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:24622:5)
    at ThemeProviderNoVars (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:27708:10)
    at ThemeProvider3 (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:27770:3)
    at ThemeProvider4 (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:68765:23)
    at ResourceDefinitionContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6933:18)
    at UndoableMutationsContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:15594:23)
    at NotificationContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6283:23)
    at I18nContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6372:18)
    at RenderedRoute (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4097:26)
    at RenderErrorBoundary (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4056:5)
    at DataRoutes (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4629:3)
    at Router (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4677:13)
    at RouterProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:4459:3)
    at RouterProvider2 (<anonymous>)
    at InternalRouter (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6669:23)
    at BasenameContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6648:23)
    at AdminRouter (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6654:18)
    at QueryClientProvider (http://localhost:3000/node_modules/.vite/deps/chunk-TNDI3JRZ.js?v=5f94f09d:2804:3)
    at PreferencesEditorContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:17617:23)
    at StoreContextProvider (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:6169:20)
    at CoreAdminContext (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:17668:28)
    at AdminContext (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:84635:21)
    at Admin (http://localhost:3000/node_modules/.vite/deps/react-admin.js?v=fe271de9:84866:28)
    at APIProvider (http://localhost:3000/node_modules/.vite/deps/@vis__gl_react-google-maps.js?v=d47e5c0f:295:5)
    at App (http://localhost:3000/src/App.tsx?t=1745830040540:50:47)

When we remove <CustomRoutes>, the app works as expected (which a working custom route of course).

sanderino666 avatar Apr 28 '25 09:04 sanderino666

Is it possible that you have more than one react-router in your dependencies?

fzaninotto avatar Apr 28 '25 09:04 fzaninotto

Ran the command below but I don't see any other react-routers installed.

$ yarn info --name-only
├─ @aws-sdk/types@npm:3.775.0
├─ @eslint/eslintrc@npm:3.3.1                                                                                                                                                                                                                       
├─ @eslint/js@npm:9.25.1                                                                                                                                                                                                                            
├─ @js-joda/core@npm:5.6.5                                                                                                                                                                                                                          
├─ @mui/icons-material@npm:7.0.2                                                                                                                                                                                                                    
├─ @mui/material@npm:7.0.2                                                                                                                                                                                                                          
├─ @mui/x-charts@npm:8.1.0                                                                                                                                                                                                                          
├─ @mui/x-date-pickers@npm:8.1.0                                                                                                                                                                                                                    
├─ @tanstack/react-query-devtools@npm:5.61.0                                                                                                                                                                                                        
├─ @tanstack/react-query@npm:5.61.0                                                                                                                                                                                                                 
├─ @types/lodash@npm:4.17.16                                                                                                                                                                                                                        
├─ @types/node@npm:22.15.3                                                                                                                                                                                                                          
├─ @types/react-beautiful-dnd@npm:13.1.8                                                                                                                                                                                                            
├─ @types/react-dom@npm:19.1.2                                                                                                                                                                                                                      
├─ @types/react@npm:19.1.2                                                                                                                                                                                                                          
├─ @typescript-eslint/eslint-plugin@npm:8.31.0                                                                                                                                                                                                      
├─ @typescript-eslint/parser@npm:8.31.0                                                                                                                                                                                                             
├─ @uidotdev/usehooks@npm:2.4.1                                                                                                                                                                                                                     
├─ @vis.gl/react-google-maps@npm:1.5.2                                                                                                                                                                                                              
├─ @vitejs/plugin-react@npm:4.4.1                                                                                                                                                                                                                   
├─ aws-amplify@npm:6.14.3                                                                                                                                                                                                                           
├─ dayjs@npm:1.11.13                                                                                                                                                                                                                                
├─ depcheck@npm:1.4.7                                                                                                                                                                                                                               
├─ eslint-config-prettier@npm:10.1.2                                                                                                                                                                                                                
├─ eslint-plugin-react@npm:7.37.5                                                                                                                                                                                                                   
├─ eslint@npm:9.25.1                                                                                                                                                                                                                                
├─ globals@npm:16.0.0                                                                                                                                                                                                                               
├─ jwt-decode@npm:4.0.0                                                                                                                                                                                                                             
├─ lodash@npm:4.17.21                                                                                                                                                                                                                               
├─ prettier@npm:3.5.3                                                                                                                                                                                                                               
├─ ra-core@npm:5.7.4                                                                                                                                                                                                                                
├─ ra-data-json-server@npm:5.7.4                                                                                                                                                                                                                    
├─ ra-i18n-polyglot@npm:5.7.4                                                                                                                                                                                                                       
├─ ra-input-rich-text@npm:5.7.4                                                                                                                                                                                                                     
├─ ra-language-dutch@npm:4.6.1                                                                                                                                                                                                                      
├─ ra-ui-materialui@npm:5.7.4                                                                                                                                                                                                                       
├─ react-admin-color-picker@npm:1.0.3                                                                                                                                                                                                               
├─ react-admin@npm:5.7.4                                                                                                                                                                                                                            
├─ react-beautiful-dnd@npm:13.1.1                                                                                                                                                                                                                   
├─ react-device-detect@npm:2.2.3                                                                                                                                                                                                                    
├─ react-dom@npm:19.1.0                                                                                                                                                                                                                             
├─ react-ga4@npm:2.1.0                                                                                                                                                                                                                              
├─ react-geocode@npm:2.0.1                                                                                                                                                                                                                          
├─ react-hook-form@npm:7.53.0                                                                                                                                                                                                                       
├─ react-is@npm:19.1.0                                                                                                                                                                                                                              
├─ react-router-dom@npm:7.5.2                                                                                                                                                                                                                       
├─ react-router@npm:7.5.2                                                                                                                                                                                                                           
├─ react-zoom-pan-pinch@npm:3.7.0                                                                                                                                                                                                                   
├─ react@npm:19.1.0                                                                                                                                                                                                                                 
├─ test-admin@workspace:.                                                                                                                                                                                                                           
├─ typescript@patch:typescript@npm%3A5.8.3#optional!builtin<compat/typescript>::version=5.8.3&hash=5786d5                                                                                                                                           
├─ use-debounce@npm:10.0.4                                                                                                                                                                                                                          
└─ vite@npm:6.3.3

sanderino666 avatar Apr 28 '25 16:04 sanderino666

Hmmm, I think you are right actually. I added this:

"resolutions": {
    "react-router": "7.5.2",
    "react-router-dom": "7.5.2"
  },

And now I don't get the error.

sanderino666 avatar Apr 28 '25 16:04 sanderino666

So it doesn't seem to be a react-admin problem, rather a deduplication problem with your package manager. I'm closing this issue, feel free to reopen it if you have new elements.

fzaninotto avatar Apr 28 '25 16:04 fzaninotto

Agreed, thanks for your help!

sanderino666 avatar Apr 28 '25 16:04 sanderino666