fix(connector-fabric): uncontrolled data used in path expression #1909
Labels
dependencies
Pull requests that update a dependency file
Fabric
Security
Related to existing or potential security vulnerabilities
https://github.com/hyperledger/cactus/security/code-scanning/40
Uncontrolled data used in path expression
Tool
CodeQL
Rule ID
js/path-injection
Query
View source
Accessing files using paths constructed from user-controlled data can allow an attacker to access unexpected resources. This can result in sensitive information being revealed or deleted, or an attacker being able to influence behavior by modifying unexpected files.
Recommendation
Validate user input before using it to construct a file path, either using an off-the-shelf library like the sanitize-filename npm package, or by performing custom validation.
Ideally, follow these rules:
Example
In the first example, a file name is read from an HTTP request and then used to access a file. However, a malicious user could enter a file name which is an absolute path, such as "/etc/passwd".
In the second example, it appears that the user is restricted to opening a file within the "user" home directory. However, a malicious user could enter a file name containing special characters. For example, the string "../../etc/passwd" will result in the code reading the file located at "/home/user/../../etc/passwd", which is the system's password file. This file would then be sent back to the user, giving them access to all the system's passwords.
References
The text was updated successfully, but these errors were encountered: