File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -227,11 +227,10 @@ function pathIsAbsolute(p: string): boolean {
227227 * @returns true if the path uses UNC extended-length syntax
228228 */
229229export function isWindowsUncExtendedPath ( p : string ) : boolean {
230- if ( process . platform !== 'win32' ) {
231- return false ;
232- }
230+ // Check for Windows UNC extended-length paths on all platforms
231+ // This is defense-in-depth - reject dangerous path patterns regardless of server OS
233232 // Match \\?\ or \\.\ prefixes (extended-length path prefixes)
234- // Character class [?.] matches literal ? or . characters
233+ // In regex: \\\\ matches \\, [?.] matches ? or ., \\ matches \
235234 return / ^ \\ \\ [ ? . ] \\ / . test ( p ) ;
236235}
237236
Original file line number Diff line number Diff line change @@ -209,9 +209,11 @@ describe('Security Utilities', () => {
209209 expect ( isWindowsUncExtendedPath ( '\\\\server\\share' ) ) . toBe ( false ) ;
210210 } ) ;
211211
212- it ( 'should return false on non-Windows platforms' , ( ) => {
212+ it ( 'should detect UNC paths on all platforms (defense-in-depth) ' , ( ) => {
213213 Object . defineProperty ( process , 'platform' , { value : 'linux' } ) ;
214- expect ( isWindowsUncExtendedPath ( '\\\\?\\C:\\Windows' ) ) . toBe ( false ) ;
214+ // UNC extended paths should be detected regardless of platform
215+ expect ( isWindowsUncExtendedPath ( '\\\\?\\C:\\Windows' ) ) . toBe ( true ) ;
216+ // Regular Unix paths should not match
215217 expect ( isWindowsUncExtendedPath ( '/usr/bin' ) ) . toBe ( false ) ;
216218 } ) ;
217219 } ) ;
You can’t perform that action at this time.
0 commit comments