Relative Path Traversal vulnerability in fabric-private-chaincode
A command-line argument is passed without sanitisation into a file-open call, so an attacker who controls that argument can open or write arbitrary files. The report claims this could allow creating or replacing files.
Originally disclosed on HackerOne
- Triaged in 34 days
- Disclosed after 36 days
Unsanitized input from os.Args[3] : 75 CLI argument flows into os.OpenFile, where it is used as a path. This may result in a Path Traversal vulnerability and allow an attacker to open arbitrary files.
The following steps of code lines with respective code confirm the issue:
- utils/fabric/peer-cli-assist.src/peer-cli-assist.go
##Data flow - 5 steps in 1 file
- Step (1,2) - Line 75:49 -
os.Args[3], os.Args[3](SOURCE) 1 - 2 [Data is 'tainted' if it comes from an insecure source such as a file, the network, or the user.] - Step (3) - Line 85:71 - `resultPipeName
- Step (4,5) - Line 87:37 -
resultPipeNameos.OpenFile(resultPipeName, os.O_APPEND|os.O_WRONLY, 0644)Line :37 -resultPipeNameLine :25 -os.OpenFile(resultPipeName, os.O_APPEND|os.O_WRONLY, 0644)[the operations that must receive clean data and that you wouldn't want an attacker to be able to manipulate]
References : https://cwe.mitre.org/data/definitions/23.html
Example fixes : Link 1 Link 2 Link 3
Impact
Writing arbitrary files: Allows the attacker to create or replace existing files.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
An attacker could create or replace arbitrary files, but only if they can control the command-line argument.
What the attacker needed
Control over the CLI argument
The fix
The path should be validated or restricted to an intended directory before being passed to os.OpenFile.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A program takes a file path from the command line and uses it directly to open a file. If someone can choose that path, they can point it at any file on the system, not just the intended one. This is called path traversal because the path can 'traverse' outside the intended folder.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.