fix(security): patch 5 vulnerabilities from security audit
- mask API keys in usage stats/history responses (apiKeyMasked) - validate proxy URL scheme + reject shell metachars before env write - escape HTML in OAuth callback page to prevent XSS - atomic O_EXCL lock file to prevent TOCTOU race in MITM startServer - set mitmIsRestarting guard synchronously before any await Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -154,14 +154,24 @@ export function clearCodexSession(state) {
|
||||
pendingExchanges.delete(state);
|
||||
}
|
||||
|
||||
function escapeHtml(str) {
|
||||
return String(str)
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
function renderCodexResultPage(success, message) {
|
||||
const color = success ? "#22c55e" : "#ef4444";
|
||||
const icon = success ? "✓" : "✗";
|
||||
const title = success ? "Authentication Successful" : "Authentication Failed";
|
||||
const safeMessage = escapeHtml(message);
|
||||
return `<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"><title>${title}</title>
|
||||
<style>body{font-family:system-ui;display:flex;justify-content:center;align-items:center;height:100vh;margin:0;background:#f5f5f5}.c{text-align:center;padding:2rem;background:#fff;border-radius:8px;box-shadow:0 2px 10px rgba(0,0,0,.1)}.i{color:${color};font-size:3rem}h1{margin:1rem 0}p{color:#666}</style>
|
||||
</head><body><div class="c"><div class="i">${icon}</div><h1>${title}</h1><p>${message}</p><p>Closing in <span id="cd">3</span>s...</p>
|
||||
</head><body><div class="c"><div class="i">${icon}</div><h1>${title}</h1><p>${safeMessage}</p><p>Closing in <span id="cd">3</span>s...</p>
|
||||
<script>let n=3;const c=document.getElementById("cd");const t=setInterval(()=>{n--;c.textContent=n;if(n<=0){clearInterval(t);window.close();}},1000);</script>
|
||||
</div></body></html>`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user