Skip to content

Commit ad1d21f

Browse files
fix(security): address XSS and TLS verification issues
- Escape spec_id and library in fallback title (XSS prevention) - Escape preview_url with quote=True before inserting in HTML template - Enable proxy_ssl_verify for backend proxy to prevent MITM attacks - Add trusted CA certificate path for TLS verification Addresses Copilot and GitHub Advanced Security findings. 🤖 Generated with [Claude Code](https://claude.ai/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e82dca0 commit ad1d21f

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

api/routers/seo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ async def seo_spec_implementation(
154154
# Fallback when DB unavailable
155155
return HTMLResponse(
156156
BOT_HTML_TEMPLATE.format(
157-
title=f"{spec_id} - {library} | pyplots.ai",
157+
title=f"{html.escape(spec_id)} - {html.escape(library)} | pyplots.ai",
158158
description=DEFAULT_DESCRIPTION,
159159
image=DEFAULT_IMAGE,
160160
url=f"https://pyplots.ai/{html.escape(spec_id)}/{html.escape(library)}",
@@ -174,7 +174,7 @@ async def seo_spec_implementation(
174174
BOT_HTML_TEMPLATE.format(
175175
title=f"{html.escape(spec.title)} - {html.escape(library)} | pyplots.ai",
176176
description=html.escape(spec.description or DEFAULT_DESCRIPTION),
177-
image=image,
177+
image=html.escape(image, quote=True),
178178
url=f"https://pyplots.ai/{html.escape(spec_id)}/{html.escape(library)}",
179179
)
180180
)

app/nginx.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ server {
4646
proxy_pass https://api.pyplots.ai/seo-proxy$request_uri;
4747
proxy_set_header Host api.pyplots.ai;
4848
proxy_ssl_server_name on;
49+
proxy_ssl_verify on;
50+
proxy_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
4951
}
5052

5153
# SPA routing - serve index.html for all routes

0 commit comments

Comments
 (0)