# GHSA-674p-xv2x-rf3g: Litestar has potential log injection in exception logging

> Attackers can inject newlines into logs via URL paths in Litestar when exception logging is enabled, allowing log forging.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 11 Aug 2025

## What is GHSA-674p-xv2x-rf3g?

GHSA-674p-xv2x-rf3g is a vulnerability in litestar, published on 11 Aug 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Summary

Litestar does not escape url paths when logging exceptions. This makes logger vulnerable to CRLF injection if logging level is configured to debug or `log_exceptions` is set to "always", which allows attackers to inject newlines and forge log entries.

### Details

Litestar directly formats unquoted path into exception logs without validation or escaping when using default exception logging handler.

https://github.com/litestar-org/litestar/blob/1e0dc7c4d67151c836208a3e360051e983b5083a/litestar/logging/config.py#L145-L150

Attackers can inject newlines in logs by embedding`%0d%0a` in url path.

`log_exceptions="always"` is not enabled by default. However, it is set in the examples of documentation (https://github.com/litestar-org/litestar/blob/1e0dc7c4d67151c836208a3e360051e983b5083a/docs/usage/logging.rst#logging). User will be impacted if they directly copy the logging config from docs.

### PoC

```
curl "http://172.17.0.2:8000/%29%0D%0AINFO:%20%20%20%20%20127.0.0.1:8192%20-%20%22POST%20/login%20HTTP/1.1%22%20200%20OK%0D%0A%28"
```

logging:

```
2025-07-15 00:00:00 - litestar - ERROR - Uncaught exception (connection_type=http, path=/)
INFO:     127.0.0.1:8192 - "POST /login HTTP/1.1" 200 OK
...
```

If stacktracks for 404 are configured to be ignored (`disable_stack_trace={404},`), attacker may also exploit this by sending malformed requests to cause 400/500 exceptions and avoid 404 in endpoints with str path parameters.

## Which versions are affected by GHSA-674p-xv2x-rf3g?

2 open source packages ship an affected version, including litestar.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `litestar` | PyPI | All versions | 2.17.0 |
| `litestar` | PyPI | All versions | 2.17.0 |

## How do I fix GHSA-674p-xv2x-rf3g?

Upgrade litestar to 2.17.0 or later.

## Is GHSA-674p-xv2x-rf3g being exploited?

There is no known exploitation of GHSA-674p-xv2x-rf3g in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-674p-xv2x-rf3g and fix it if it is affected.

What it is: GHSA-674p-xv2x-rf3g is a vulnerability in litestar, published on 11 Aug 2025. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-674p-xv2x-rf3g in the wild and no public exploit code.

Affected packages and fixed versions:
- litestar (PyPI): affected all versions; fixed in 2.17.0
- litestar (PyPI): affected all versions; fixed in 2.17.0

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-674p-xv2x-rf3g/ (Markdown: https://insights.sbomify.com/GHSA-674p-xv2x-rf3g/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-674p-xv2x-rf3g

---
From sbomify Insights: https://insights.sbomify.com/GHSA-674p-xv2x-rf3g/
Summaries are generated and may contain mistakes; the official description above is the record.
