Fix security vulnerabilities: XSS, cookie hardening, rate limiter bypass, HSTS, and open redirect

- Fix XSS in showToast() by replacing innerHTML with safe DOM construction via textContent
- Add Secure flag to session and CSRF cookies when base_url uses HTTPS
- Prevent rate limiter bypass by only trusting X-Forwarded-For/X-Real-IP from private/loopback IPs
- Add Strict-Transport-Security header when running behind HTTPS
- Validate short link URLs to prevent open redirects (must be http, https, or relative path)
- Remove runtime config.toml file write from slug length update handler
- Pin Docker base image to alpine:3.20 instead of floating latest tag

Co-Authored-By: Claude Opus 4.6 <[email protected]>
This commit is contained in:
lucioandClaude Opus 4.6 committed 2026-05-21 20:57:47 -07:00
1 parent 65e013d728
commit 737a48ac30
5 files changed
+78 -54

No files matched your search

+12 -4
View File
@@ -255,10 +255,18 @@ function showToast(message, type) {
const toast = document.createElement("div");
toast.className = `toast ${type === "success" ? "toast-success" : "toast-error"}`;
toast.innerHTML = `
<div class="toast-message">${message}</div>
<button class="toast-close" onclick="dismissToast(this)">&times;</button>
`;
const msgDiv = document.createElement("div");
msgDiv.className = "toast-message";
msgDiv.textContent = message;
const closeBtn = document.createElement("button");
closeBtn.className = "toast-close";
closeBtn.textContent = "×";
closeBtn.addEventListener("click", function() { dismissToast(closeBtn); });
toast.appendChild(msgDiv);
toast.appendChild(closeBtn);
container.appendChild(toast);
}