Skip to content

Commit b424ecd

Browse files
authored
Fix reported vulnerability (#290)
1 parent 5a6e2b7 commit b424ecd

File tree

5 files changed

+12
-5
lines changed

5 files changed

+12
-5
lines changed

.all-contributorsrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"projectName": "cadwyn",
33
"projectOwner": "zmievsa"
4-
}
4+
}

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ Please follow [the Keep a Changelog standard](https://keepachangelog.com/en/1.0.
55

66
## [Unreleased]
77

8+
## [5.4.3]
9+
10+
### Fixed
11+
12+
* XSS vulnerability in `/docs` and `/redoc` endpoints where the `version` parameter was not properly sanitized, allowing potential cross-site scripting attacks
13+
814
## [5.4.2]
915

1016
### Fixed

cadwyn/applications.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from logging import getLogger
66
from pathlib import Path
77
from typing import TYPE_CHECKING, Annotated, Any, Optional, Union, cast
8+
from urllib.parse import quote
89

910
import fastapi
1011
from fastapi import APIRouter, FastAPI, HTTPException, routing
@@ -389,7 +390,7 @@ async def swagger_dashboard(self, req: Request) -> Response:
389390

390391
if version:
391392
root_path = self._extract_root_path(req)
392-
openapi_url = root_path + f"{self.openapi_url}?version={version}"
393+
openapi_url = root_path + f"{self.openapi_url}?version={quote(version, safe='')}"
393394
oauth2_redirect_url = self.swagger_ui_oauth2_redirect_url
394395
if oauth2_redirect_url:
395396
oauth2_redirect_url = root_path + oauth2_redirect_url
@@ -407,7 +408,7 @@ async def redoc_dashboard(self, req: Request) -> Response:
407408

408409
if version:
409410
root_path = self._extract_root_path(req)
410-
openapi_url = root_path + f"{self.openapi_url}?version={version}"
411+
openapi_url = root_path + f"{self.openapi_url}?version={quote(version, safe='')}"
411412
return get_redoc_html(openapi_url=openapi_url, title=f"{self.title} - ReDoc")
412413

413414
return self._render_docs_dashboard(req, docs_url=cast("str", self.redoc_url))

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cadwyn"
3-
version = "5.4.2"
3+
version = "5.4.3"
44
description = "Production-ready community-driven modern Stripe-like API versioning in FastAPI"
55
authors = [{ name = "Stanislav Zmiev", email = "zmievsa@gmail.com" }]
66
license = "MIT"

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)