fix(sec-86): harden iframe postMessage to trusted parent origins#189
Open
fix(sec-86): harden iframe postMessage to trusted parent origins#189
Conversation
Replaces wildcard '*' target with explicit trusted-origin list sourced from CS_ALLOWED_ORIGINS. Guards inbound message listener by source window identity and origin allowlist. Fails closed when no trusted origins are configured. Also addresses SEC-87. 🔒 Scanned for secrets using gitleaks 8.30.1
Contributor
Docker Preview Images ReadyPreview Docker images have been built for this PR: ECR (internal): docker pull 422074288268.dkr.ecr.us-east-1.amazonaws.com/rudderstack/profiles-code-server:pr-189Image Details:
Test the image: docker run --rm -p 8080:8080 422074288268.dkr.ecr.us-east-1.amazonaws.com/rudderstack/profiles-code-server:pr-189
|
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.
Summary
'*'postMessagetarget in the code-server iframe client with an explicit allowlist sourced fromCS_ALLOWED_ORIGINS(SEC-86).messagelistener inclient.tsby bothparentEvent.source === parent(window identity) and an origin allowlist (SEC-87).postMessageis sent and no inbound messages are processed.window.location.origin— iframe and parent live at different origins, so the browser was silently dropping those messages. Now targets the validatedparentEvent.origin.Mechanism
New quilt patch
patches/harden-iframe-postmessage.diff:lib/vscode/src/vs/base/common/product.ts— addscodeServerParentOrigins?: readonly string[]toIProductConfiguration.lib/vscode/src/vs/server/node/webClientServer.ts— parsesprocess.env.CS_ALLOWED_ORIGINSand injects into the workbenchproductConfiguration(mirrors the existingVSCODE_PROXY_URIenv-var pattern a few lines above).lib/vscode/src/vs/workbench/browser/client.ts— origin-guarded outbound + inbound messaging.Linear
Fixes SEC-86
Fixes SEC-87
Test plan
quilt push -aapplies the full stack cleanly (CIbuild-vscode.yamlgate).CS_ALLOWED_ORIGINS=https://app.dev.rudderlabs.com, verify:loadedpostMessage reaches the webapp iframe parent on startup.CS_ALLOWED_ORIGINSempty, no outboundpostMessageis fired and no inbound messages are processed.CodeServerImageNamein rudder-devops to verify embedding still works in dev before closing SEC-86 / SEC-87.