| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent ac367b3 commit 9a9bed9
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1329,6 +1329,19 @@ changes: | |||
| 1329 | 1329 | This function ensures the correct decodings of percent-encoded characters as | |
| 1330 | 1330 | well as ensuring a cross-platform valid absolute path string. | |
| 1331 | 1331 | ||
| 1332 | + **Security Considerations:** | ||
| 1333 | + | ||
| 1334 | + This function decodes percent-encoded characters, including encoded dot-segments | ||
| 1335 | + (`%2e` as `.` and `%2e%2e` as `..`), and then normalizes the resulting path. | ||
| 1336 | + This means that encoded directory traversal sequences (such as `%2e%2e`) are | ||
| 1337 | + decoded and processed as actual path traversal, even though encoded slashes | ||
| 1338 | + (`%2F`, `%5C`) are correctly rejected. | ||
| 1339 | + | ||
| 1340 | + **Applications must not rely on `fileURLToPath()` alone to prevent directory | ||
| 1341 | + traversal attacks.** Always perform explicit path validation and security checks | ||
| 1342 | + on the returned path value to ensure it remains within expected boundaries | ||
| 1343 | + before using it for file system operations. | ||
| 1344 | + | ||
| 1332 | 1345 | ```mjs | |
| 1333 | 1346 | import { fileURLToPath } from 'node:url'; | |
| 1334 | 1347 | ||
@@ -1384,6 +1397,15 @@ representation of the path, a `Buffer` is returned. This conversion is | |||
| 1384 | 1397 | helpful when the input URL contains percent-encoded segments that are | |
| 1385 | 1398 | not valid UTF-8 / Unicode sequences. | |
| 1386 | 1399 | ||
| 1400 | + **Security Considerations:** | ||
| 1401 | + | ||
| 1402 | + This function has the same security considerations as [`url.fileURLToPath()`][]. | ||
| 1403 | + It decodes percent-encoded characters, including encoded dot-segments | ||
| 1404 | + (`%2e` as `.` and `%2e%2e` as `..`), and normalizes the path. **Applications | ||
| 1405 | + must not rely on this function alone to prevent directory traversal attacks.** | ||
| 1406 | + Always perform explicit path validation on the returned buffer value before | ||
| 1407 | + using it for file system operations. | ||
| 1408 | + | ||
| 1387 | 1409 | ### `url.format(URL[, options])` | |
| 1388 | 1410 | ||
| 1389 | 1411 | <!-- YAML | |
@@ -2014,6 +2036,7 @@ console.log(myURL.origin); | |||
| 2014 | 2036 | [`querystring`]: querystring.md | |
| 2015 | 2037 | [`url.domainToASCII()`]: #urldomaintoasciidomain | |
| 2016 | 2038 | [`url.domainToUnicode()`]: #urldomaintounicodedomain | |
| 2039 | + [`url.fileURLToPath()`]: #urlfileurltopathurl-options | ||
| 2017 | 2040 | [`url.format()`]: #urlformaturlobject | |
| 2018 | 2041 | [`url.href`]: #urlhref | |
| 2019 | 2042 | [`url.parse()`]: #urlparseurlstring-parsequerystring-slashesdenotehost | |
| Back | FazBrowse Home | New Git URL |
0 commit comments