Fix header normalization for xlsx #612
Nullify Code
Severity Threshold: 🔵 MEDIUM
1 Potential vulnerability sources found within this repo
🔴 CRITICAL |
🟡 HIGH |
🔵 MEDIUM |
⚪ LOW |
---|---|---|---|
0 | 0 | 1 | 0 |
ID: 01J852XK0D30PAG8PTKH0GZ6HF
Language: TypeScript
Severity: 🔵 MEDIUM
CWE-22
Javascript pathtraversal rule non literal fs filename
The application dynamically constructs file or path information. If the path
information comes from user-supplied input, it could be abused to read sensitive files,
access other users' data, or aid in exploitation to gain further system access.
User input should never be used in constructing paths or files for interacting
with the filesystem. This includes filenames supplied by user uploads or downloads.
If possible, consider hashing user input or using unique values and
use path.normalize
to resolve and validate the path information
prior to processing any file functionality.
Example using path.normalize
and not allowing direct user input:
// User input, saved only as a reference
// id is a randomly generated UUID to be used as the filename
const userData = {userFilename: userSuppliedFilename, id: crypto.randomUUID()};
// Restrict all file processing to this directory only
const basePath = '/app/restricted/';
// Create the full path, but only use our random generated id as the filename
const joinedPath = path.join(basePath, userData.id);
// Normalize path, removing any '..'
const fullPath = path.normalize(joinedPath);
// Verify the fullPath is contained within our basePath
if (!fullPath.startsWith(basePath)) {
console.log("Invalid path specified!");
}
// Process / work with file
// ...
For more information on path traversal issues see OWASP:
https://owasp.org/www-community/attacks/Path_Traversal