security(browser-extension): fix DOM-based XSS vulnerability#838
security(browser-extension): fix DOM-based XSS vulnerability#838akhilesharora wants to merge 1 commit intosupermemoryai:mainfrom
Conversation
|
@akhilesharora can you share demo with this new changes? |
|
@akhilesharora any update? |
Tested this by saving memories with HTML payloads ( For example, saving To reproduce: # Save a memory with HTML payload
curl -X POST 'https://api.supermemory.ai/v3/documents' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"content": "<img src=x onerror=alert(document.cookie)> My favorite color is blue"}'
# Wait ~20 seconds for processing, then search
curl -X POST 'https://api.supermemory.ai/v4/search' \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"q": "favorite color"}'
# Returns clean text, HTML stripped by AI processingThat said, that's just a side effect of the AI summarization, not intentional sanitization. The extension code itself doesn't validate anything and passes whatever comes back from the API straight to innerHTML. If the backend processing ever changes, this becomes exploitable. The createTextNode fix is the right defensive approach regardless of what the backend does - just wanted to share what came up while integrating the SDK. |
Summary
Fixes critical DOM-based XSS vulnerability in browser extension content scripts.
Continuation of #459 with feedback addressed.
Changes
<div>,<br>) from stored memories - fixes the visible HTML tags issueinnerHTMLwithdocument.createTextNode()- prevents XSSFeedback Addressed
<div>tags appearing in prompt (MaheshtheDev)createTextNode()instead of wrapper elements