Monitor vulnerabilities like this one.
Sign up free to get alerted when software you use is affected.
5.9
Hono: Malicious Files Can Be Written Outside the Output Directory
GHSA-xf4j-xp2r-rqqx
CVE-2026-39408
GHSA-xf4j-xp2r-rqqx
Summary
A security issue affects the Hono framework, allowing attackers to write files outside the intended output directory during static site generation. This could lead to unintended files being overwritten, affecting generated artifacts, or impacting deployment. To mitigate this, ensure that values passed to ssgParams are sanitized or validated to prevent path traversal attacks.
What to do
- Update yusukebe hono to version 4.12.12.
Affected software
| Vendor | Product | Affected versions | Fix available |
|---|---|---|---|
| yusukebe | hono | > 4.0.0 , <= 4.12.12 | 4.12.12 |
| yusukebe | hono | > 4.0.0 , <= 4.12.11 | 4.12.12 |
Original title
Hono: Path traversal in toSSG() allows writing files outside the output directory
Original description
## Summary
A path traversal issue in `toSSG()` allows files to be written outside the configured output directory during static site generation. When using dynamic route parameters via `ssgParams`, specially crafted values can cause generated file paths to escape the intended output directory.
## Details
The static site generation process creates output files based on route paths derived from application routes and parameters. When `ssgParams` is used to provide values for dynamic routes, those values are used to construct output file paths. If these values contain traversal sequences (e.g. `..`), the resulting output path may resolve outside the configured output directory. As a result, files may be written to unintended locations instead of being confined within the specified output directory.
For example:
```ts
import { Hono } from 'hono'
import { toSSG, ssgParams } from 'hono/ssg'
const app = new Hono()
app.get('/:id', ssgParams([{ id: '../pwned' }]), (c) => {
return c.text('pwned')
})
toSSG(app, fs, { dir: './static' })
```
In this case, the generated output path may resolve outside `./static`, resulting in a file being written outside the intended output directory.
## Impact
An attacker who can influence values passed to `ssgParams` during the build process may be able to write files outside the intended output directory.
Depending on the build and deployment environment, this may:
* overwrite unintended files
* affect generated artifacts
* impact deployment outputs or downstream tooling
This issue is limited to build-time static site generation and does not affect request-time routing.
A path traversal issue in `toSSG()` allows files to be written outside the configured output directory during static site generation. When using dynamic route parameters via `ssgParams`, specially crafted values can cause generated file paths to escape the intended output directory.
## Details
The static site generation process creates output files based on route paths derived from application routes and parameters. When `ssgParams` is used to provide values for dynamic routes, those values are used to construct output file paths. If these values contain traversal sequences (e.g. `..`), the resulting output path may resolve outside the configured output directory. As a result, files may be written to unintended locations instead of being confined within the specified output directory.
For example:
```ts
import { Hono } from 'hono'
import { toSSG, ssgParams } from 'hono/ssg'
const app = new Hono()
app.get('/:id', ssgParams([{ id: '../pwned' }]), (c) => {
return c.text('pwned')
})
toSSG(app, fs, { dir: './static' })
```
In this case, the generated output path may resolve outside `./static`, resulting in a file being written outside the intended output directory.
## Impact
An attacker who can influence values passed to `ssgParams` during the build process may be able to write files outside the intended output directory.
Depending on the build and deployment environment, this may:
* overwrite unintended files
* affect generated artifacts
* impact deployment outputs or downstream tooling
This issue is limited to build-time static site generation and does not affect request-time routing.
ghsa CVSS4.0
5.9
Vulnerability type
CWE-22
Path Traversal
Published: 8 Apr 2026 · Updated: 8 Apr 2026 · First seen: 8 Apr 2026