[bug]: Postman import allows path traversal through collection folder names
Is there an existing issue for this?
- I have searched and didn't find similar issue
Current behavior
When importing a Postman collection containing a folder named ../../escaped, Keploy uses the untrusted folder name directly in the output path. As a result, it writes the generated testcase outside the intended <project>/keploy/ directory:
<project-parent>/escaped/tests/test-1.yaml
### Steps to Replicate
1. Create an isolated directory:
```bash
mkdir -p /tmp/keploy-path-repro/project
cd /tmp/keploy-path-repro/projectCreate
malicious.json:{ "info": { "name": "Path traversal reproduction", "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json" }, "item": [ { "name": "../../escaped", "item": [ { "name": "Traversal test", "request": { "method": "GET", "header": [], "url": "https://example.com" }, "response": [ { "name": "OK", "status": "OK", "code": 200, "header": [], "body": "{}" } ] } ] } ] }Import the collection:
keploy import postman --path malicious.jsonVerify that a file was created outside the project directory:
test -f /tmp/keploy-path-repro/escaped/tests/test-1.yaml \ && echo "BUG REPRODUCED: file written outside project"Confirm that the escaped file contains the imported testcase:
cat /tmp/keploy-path-repro/escaped/tests/test-1.yaml
Logs (if any)
Operating system
MacOS
System Info (uname -a)
Darwin Utkarshs-MacBook-Air.local 24.1.0 Darwin Kernel Version 24.1.0: Thu Oct 10 21:05:14 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T8103 arm64
OS Release Info (cat /etc/os-release)
ProductName: macOS ProductVersion: 15.1.1 BuildVersion: 24B91
Docker Info (if applicable)
No
Your Environment
Macbook Local machine
Version
I am using latest
Repository
keploy
What use case were you trying? (optional)
I was importing a Postman collection into Keploy to convert its requests and saved responses into Keploy test cases. I expected every generated testcase to be stored inside the project’s keploy/ directory, regardless of the folder names contained in the collection.
Source: keploy/keploy