fix: add postMessage origin validation to useUserSync - #7
Open
FaizanKolega wants to merge 1 commit into
Open
FaizanKolega wants to merge 1 commit into
FaizanKolega wants to merge 1 commit into
Conversation
FaizanKolega
force-pushed
the
nc-fix/postmessage-origin-validation
branch
from
December 10, 2025 15:20
5207cc1 to
fe5511f
Compare
Fixes CWE-345 (Insufficient Verification of Data Authenticity) and OWASP A08:2021 vulnerability where wildcard origin ('*') in postMessage allowed any iframe to receive sensitive user data (id, email, display_name).
Changes:
- Add origin validation for postMessage sender (replaces wildcard '*' with specific origins)
- Add origin validation for postMessage receiver (validates event.origin)
- Allow same-origin iframes and trusted external domains (docs.google.com for Google Docs viewer)
- Handle edge cases (about:blank, data:, blob: URLs)
- Add security constants for maintainability
Defence in depth improvement with no breaking changes.
FaizanKolega
force-pushed
the
nc-fix/postmessage-origin-validation
branch
from
December 10, 2025 15:55
fe5511f to
79df495
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add origin validation to postMessage in useUserSync to prevent data leakage to untrusted iframes and block malicious parent windows from injecting fake user data. Resolves CWE-345 (Insufficient Verification of Data Authenticity) and OWASP A08:2021 vulnerabilities.
Change Summary
Added origin validation to both sender and receiver in
useUserSync.tspostMessage communication:Sender side: Replaced wildcard
*origin with specific origin validation - only sends user data to same-origin iframes or explicitly trusted domains (docs.google.com for Google Docs viewer)Receiver side: Added
event.originvalidation before processing messages - rejects messages from untrusted origins with console warningsFixes security findings:
*Files modified:
packages/nc-gui/composables/useUserSync.tsChange type
Test/ Verification
Manual testing:
cd packages/nc-gui npm run devVerify same-origin iframes work:
Verify Google Docs viewer works:
Verify security working:
Additional information / screenshots (optional)
Security Context:
Backward Compatibility: ✅ Fully compatible - no breaking changes to existing functionality
Implementation Details:
getIframeTargetOrigin()helper to validate iframe sourcesThis change is a defence-in-depth security improvement that prevents potential data leakage while maintaining full backward compatibility.