# GHSA-q324-q795-2q5p: Path traversal when using `preview-docs` when working dir contains files with question mark `?` in name

> Attackers can read arbitrary files via path traversal in openapi-cli preview-docs if local filenames contain question marks.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Local or same network only
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 12 Oct 2021

## What is GHSA-q324-q795-2q5p?

GHSA-q324-q795-2q5p is a path traversal vulnerability in @redocly/openapi-cli, published on 12 Oct 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.

### Official description

### Impact
`preview-docs` command allows path traversal if current working dir contains files with question mark `?` in name and attacker knows the name.

### Patches
It was patched starting from 1.0.0-beta.59

### Workarounds
Do not run openapi-cli preview-docs command in the folder which contains files with question mark `?` in name.

### References
https://github.com/Redocly/openapi-cli/pull/347

### For more information
If you have any questions or comments about this advisory:
* Open an issue in [@redocly/openapi-cli](https://github.com/Redocly/openapi-cli)
* Email us at [security@redocly.com](mailto:security@redocly.com)

## Which versions are affected by GHSA-q324-q795-2q5p?

2 open source packages ship an affected version, including @redocly/openapi-cli.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@redocly/openapi-cli` | npm | All versions | 1.0.0-beta.59 |
| `@redocly/openapi-cli` | npm | All versions | 1.0.0-beta.59 |

## How do I fix GHSA-q324-q795-2q5p?

Upgrade @redocly/openapi-cli to 1.0.0-beta.59 or later.

## Is GHSA-q324-q795-2q5p being exploited?

There is no known exploitation of GHSA-q324-q795-2q5p in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-q324-q795-2q5p and fix it if it is affected.

What it is: GHSA-q324-q795-2q5p is a path traversal vulnerability in @redocly/openapi-cli, published on 12 Oct 2021. It can only be exploited from the same machine or local network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-q324-q795-2q5p in the wild and no public exploit code.

Affected packages and fixed versions:
- @redocly/openapi-cli (npm): affected all versions; fixed in 1.0.0-beta.59
- @redocly/openapi-cli (npm): affected all versions; fixed in 1.0.0-beta.59

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-q324-q795-2q5p/ (Markdown: https://insights.sbomify.com/GHSA-q324-q795-2q5p/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-q324-q795-2q5p

---
From sbomify Insights: https://insights.sbomify.com/GHSA-q324-q795-2q5p/
Summaries are generated and may contain mistakes; the official description above is the record.
